[Discussion] Generic X3TC S&M questions III

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon » Thu, 15. Dec 11, 23:30

Am I missing something, or do tsbw and maapfs not work for activating the SE/GE in AP!? :O
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22236
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Thu, 15. Dec 11, 23:33

should be the same as it was in TC

Firewrath
Posts: 121
Joined: Fri, 3. Aug 07, 05:49
x3tc

Post by Firewrath » Fri, 16. Dec 11, 14:30

ScRaT_GER wrote:
Firewrath wrote:So, can someone Please tell me Why this runs the 'test.message' script as Soon as i open the ship command screen?
To fix this, simply use the version of "set script command upgrade" which doesn't take an additional "script" parameter.
That ...wasnt in the tutorial i went through, Thanks, that got it working. ^-^
sorry it took me so long to reply, i dropped off there for a bit, or a week, ...or two, >.>

...and i have more questions for anyone nice enough to help, ^-^;
First, i dont have Albion Prelude and most likely wont for a while, so whatever nifty script addons it has, i dont have access to, (and id like to keep my script compatible with both X3TC/X3AP)

So.
A) Is there a way when running a command from the command menu that opens up a menu, to stop it from activating Autopilot or canceling the current Autopilot orders?
Id rather not use a hotkey, i have only a couple scripts installed and they all want to use 2-4 hotkeys, i am running out of room on my keyboard, -_-
i imagine im not the only one with this, so id like to keep it to the ships command menu if possible,


B) Is there Any way to get a passenger on a ship with an S sized cargo by scripting?
Im going to have them hired as pilots the same way sector/universal traders are,
(though via this script: '= $passenger -> move passenger to ship [THIS]: set passenger as pilot=[TRUE]')
so i dont need the passenger to stay in the cargo bay, i just wanted it as a pointer to pass localvars to with the 'hidden marine' method A.Persyn showed me in a reply Here.
Though obviously with passengers instead of marines, Unless theres someway to attach localvars to the pilot that itll keep once made into a passengers via: '<RetVar/IF><RefObj> add pilot of ship <Var/Ship> as passenger: disable ship =<Var/Boolean>'
Im trying to use this so stats that are attached to the pilot/passenger as localvars can be moved with the pilot/passenger without some complex ship localvar copy script,
(On the same note i geuss setting the pilot as a passenger would be rejected/destroyed on an ship with S cargo? ...and no, i havnt had time to test it as it Just came to me and i cant try it out for a bit yet, -_-)


C) Back to the menus. Can you call a menu up from another menu?
Ive tried and its not working, the second menu just never pops up,
im assuming my 'start - call script' bit is wrong, but im not sure, so i have these two scripts if anyone can point out what im doing wrong:

test.main.menu.xml

Code: Select all

  $a = 'a'
  $b = 'b'
  
  $menu =  create custom menu array
  
  add custom menu item to array $menu: text='Hire Pilot' returnvalue=$a
  add custom menu item to array $menu: text='Ship List' returnvalue=$b
  
  loop:
@ = wait 1 ms
  $return =  open custom menu: title='A Menu' description='Test' option array=$menu
  
  if $return == $a
@ |START [THIS] -> call script 'hire.pilot.test' : 
  else if $return == $b
@ |START [THIS] -> call script 'test.menu' : 
  end
  return null
test.menu.xml

Code: Select all

  *if not [THIS] == [PLAYERSHIP]
  $array =  get ship array: of race Player class/type=null
  $menu =  create custom menu array: heading='Your ships'
  $size =  size of array $array
  while $size
  |dec $size = 
  |$ship = $array[$size]
  |$ida = $ship -> get ID code
  |$idb = $ship -> get pilot name
  |$ibc = $ship -> get local variable: name='lpkilled'
  |$idd = $ship -> get pilot fightskill
  |$text = sprintf: fmt='%s (I: %s) (K: %s) (F: %s) (P: %s)', $ship, $ida, $idc, $idd, $idb
  |add custom menu item to array $menu: text=$text returnvalue=$ship
@ |= wait 1 ms
  end
  $ret =  open custom menu: title='Ship Destroyer' description=null option array=$menu
  skip if not $ret == -1
  |return null
  $ret -> destruct: show no explosion=[FALSE]
  *else
  *end
  return null
(Yes, i know what the 'destruct' does, but this is a place holder until i can figure out more complex menu arrays, like columns for each stat ($ida/$idb/etc) ...which is going slowly, :P)

