[Discussion] Generic X3TC S&M questions II
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 2033
- Joined: Wed, 29. Jun 05, 01:45
@Bishop/Cycrow
One thing however, on the note of global variables for loopy type of scripts. I find it useful to have 3 states,
-Running
-Not Running
-Shutting down
Because, if you only have 2 states (running and not running) then e.g.
1. You have it running, and it has 10ms til the next loop
2. You turn it off, the global variable is now set to not running
3. You turn it on again (before the 10ms is over), and the variable is set to running again, but you now have 2 scripts running.
With 3 states you simply do
(to turn off) if running, set state shutting down; otherwise, nothing
(to turn on) if running, do nothing; if shutting down, set state to running; if not running, set state to running, start new script;
One thing however, on the note of global variables for loopy type of scripts. I find it useful to have 3 states,
-Running
-Not Running
-Shutting down
Because, if you only have 2 states (running and not running) then e.g.
1. You have it running, and it has 10ms til the next loop
2. You turn it off, the global variable is now set to not running
3. You turn it on again (before the 10ms is over), and the variable is set to running again, but you now have 2 scripts running.
With 3 states you simply do
(to turn off) if running, set state shutting down; otherwise, nothing
(to turn on) if running, do nothing; if shutting down, set state to running; if not running, set state to running, start new script;
-
- Posts: 7232
- Joined: Fri, 9. Apr 04, 21:19
I see your point, as my script is to be called manually by the player I think the chance of a repeat occurrence in 100-500ms is pretty low.
However I will endeavor to code a system such as that you describe. . . it will be very good practice, and we'll see if I've truly got my head round Cycrow's code.
Thanks for all the help, I realise it must be a little irritating to have such a scripting noob asking silly questions!
However I will endeavor to code a system such as that you describe. . . it will be very good practice, and we'll see if I've truly got my head round Cycrow's code.
Thanks for all the help, I realise it must be a little irritating to have such a scripting noob asking silly questions!
"Shoot for the Moon. If you miss, you'll end up co-orbiting the Sun alongside Earth, living out your days alone in the void within sight of the lush, welcoming home you left behind." - XKCD
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
Different question, probably easier to answer. Whats the trick to getting a scripted station to produce two products? I start with:
The odd thing is if I change the name of the station, it breaks the code after the line that changes the name. This code works fine for one product, aside from it doesnt fill the resources all the way (even if I create code to check max hold, then add max number of each resource).
If I add another product (say 1 GJ shielding), it never produces the second. Am I doing something wrong?
Code: Select all
001 $station = create station: type=Terran Matter/Anti-Matter Launcher Forge owner=Terran addto=Mars x=-35000 y=0 z=35000
002 $maxshieldtype = $station -> get max. shield type that can be installed
003 = $station -> install 10 units of $maxshieldtype
004 $maxsheildstrength = $station -> get maximum shield strength
005 $station -> set current shield strength to $maxsheildstrength
006
007 * Add wares and fill stock
008 $station -> add product to factory or dock: 2 GJ Shield
009 = $station -> add 10 units of 2 GJ Shield
010
011 $station -> add primary resource to factory: Energy Cells
012 = $station -> add 10000 units of Energy Cells
013
014 $station -> add primary resource to factory: Terran MRE
015 = $station -> add 10000 units of Terran MRE
016
017 $station -> add primary resource to factory: Ore
018 = $station -> add 10000 units of Ore
019
020 $station -> station trade and production tasks: on=[TRUE]
021 return null
If I add another product (say 1 GJ shielding), it never produces the second. Am I doing something wrong?
-
- Posts: 13244
- Joined: Fri, 13. Jan 06, 16:39
Don't mess with stock amounts before you turn on the production.
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.
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
Thanks for the quick reply. Modifying existing code to:
:produces nothing. I might have to delete the script and re-write from scratch. Its odd that just changing the name of a station or moving one line of code can have such an impact.
Code: Select all
001 * Create Station
002 $station = create station: type=Terran Matter/Anti-Matter Launcher Forge owner=Terran addto=Mars x=-35000 y=0 z=35000
003 $maxshieldtype = $station -> get max. shield type that can be installed
004 = $station -> install 10 units of $maxshieldtype
005 $maxsheildstrength = $station -> get maximum shield strength
006 $station -> set current shield strength to $maxsheildstrength
007 $station -> station trade and production tasks: on=[TRUE]
008
009 * Add wares and fill stock
010 $station -> add product to factory or dock: 2 GJ Shield
011 = $station -> add 7 units of 2 GJ Shield
012
013 $station -> add product to factory or dock: 1 GJ Shield
014 = $station -> add 7 units of 1 GJ Shield
015
016 $station -> add primary resource to factory: Energy Cells
017 = $station -> add 10000 units of Energy Cells
018
019 $station -> add primary resource to factory: Terran MRE
020 = $station -> add 10000 units of Terran MRE
021
022 $station -> add primary resource to factory: Ore
023 = $station -> add 10000 units of Ore
024
025 return null
-
- Posts: 13244
- Joined: Fri, 13. Jan 06, 16:39
It's literally what you told it to do.eldyranx3 wrote::produces nothing.
I thought it would be obvious to add products and resources instead of turning on the production of... nothing.
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.
-
- Posts: 3823
- Joined: Fri, 12. Aug 05, 20:46
Let's be a little more explicit.
1. Turn OFF (optional, but good habit especially for re-usability)
2. Set ressource / products
3. Turn ON
4. Add ressources
1. Turn OFF (optional, but good habit especially for re-usability)
2. Set ressource / products
3. Turn ON
4. Add ressources
X3:TC/AP Pirate Guild 3 - Yaki Armada 2 - Anarkis Defense System
Anarkis Gaming HQ
Independent Game Development
X3 Scripting and Modding Station
Anarkis Gaming HQ
Independent Game Development
X3 Scripting and Modding Station
-
- Posts: 2178
- Joined: Sat, 14. Jan 06, 21:29
-
- Posts: 7232
- Joined: Fri, 9. Apr 04, 21:19
Ok, this is odd.
I want to return the type of ship I am flying.
I.e. If I am flying a Panther, I want to return "Panther"
I think this is known as the ship "type"
I can't seem to find the command to do this.
<RetVar> = get player ship
<RetVar/IF> = <RefObj> get name
Both return the name of the ship
<RetVar/IF><RefObj> get object class
Returns the ship class (obviously!)
I think what I want is:
<RetVar><RefObj> get ship type
Damned if I can find it !!
I want to return the type of ship I am flying.
I.e. If I am flying a Panther, I want to return "Panther"
I think this is known as the ship "type"
I can't seem to find the command to do this.
<RetVar> = get player ship
<RetVar/IF> = <RefObj> get name
Both return the name of the ship
<RetVar/IF><RefObj> get object class
Returns the ship class (obviously!)
I think what I want is:
<RetVar><RefObj> get ship type
Damned if I can find it !!
"Shoot for the Moon. If you miss, you'll end up co-orbiting the Sun alongside Earth, living out your days alone in the void within sight of the lush, welcoming home you left behind." - XKCD
-
- Posts: 3823
- Joined: Fri, 12. Aug 05, 20:46
$shiptype = [PLAYERSHIP] -> get ware type code of object
in the beginning of the General Object Commands
btw, [playership] and "get player ship" returns a pointer to the ship itself, it's very different from "get name" which returns a string. As an example:
$ship = get player ship
$shield = $ship -> get shield in %
will work, but
$ship = [playership] -> get name
$shield = $ship -> get shield in %
won't
in the beginning of the General Object Commands
btw, [playership] and "get player ship" returns a pointer to the ship itself, it's very different from "get name" which returns a string. As an example:
$ship = get player ship
$shield = $ship -> get shield in %
will work, but
$ship = [playership] -> get name
$shield = $ship -> get shield in %
won't

