LUA Script Help

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

LUA Script Help

Post by butch4343 »

Guys,

I am here again begging help with LUA scripts. I have a couple of errors and I cant see where.

The first is that I have three routes A/B/C and what I want is a group to randomly be assigned to each route, so the player doesnt know where the enenmy will come from.

I stole a script of Baloogan and amended it as I thought fit, the only issue is I want to assign a group and not a unit as he has.

math.randomseed( os.time() )

a = math.random(1,10)

if a<5 then

ScenEdit_AssignUnitToMission(‘Attack Group 1’, ‘Route A’)

elseif a>=5 and a<8 then

ScenEdit_AssignUnitToMission(‘Attack Group 1’, ‘Route B’)

elseif a>=8 then

ScenEdit_AssignUnitToMission(‘Attack Group 1’, ‘Route C’)

end


But I get an error of

LUA script execution error : (String Random Assign Group To Mission) 7 Unexpected Character symbol near char 145)

My second problem is that I want to re-assign the units an ASW patrol once they reach the straights of dover. I thought using something like:

unit = ScenEdit_UnitX()
ScenEdit_AssignUnitToMission({unitname=unit.name}, 'Attack Patrol')


As this would save me the hassle of having to do lines of script, it would just be whatever units made it that far south. My issue is I get:

03:02:32 - 03:02:32 - Lua script execution error: [string "Soviet Vessels Enter Patrol Box"]:2: invalid arguments to method call


Anyone see where my scripting is gone wrong?

Regards a Grateful Numpty at LUA
Attachments
18OsasAn..Channel.zip
(43.97 KiB) Downloaded 11 times
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA Script Help

Post by michaelm75au »

Check the quote marks; they should be like below.
ScenEdit_AssignUnitToMission('Attack Group 1', 'Route A')
Michael
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA Script Help

Post by michaelm75au »

unit = ScenEdit_UnitX()
ScenEdit_AssignUnitToMission(unit.name, 'Attack Patrol')
Michael
butch4343
Posts: 327
Joined: Thu Mar 26, 2015 2:09 pm

RE: LUA Script Help

Post by butch4343 »

Michael,

I am again in your debt buddy, thanks for the fault finding in my scripts.

I now have multiple groups of OSAs randomly racing the channel to sink NATO reinforcement convoys.

Thanks again

Butch
Post Reply

Return to “Lua Legion”