LUA Error (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


Tecmeister -> LUA Error (1/1/2019 1:41:09 PM)

Help!!

I've been working on fixing this error for a few months with no luck. I have a technical background but no programming experience. Lua looks like it can be simple, and built up to complex tasks, but I'm missing something and can't figure out what.

This scenario is predicated on the US getting tired of China's actions in the South China Sea. The Navy is sent in along with ground based air assets, and after destroying everything that tries to stop them, invading and capturing Woody Island.

Once the Amphib task group (I've removed all other assets on both side for simplicity) is stationed in the box south of Woody, (Ref Pts 2720-2723) undock the 4 LCAC's and move them into the tiny patrol area next to Woody, Ref Pts 2724-2727. The LCAC's need to be in the patrol area for 30 minutes to fire the Capture Woody script.

All the info I've found for SetUnitSide seems right, but it's not, I always get an error "Lua script execution error: [string "Capture Woody"]:1: ')' expected near 'Island'".

The attached save is after the Amphibs reach their patrol area, so all that's left to do is move the LCAC's.

Can someone show me what I'm missing? I'd like to test and them upload the whole scenario for other players to try.

Thanks,

Tecmeister




stilesw -> RE: LUA Error (1/1/2019 2:26:22 PM)

Tecmeister,

May have found your Lua problem. You used:
ScenEdit_SetUnitSide (China, Woody Island, United States)

Coincidentally, I was doing a similar thing with Woody Island some time back and found this code works:

ScenEdit_SetUnitSide({side="PRC", name="Woody Island Air Strip", newside="USN"})

So, it appears to have been a problem with identifiers (side, name, newside) and quotes.

Hope this helps,

-Wayne




Tecmeister -> RE: LUA Error (1/1/2019 4:33:26 PM)

Wayne,

Thanks for the quick reply. Tried your update above, but no joy. Any other ideas are welcome, and Thanks Again!

Bruce




Whicker -> RE: LUA Error (1/1/2019 5:30:58 PM)

you just have multiple formatting errors, this works in your save in the lua console:

ScenEdit_SetUnitSide({side='China', name='Woody Island', newside='United States'})

- you have a space after ScenEdit_SetUnitSide
- you are missing the curly brackets {}
- you are not giving the parameter/identifier or whatever you call it - name=, side=, newside=
- you didn't enclose your strings in quotes - the name and sides in this context are strings, and strings are always enclosed in quotes - single or double, either works as long as they are paired.




Whicker -> RE: LUA Error (1/1/2019 5:33:01 PM)

it may take a second or two of game time to update properly.




Tecmeister -> RE: LUA Error (1/5/2019 3:22:00 PM)

Whicker,

That's excellent, worked the first attempt. I must have tried 30 different attempts to make that work. Most of the LUA docs I found (including the Command LUA Documentation web page)didn't include the curly brackets in their examples, so I assumed (yeah, I know...) that they were for illustrative purposes. A thousand Thank-You's!!

Bruce[&o]




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.859375