X3:TC/AP Pirate Guild 3 - Yaki Armada 2 - Anarkis Defense System
Anarkis Gaming HQ
Independent Game Development
X3 Scripting and Modding Station
Anarkis Gaming HQ
Independent Game Development
X3 Scripting and Modding Station
hi i was thinking of making an M0 mod, after being ispired by a post from someone that i cant remember the name of (sorry).
of course i know that M9s function improperly so i just give them M2 class and say that they'er M0. imho an M0 is a ship with lots of guns, shields and M6 internal docking but thats beside the point.
what i really need to know is a basic description of how to use the mission director to make an M0 plot. it would start like the hub plot, contacted by a goner (the mad one) offered ship blueprints in return for nividium and then having to go and get a scientist from each race to help construct it. lots of scavenging to some special shipyard, then having to wait a while as its finished. but oh no, next it turns out that Xenon, Yaki, Khaak, Pirates and an unkown terran group (enemy race in this so it doesnt ruin anyones rep) and are aproaching from all sides to destroy/ capture the shipyard. you have to defend it for a certian amount of time and if its destroyed thats it, mission failed. if it survives long enough you can transfer into it and give it its maiden voyage to finish off any remaining enemies. and thats it plot complete, shiny new M0 all for you.
i was going to use an edited version of the Hub plot but i have a problem. though it looks like the script editor, i cant make neither heads nor tails of how to make this.
of course i know that M9s function improperly so i just give them M2 class and say that they'er M0. imho an M0 is a ship with lots of guns, shields and M6 internal docking but thats beside the point.
what i really need to know is a basic description of how to use the mission director to make an M0 plot. it would start like the hub plot, contacted by a goner (the mad one) offered ship blueprints in return for nividium and then having to go and get a scientist from each race to help construct it. lots of scavenging to some special shipyard, then having to wait a while as its finished. but oh no, next it turns out that Xenon, Yaki, Khaak, Pirates and an unkown terran group (enemy race in this so it doesnt ruin anyones rep) and are aproaching from all sides to destroy/ capture the shipyard. you have to defend it for a certian amount of time and if its destroyed thats it, mission failed. if it survives long enough you can transfer into it and give it its maiden voyage to finish off any remaining enemies. and thats it plot complete, shiny new M0 all for you.
i was going to use an edited version of the Hub plot but i have a problem. though it looks like the script editor, i cant make neither heads nor tails of how to make this.
-
- Posts: 1468
- Joined: Wed, 3. Aug 05, 05:05
Just a question to any of the scripters who may know the answer,
Why does this work fine in a normal game but fails in a custom game start?
It does not skip the 'break' even if '$Bank.Int.Updater.Run == [TRUE]'
Anyone have an explanation as to why this is so?
MarCon
Why does this work fine in a normal game but fails in a custom game start?
Code: Select all
188 |$Bank.Int.Updater.Run = get global variable: name='mc.st.ex.bank.int.updater'
189 |skip if $Bank.Int.Updater.Run == [TRUE]
190 ||break
Anyone have an explanation as to why this is so?
MarCon
-
- Posts: 13244
- Joined: Fri, 13. Jan 06, 16:39
at 188.5 you should print the variable to a log file - or just the in game log.
It's unlikely that the game start affects the working of logical operations.
It's unlikely that the game start affects the working of logical operations.
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.
-
- Posts: 1468
- Joined: Wed, 3. Aug 05, 05:05
Sorry, should have said, I did print to log file thats how i know it is returning [True] , the log actually says 'Bank updater run = 1' so thats returning true.Gazz wrote:at 188.5 you should print the variable to a log file - or just the in game log.
It's unlikely that the game start affects the working of logical operations.
So the 'Skip' is what is not working and i am at a loss as to understanding why. i's not skipping and hitting the break so exiting a 'while' loop when it should only exit if the GV returns anything other than true.
If i comment out the 'break' the script no longer exits incorrectly, this is my reasoning that the skip is not working.
MarCon
-
- Posts: 13244
- Joined: Fri, 13. Jan 06, 16:39
Your "1" could still be the wrong variable type.
189 |skip if $Bank.Int.Updater.Run
or even shorter:
188 |skip if get global variable: name='mc.st.ex.bank.int.updater'
189 |break
Is generally safer because it equally works for anything that is not null or 0.
189 |skip if $Bank.Int.Updater.Run
or even shorter:
188 |skip if get global variable: name='mc.st.ex.bank.int.updater'
189 |break
Is generally safer because it equally works for anything that is not null or 0.
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.
-
- Posts: 1468
- Joined: Wed, 3. Aug 05, 05:05
-
- Posts: 13244
- Joined: Fri, 13. Jan 06, 16:39
Or just keep it simple and readable.
001 while get global variable: name='mc.st.ex.bank.int.updater'
050 |bla bla
100 end
001 while get global variable: name='mc.st.ex.bank.int.updater'
050 |bla bla
100 end
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.
-
- Posts: 7232
- Joined: Fri, 9. Apr 04, 21:19
Has any one any idea where the vocal sample ID's are for the race names?
0001-L044, seems to be far from a complete list. . . . . I KNOW Betty can say "Xenon"!!
Edit:
Another question, Ship classes.
"Little Ship" = M5, M4, M3, TS, TP
"Big Ship" = M1, M2, M6, TL
I know that much from the MSCI Handbook, but what about M8 & TM. Am I right in thinking they too are "Big Ships"
Edit2: Ah HA, I have written a script to find out! M8's and TM's ARE Big Ships
0001-L044, seems to be far from a complete list. . . . . I KNOW Betty can say "Xenon"!!
Edit:
Another question, Ship classes.
"Little Ship" = M5, M4, M3, TS, TP
"Big Ship" = M1, M2, M6, TL
I know that much from the MSCI Handbook, but what about M8 & TM. Am I right in thinking they too are "Big Ships"
Edit2: Ah HA, I have written a script to find out! M8's and TM's ARE Big Ships
"Shoot for the Moon. If you miss, you'll end up co-orbiting the Sun alongside Earth, living out your days alone in the void within sight of the lush, welcoming home you left behind." - XKCD
-
- Posts: 2255
- Joined: Mon, 31. Oct 05, 08:44
I have an issue with a menu opened against a ship clearing the ships current command.
Step One – Open Main Summary Menu and everything is okay
[ external image ]
Step Two – Open Menu for the object, in this case the Mammoth and it's command/action has been cleared:
[ external image ]
Now if I was using a ship command slot I could use the “set ship command preload script: command='cmd' script='script' command, but this is all done via hotkey.
Is there a work around?
LA
Step One – Open Main Summary Menu and everything is okay
[ external image ]
Step Two – Open Menu for the object, in this case the Mammoth and it's command/action has been cleared:
[ external image ]
Now if I was using a ship command slot I could use the “set ship command preload script: command='cmd' script='script' command, but this is all done via hotkey.
Is there a work around?
LA
-
- Posts: 13244
- Joined: Fri, 13. Jan 06, 16:39
If you must open the menu on task 0 of the ship, make it an interrupt instead of start task.
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.