but basically, menus/arrays are confusing enough without trying to embed 2-3 other menus into the one i already have,
(Which is how LV's tutorial does it Here.)
cause i'll have at least 1 menu for moving pilots around between docked ships, 1 for hiring pilots in docked ships, 1 for hiring marine pilots into docked ships, and all of those need to show an array of docked ships and/or a list of pilots/passengers/marines, so id have have each menu/command setup its own xml file just to keep it simpler for me,

Also, i know ive been asking a Lot of questions about all of this over the past few months, and i am grateful that more then a few of you have been willing to put up with them and help out, so I've been trying to avoid asking more for fear of pushing my luck, but right now i feel im So close to getting this done if i can work out these issues, that the rest should be easy enough for me to do since it deals with things behind the scenes like purchasing/installing wares and pilot salaries. (Which are of no use till I can get pilots on All ships. ^-^; )
Anyways. Point. Replys or not, help or not, i do want to just say Thanks you all that have helped me so far, which is a nice list of people. ^-^


Side note. The forums really need a Code or Spoiler button that would hide such things until you pushed a button to cut down on post size for such things as posting scripts. >.>

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Fri, 16. Dec 11, 16:05

A) Is there a way when running a command from the command menu that opens up a menu, to stop it from activating Autopilot or canceling the current Autopilot orders?
Yes, you can 'abuse' the command "set ship command preload script: command=<Object Command/Signal> script=<Script Name>". This commands runs the script <Script Name> whenever the specified signal or command is fired.
When the called script returns true (in other words, everything which is not [FALSE] or null) the script associated with that command is called (with the return on that script, btw).
So, now comes the 'abusing' part:
The called script simply never returns true, but always false. Thus the associated command is never called and the old command keeps running.

A small example:

Code: Select all

$cmd.config = {YOUR_COMMAND}
$cmd.ware  = [TRUE]
set script command upgrade: command=$cmd.config  upgrade=$cmd.ware  script='your.script.check'
set ship command preload script: command=$cmd.config script='your.script.config'
* This will actually never get called after the config-preload
global script map: set: key=$cmd.config, class={Ship}, race={Spieler}, script='your.script', prio=0
As it says, the last line will actually never make a script run, because you always return false in your preload-script (named 'your.script.config' here).
B) Is there Any way to get a passenger on a ship with an S sized cargo by scripting?
I don't know if this is possible...
However, note that you can always use arrays of arrays to represent objects.

So, you have two arrays in the end:
- an array of passengers (1)
- an array of arrays, where each array contains data associated with a passenger (2)

You store these arrays globally or locally and whenever you need to access the data of a passenger you find his index in (1) and retrieve the data at that index from (2).

Like that, you don't need some obscure hiding mechanism or localvar copy script. The only thing you have to watch out for, is to keep the array indices valid - i.e. if you delete a passenger from (1), make sure you delete the data from (2) aswell.
C) Back to the menus. Can you call a menu up from another menu?
Ive tried and its not working, the second menu just never pops up,
im assuming my 'start - call script' bit is wrong, but im not sure, so i have these two scripts if anyone can point out what im doing wrong:
Have you tried it without the START? Everything else looks fine to me, besides the fact that you're never actually looping in the main script, because you never use 'goto loop'.
(Yes, i know what the 'destruct' does, but this is a place holder until i can figure out more complex menu arrays, like columns for each stat ($ida/$idb/etc) ...which is going slowly, Razz)
Maybe my tutorial on menus can be of help.

Greetings,
ScRaT

User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 » Fri, 16. Dec 11, 16:51

Since I havent seen it here yet:

1) What new MD commands did Egosoft introduce in X3:AP?

2) What new variables did Egosoft add?

I'm half tempted to extract the new MD files myself, but if someone has already done so, and would like to consolidate knowledge here, I'm sure it would benefit everyone.

User avatar
Ketraar
EGOSOFT
EGOSOFT
Posts: 11868
Joined: Fri, 21. May 04, 17:15
x4

Post by Ketraar » Fri, 16. Dec 11, 17:10

New MD commands will get listed and possibly explained in the X3: Albion Prelude - A Survival Guide soon™.

MFG

Ketraar
Image

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22236
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Fri, 16. Dec 11, 18:41

the new script commands will also be explained (breifly) in the Survival guide as well.


however, one thing i will mention now, the handling of hotkeys has changed.
theres now a kind of built in hotkey manager so if you register the same script multiple times, they overwrite each other so u only get the 1 hotkey. This can also be used to change the text without needing to unregister (and losing the assigned key) and re-register.

also if the script the hotkey is calling no longer exists (ie its been removed) The hotkey will no longer be listed in the controls menu.

finally, you can also set page id/text id instead of a string and get the menu to read it directly from the text file. So changing the text file will change the displayed text

