[Discussion] Generic X3TC S&M questions III
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
That ...wasnt in the tutorial i went through, Thanks, that got it working. ^-^ScRaT_GER wrote:To fix this, simply use the version of "set script command upgrade" which doesn't take an additional "script" parameter.Firewrath wrote:So, can someone Please tell me Why this runs the 'test.message' script as Soon as i open the ship command screen?
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
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
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. >.>
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.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?
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
I don't know if this is possible...B) Is there Any way to get a passenger on a ship with an S sized cargo by scripting?
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.
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'.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:
Maybe my tutorial on menus can be of help.(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)
Greetings,
ScRaT
New MD commands will get listed and possibly explained in the X3: Albion Prelude - A Survival Guide soon™.
MFG
Ketraar
MFG
Ketraar
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
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
- EmperorJon
- Posts: 9378
- Joined: Mon, 29. Dec 08, 20:58
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... )
It might be nice to give the Yaki a proper economy now they have a stock exchange.
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... )
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.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
@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.
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.
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?
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.
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?
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?
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
Instead I would have to store the reference data as an array and loop through it each time?
No.So there are no pure hash tables then where I can put anything of a certain type in there I want?
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.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.
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
X3 can surprise you with how long a given instruction takes.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.
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.
There is no sense crying over every mistake. You just keep on trying till you run out of cake.