[Help] How to convert numbers

The place to discuss scripting and game modifications for X4: Foundations.

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

Assailer
Posts: 478
Joined: Sun, 25. May 14, 17:45
x4

[Help] How to convert numbers

Post by Assailer »

Guys, How do i convert a floating value to integer in xml scipts?

<set_value name="$intvalue" exact="(int)$floatvalue"/>
or
<set_value name="$intvalue" exact="floor($floatvalue)"/>
or
... ?

I want to get rid of the fractional part.
morbideth
Posts: 391
Joined: Sun, 9. Nov 08, 03:07
x3tc

Re: [Index] X4: Foundations Tools, Tutorials and Resources

Post by morbideth »

Assailer wrote: Sat, 15. Dec 18, 23:17 Guys, How do i convert a floating value to integer in xml scipts?

<set_value name="$intvalue" exact="(int)$floatvalue"/>
or
<set_value name="$intvalue" exact="floor($floatvalue)"/>
or
... ?

I want to get rid of the fractional part.
a trailing i, or f for float.
($floatvalue)i
i.e. (player.money/$cost)i
Assailer
Posts: 478
Joined: Sun, 25. May 14, 17:45
x4

Re: [Index] X4: Foundations Tools, Tutorials and Resources

Post by Assailer »

morbideth wrote: Sun, 16. Dec 18, 13:43
Assailer wrote: Sat, 15. Dec 18, 23:17 Guys, How do i convert a floating value to integer in xml scipts?

<set_value name="$intvalue" exact="(int)$floatvalue"/>
or
<set_value name="$intvalue" exact="floor($floatvalue)"/>
or
... ?

I want to get rid of the fractional part.
a trailing i, or f for float.
($floatvalue)i
i.e. (player.money/$cost)i

Oooo nice! Thanks!
StopBanningMe7_III
Posts: 47
Joined: Wed, 24. Feb 16, 05:23
x4

Re: [Index] X4: Foundations Tools, Tutorials and Resources

Post by StopBanningMe7_III »

Are the xml schema the only source for such information as described above? When I discovered that values could be cast with trailing letters that look like identifiers I was so annoyed that I initially named that token group "stupid_inexplicable_trailing_f" in my little translator thingy.
Assailer
Posts: 478
Joined: Sun, 25. May 14, 17:45
x4

Re: [Index] X4: Foundations Tools, Tutorials and Resources

Post by Assailer »

StopBanningMe7_III wrote: Mon, 17. Dec 18, 01:49 Are the xml schema the only source for such information as described above? When I discovered that values could be cast with trailing letters that look like identifiers I was so annoyed that I initially named that token group "stupid_inexplicable_trailing_f" in my little translator thingy.
Those 'special' inexplicable tricks take quite a bit of effort to find, understand and successfully use them by trial/error. Your best bet is to ask here or to go through line by line the original scripts in hope to find what you are looking for.
Semantics for certain commands would require much more explanation to understand. I would like EGO to focus on fixing pathfinding first before spending time with documentation :)
StopBanningMe7_III
Posts: 47
Joined: Wed, 24. Feb 16, 05:23
x4

Re: [Index] X4: Foundations Tools, Tutorials and Resources

Post by StopBanningMe7_III »

Assailer wrote: Mon, 17. Dec 18, 05:33
StopBanningMe7_III wrote: Mon, 17. Dec 18, 01:49 Are the xml schema the only source for such information as described above? When I discovered that values could be cast with trailing letters that look like identifiers I was so annoyed that I initially named that token group "stupid_inexplicable_trailing_f" in my little translator thingy.
Those 'special' inexplicable tricks take quite a bit of effort to find, understand and successfully use them by trial/error. Your best bet is to ask here or to go through line by line the original scripts in hope to find what you are looking for.
Semantics for certain commands would require much more explanation to understand. I would like EGO to focus on fixing pathfinding first before spending time with documentation :)
Line by line by hand? Yeah... no.

As with all other problems in life, PERL TO THE RESCUE! Or maybe a library to extract grammars from xml files. That might work better.

I'll see if I can extract a full grammar for the language and post it here. I'm tired of not knowing how on earth to even start writing a mod.

(2 minutes later) EDIT: Here's a dump out of some of the core of the language. Pretty crude and only marginally useful, but at least it does give a list of a lot of the more complicated commands, and details what parameters the more basic commands take.

https://pastebin.com/raw/JxBFRRKa
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13489
Joined: Sun, 15. Feb 04, 20:12
x4

Re: [Help] How to convert numbers

Post by euclid »

Topic split and title adjusted.

For basics in scripting (XML and MD) please check the very first link in this sticky.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

Return to “X4: Foundations - Scripts and Modding”