[Logged] SideWrapper unitsBy intereting case of exception. (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


KnightHawk75 -> [Logged] SideWrapper unitsBy intereting case of exception. (6/13/2021 3:42:19 PM)

So I came across this interesting thing.

1. Restart CMO.
2. Load the attached scene in the editor.
3. Press the special action with "FreshStart" in the name.
4. Note the invalid parameters to method exception. for feeding nil as a category in the filter.
5. Press the second special action with "NonNil" in the name.
6. Note it runs.
7. Press the special action with "FreshStart" in the name.
8. Note it now runs fine with no exception.

[optional]
9. reload map and repeat for same results still works.
10. exit to main menu and reenter editor and repeat (same result still works.)
11. Restart CMO a second time.
12. repeat the step BUT this time run "NonNil" first, and then "FreshStart". - NO exceptions.

[optional]
If you run same test excluding the additional params (so defaults get used) in an attempt to test 'initializing' it. ie s:unitsBy("Facility"); that will not clear the way for #3 above to run.

Weird huh. [&:] It's more curious to me why nil works after than why nil fails initially.
Even more weird cause I can see the function has a default in it's definition of 0 so I'm not sure what exactly is going on other than something buried deep in translation layer before it even gets there.

exception:
quote:


-- B1147.25 -- Invalid arguments to method: LuaWrapper_Side.unitsBy
Exception: Invalid arguments to method: LuaWrapper_Side.unitsBy
Stack Trace: at NLua.Lua.ThrowExceptionFromError(Int32 oldTop)
at NLua.Lua.DoString(String chunk, String chunkName)
at Command_Core.Lua.LuaSandBox.RunScript(String str, Boolean RunInteractively, String script)
at Command_Core.SpecialAction.(Scenario )
Call Stack & Error details:
Error at 101325,

...and no I'm not trying to find these things, just come across them, this one was from a "why is something that worked for a an entire day flawlessly suddenly not working on restart" incident. :)




michaelm75au -> RE: SideWrapper unitsBy intereting case of exception. (6/14/2021 1:39:24 AM)

The parameters of 'unitsBy' are defined as integers, the default being 0 if none supplied.
This is Nlua complaining about a 'nil' when it should be a 'integer' - doesn't even get into the function.

Can't see why Nlua suddenly 'likes nil' - I can see it has changed it to 0 when it passes it to the 'unitsBy' function in step #7.




michaelm75au -> RE: SideWrapper unitsBy intereting case of exception. (6/14/2021 1:45:19 AM)

I can fix the inconsistency by making those 2 parameters 'interger?' which means that a nil will be accepted but the parameters are supposed to be integers.
Tested okay when I tried it - the 'nil' was passed to the function so issue seems to be in how Nlua package is handling it.




WSBot -> RE: SideWrapper unitsBy intereting case of exception. (6/14/2021 2:48:50 PM)

0014604




KnightHawk75 -> RE: SideWrapper unitsBy intereting case of exception. (6/15/2021 2:16:58 AM)


quote:

ORIGINAL: michaelm75au

I can fix the inconsistency by making those 2 parameters 'interger?' which means that a nil will be accepted but the parameters are supposed to be integers.
Tested okay when I tried it - the 'nil' was passed to the function so issue seems to be in how Nlua package is handling it.

Interesting, that NLua after a successful first use of the second param would "learned and cache" that it's allowed nils but I guess it does some how, or maybe it works due to luck\nature of how things are done in NLua. Anyway.. cool that you could find solution that works around it, while also still allowing nil (as that will save some coding on the script side). [&o]





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
3.515625E-02