LUA Script Help (Full Version)

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



Message


butch4343 -> LUA Script Help (11/21/2017 7:23:02 AM)

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




michaelm75au -> RE: LUA Script Help (11/21/2017 11:03:28 AM)

Check the quote marks; they should be like below.
ScenEdit_AssignUnitToMission('Attack Group 1', 'Route A')




michaelm75au -> RE: LUA Script Help (11/21/2017 11:06:18 AM)

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




butch4343 -> RE: LUA Script Help (11/24/2017 1:54:39 PM)

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




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.953125