[FYI] Time Variables

The place to discuss scripting and game modifications for X Rebirth.

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

bbeach
Posts: 100
Joined: Tue, 24. Feb 09, 03:47
x4

[FYI] Time Variables

Post by bbeach »

Just a heads up (took me about an hour to figure this out).

I'm sure you've all seen a <wait exact="5s" /> type tag, which would sleep the script for 5 seconds. But say you wanted to use a calculated time.

You have your variable.
<set_value name="$myvalue" exact="2" />

Then you do some math.

<set_value name="$mywaittime" exact="$myvalue * 5 - 8 + 3" />

If you try to do <wait exact="$mywaittime" /> it will fail because the number '5' isn't a time.

What ended up working was multiplying the number by one second. So to wait for the numerical value of $mywaittime in seconds: <wait exact="$mywaittime*1s" /> You can do that at any point in the calculation, so <set_value name="$mywaittime" exact="($myvalue * 5 - 8 + 3)*1s" /> would also work.
Jey123456
Posts: 259
Joined: Sat, 23. Nov 13, 09:48
x4

Post by Jey123456 »

there is a casting system in place. to convert time to an integer (will give you seconds value of the time)

like, if you have

<set_value name="$myvalue" exact="2min" />
<set_value name="$myvalueinteger" exact="($myvalue)i" />

the i after the variable convert it to an integer, in time case, its the number of seconds.

there is a lot of similar letters just like you can convert an integer to time by adding an s or min next to it. or to a distance by adding an m or km

min and km inside the binary as far as i could figure thanks to some error logs, are simply converted to s * 60s (so 10min end up 10s * 60s) same concept for km

look for "Default suffix" in scriptproperties.html
bbeach
Posts: 100
Joined: Tue, 24. Feb 09, 03:47
x4

Post by bbeach »

I saw the suffix list, but I didn't know about the casting system, thanks! Well I guess if you ever run across a situation where casting won't work for some reason, try multiplying by one unit of what you want to convert to :p

Return to “X Rebirth - Scripts and Modding”