Members | Sign In
All Forums > Mission Scripting
avatar

Formulas in Variables

posted Feb 02, 2013 14:11:28 by 5th_Wall_Gaming
So how would I go about referencing those values?

I can make a variable called "RandomNumber" which is a random number from 1 to 100.

But how do I say, "Place a ship and name it RandomNumber"?

Is this still not possible?
http://www.5thWallGaming.com
We make dreams reality
page   1
10 replies
avatar
JSpaced said Feb 02, 2013 16:05:37
Yes, I'm having trouble with this too. What is the correct way of making an integer (i.e. the radius of something) reference a variable?
J
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
MarkBell said Feb 04, 2013 14:19:37
Well, in that specific example, you just leave the name declaration field blank and it assigns a random name upon creation (H47 or whatever). The trick is the shipName is looking for a string, so even if you put it as shipName="RandomNumber + 0" it would just name your ship "RandomNumber + 0", not 417.

Most other variables should be able to take a reference like this:
<set_variable name="CenterPos" value="2.0" />
<create type="neutral" x="50000.0 + CenterPos" y="0.0" z="49000.0" angle="270.0" name="" hullID="0" />
and CenterPos could be referenced to something else, incremented, etc. The field has to be looking for a float type, and not a string type.
avatar
RussJudge said Feb 04, 2013 14:36:22
This goofy mission does play around with expressions (formulas) a bit, and the mission does work (although it is a bit strange). You can look at it for examples of how to make use of formulas. The mission was not intended as something to really play with, but more as a proof-of-concept for both expressions use and for the new commands that were offered with v. 1.7.

One of the tricks it does is to offer a way to truly randomize something, by incrementing a variable by one every second, and taking an action based on the value of that variable, triggered by some other event (in this case, a keypress by the user).
Russ
Author of Artemis Mod Loader.

Sign up for a free Dropbox account.
avatar
5th_Wall_Gaming said Feb 05, 2013 16:25:55
I tried both of these..
<set_variable name="RandomX" RandomFloatLow="0" RandomFloatHigh="99998"/>
<set_variable name="RandomZ" RandomFloatLow="0" RandomFloatHigh="99998"/>
<create type="station" x="1+RandomX" y="0" z="1+RandomZ" name="Station 1"/>

<set_variable name="RandomX" RandomIntLow="0" RandomIntHigh="99998"/>
<set_variable name="RandomZ" RandomIntLow="0" RandomIntHigh="99998"/>
<create type="station" x="1+RandomX" y="0" z="1+RandomZ" name="Station 2"/>

and neither of them made a station.
[Last edited Feb 05, 2013 16:26:18]
http://www.5thWallGaming.com
We make dreams reality
avatar
JSpaced said Feb 05, 2013 22:27:42
Does it work if you put spaces between 1 and + and variable name:

X="1 + RandomX" y="0.0" z="1 + RandomZ" etc. otherwise it's looking for variable: "1+RandomX"
[Last edited Feb 05, 2013 22:28:18]
"We should give him the send-off he deserves. He died saving us all. Prepare a Rocket-Shed for immediate launch."
avatar
5th_Wall_Gaming said Feb 06, 2013 05:10:38
Just tried it. No go.
http://www.5thWallGaming.com
We make dreams reality
avatar
MarkBell said Feb 06, 2013 11:55:38
Did you try adding a hullKey or hullID? I dunno if that's tripping it up.
avatar
5th_Wall_Gaming said Feb 06, 2013 16:55:27
Haven't for a station before and if I put in numbers, it works.
http://www.5thWallGaming.com
We make dreams reality
avatar
bleep751 said Feb 07, 2013 00:14:57
Hey, I've been using alot of the variable formulas, and I did have one suggestion for you. I see that your code has RandomFloatLow and High with a capital R. Try with a lowercase. with uppercase, the variables are just set to zero by default. With lowercase, seems to work. I tested this code below, and it worked without issue.

<event>
<if_variable name="station" comparator="=" value="0"/>
<set_variable name="RandomX" randomFloatLow="0" randomFloatHigh="99998"/>
<set_variable name="RandomZ" randomFloatLow="0" randomFloatHigh="99998"/>
<create type="station" x="1+RandomX" y="0" z="1+RandomZ" name="Station 1"/>
<set_variable name="station" value="1"/>
</event>
avatar
5th_Wall_Gaming said Feb 07, 2013 00:23:29
That WORKS!! THANK YOU!! :)
http://www.5thWallGaming.com
We make dreams reality
Login below to reply: