Anyone here who has an idea about how to fake expressions to be interpreted as true/false if they’re 0 or 1 as in lots of typical other languages?
Im porting a reasonably big JavaScript game - the actual code is only about 25k lines but in addition it has about 130k lines of story scripts also evaluating expressions/handling conditions the same way. So far I just tried to modify all the script expressions into Lua code and called that code on demand, but I just noticed there are a lots of conditions just using the shortcut version, i.e. a kind of
if myStoryVariable then
instead of
if myStoryVariable == 0 then
or
if myStoryVariable ~= 0 then
So, right now, my code is valid but just wrong, as in Lua 0 and 1 (or any other number) is true.
Anyone with an idea how to solve this in a nice way?
I actually do have code from the scripting system of the original game to evaluate the expressions but it’s ugly code and lot’s of other stuff mixed in, like management of variables or calling all kinds of external functions for special variable name etc. and I’ve successfully transformed all this into plain Lua code already. So I could just port all that expressions handling code but I’d so much prefer to use Lua for this.
Of course I could simply read through those 130k lines of story script and fix it where required - but I know after just a few thousand lines it’s starting to become a decent source for additional bugs