PDA

View Full Version : LUA questions?



bloodylemming
September 9th, 2022, 23:27
I can't seem to find or figure out where to post questions, specifically about LUA, for instance, what's the syntax for simple rounding, using the math function?

Zacchaeus
September 9th, 2022, 23:52
See the developers guide https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644285/Developer+Guide as a starting point. You’ll probably get more help by posting in the armoury section or on Discord.

superteddy57
September 9th, 2022, 23:53
math.ceil (round up) or math.floor (round down) on a number. Most questions would be placed in the Workshop when related to coding questions.

darrenan
September 10th, 2022, 01:36
https://www.lua.org/docs.html for general questions about the LUA language. As mentioned above see the developer guide section of the FG wiki for information specific to programming for FG.

celestian
September 10th, 2022, 01:46
I can't seem to find or figure out where to post questions, specifically about LUA, for instance, what's the syntax for simple rounding, using the math function?

IMO the best option for this is google search. More than likely you'll find it on stackexchange.

bloodylemming
September 10th, 2022, 05:38
I find plenty of info on .ceil and .floor, but that's just round up, round down. I need a simple rounding, where .5 is rounded up and anything less is rounded down. Gone through the LUA 5.1 reference and so far, it's looking like I'll just have to make a function.

Can an admin move this to the Armory or Workshop, or do I just repost it?

damned
September 10th, 2022, 07:35
Lua deliberately doesnt have existing functions for everything.
If you need to do something like simple rounding use
math.floor(num + 0.5);

bloodylemming
September 10th, 2022, 17:37
Lua deliberately doesnt have existing functions for everything.
If you need to do something like simple rounding use
math.floor(num + 0.5);

That's simpler than what I was going to do, which is to subtract .floor from .abs, make the comparison whether to add 1 to .floor... Thanks for saving me from myself. !)