LUA Error

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Tecmeister
Posts: 27
Joined: Sun Dec 10, 2006 11:14 pm

LUA Error

Post by Tecmeister »

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
Attachments
Woody.zip
(157.82 KiB) Downloaded 22 times
A decade of Blue Water service
User avatar
stilesw
Posts: 1572
Joined: Wed Jun 25, 2014 10:08 pm
Location: Hansville, WA, USA

RE: LUA Error

Post by stilesw »

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
“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)
Tecmeister
Posts: 27
Joined: Sun Dec 10, 2006 11:14 pm

RE: LUA Error

Post by Tecmeister »

Wayne,

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

Bruce
A decade of Blue Water service
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: LUA Error

Post by Whicker »

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
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: LUA Error

Post by Whicker »

it may take a second or two of game time to update properly.
Tecmeister
Posts: 27
Joined: Sun Dec 10, 2006 11:14 pm

RE: LUA Error

Post by Tecmeister »

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]
A decade of Blue Water service
Post Reply

Return to “Lua Legion”