at a later point i will go through the changes to the custom menus, but for examples of them, you can look at the stock exchange that makes use of a lot of them, and also the upcoming bonus pack will use them abit

User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon » Sun, 18. Dec 11, 22:16

Something I've only just thought up...

What would be required to make the Yaki TLs build stations (at GoDs command) and make the Yaki have freetrade TSs like other races. Would it be a few simple job file edits (strongly suspect not... :P)

It might be nice to give the Yaki a proper economy now they have a stock exchange.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______

SyncViews
Posts: 58
Joined: Thu, 27. Jan 11, 14:38
x3tc

Post by SyncViews » Sat, 24. Dec 11, 10:08

Which files set up the initial relations between the races in TC and AP? If it is hardcoded for some reason, is there a clean way to overule it?

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent » Sun, 25. Dec 11, 06:38

@ChristmasJon
There are ways to make anything happen with the S.E, However, trying to use God is nigh impossible as pretty much no one knows how it works (There are probably people who do, but we can't really change how God is, on account of God being God)

------



I don't suppose anyone wants to make a(/another) super-station management trade script with me?
I find CAGS sorely lacking in some departments, and I want to change it to operate more from the station side, as opposed to operating from individual traders.

User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 » Mon, 26. Dec 11, 18:58

Easy question, and Im sure I can fumble through it, but when creating MD content for X3:AP does one place Text Files and MD files in X3TC\Addon directory? For example:

MD files -> X3TC\Addon\director
Text -> X3TC\Addon\t

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22236
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Mon, 26. Dec 11, 19:44

yes

User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 » Mon, 26. Dec 11, 20:48

Thanks!

iHans
Posts: 1
Joined: Fri, 30. Dec 11, 21:54

Post by iHans » Fri, 30. Dec 11, 22:44

Hello! After buying a Terran Osaka destroyer, I noticed that there were no weapons installed on the ship. I bought those basic EMPCs to every turret, but I would like to have those "Real" guns like Starburst Shockwave Cannons but every station has second to none of them, or none at all. Is there a dirty way to cheat more stock of those to stations?

User avatar
eldyranx3
Posts: 2178
Joined: Sat, 14. Jan 06, 21:29
xr

Post by eldyranx3 » Sat, 31. Dec 11, 02:27

Cycrows cheat package has an option 'Keep Station Stocked'. Check the stickies for a download link.

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Sat, 31. Dec 11, 02:57

Are the arrays used in scripts pure arrays, or do they have some functionality of a hash? I am thinking of running a Global script that would keep an 'array' for reference, but I don't want to be calling the "is x in array" method over and over again if its a pure array because of performance issues.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22236
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Sat, 31. Dec 11, 03:16

it is an array yes, global/local variables that you can set is a hash table

User avatar
RoverTX
Posts: 1436
Joined: Wed, 16. Nov 11, 18:37
x4

Post by RoverTX » Sat, 31. Dec 11, 03:34

So there are no pure hash tables then where I can put anything of a certain type in there I want? So I couldn't do something like this?

Code: Select all

data = get all stations from sector X
size = data.size
i = 0
while i < size
  if hashtable.get(data[i]) == null
     destory data[i]
  end
i++
end
Where the hashtable would just be a hash tables of specfic stations?

Instead I would have to store the reference data as an array and loop through it each time?

User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER » Sat, 31. Dec 11, 11:17

So there are no pure hash tables then where I can put anything of a certain type in there I want?
No.
I am thinking of running a Global script that would keep an 'array' for reference, but I don't want to be calling the "is x in array" method over and over again if its a pure array because of performance issues.
Well, if finding the index of a station in some global array is via the normal script commands is too slow for you, you could simply store the index of that station as a local variable on the station itself - although I doubt that it would make any noticable difference.
Of course you'd have to do some bookkeeping to make sure, that the indices and the array are always synced (i.e. when you delete a station from the global arrays, the indices of the other stations need to be adjusted).
Maybe there are better solutions, but I don't know enough about your use case.

Greetings,
ScRaT

User avatar
Gazz
Posts: 13244
Joined: Fri, 13. Jan 06, 16:39
x4

Post by Gazz » Sat, 31. Dec 11, 13:05

RoverTX wrote:I am thinking of running a Global script that would keep an 'array' for reference, but I don't want to be calling the "is x in array" method over and over again if its a pure array because of performance issues.
X3 can surprise you with how long a given instruction takes.
The only useful way is to parse 2 approaches. Last time I ran a loop with an empty line 2 million times. Took 4.5 sec. Then I put in line 1, took 5 sec... etc.

Some things like pathfinding through sectors are quite costly, looking up a local variable is not.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”