Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

LUA Script Help

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA Script Help Page: [1]
Login
Message << Older Topic   Newer Topic >>
LUA Script Help - 11/21/2017 7:23:02 AM   
butch4343

 

Posts: 327
Joined: 3/26/2015
Status: offline
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

Attachment (1)
Post #: 1
RE: LUA Script Help - 11/21/2017 11:03:28 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Check the quote marks; they should be like below.
ScenEdit_AssignUnitToMission('Attack Group 1', 'Route A')

_____________________________

Michael

(in reply to butch4343)
Post #: 2
RE: LUA Script Help - 11/21/2017 11:06:18 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
unit = ScenEdit_UnitX()
ScenEdit_AssignUnitToMission(unit.name, 'Attack Patrol')

_____________________________

Michael

(in reply to michaelm75au)
Post #: 3
RE: LUA Script Help - 11/24/2017 1:54:39 PM   
butch4343

 

Posts: 327
Joined: 3/26/2015
Status: offline
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

(in reply to michaelm75au)
Post #: 4
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA Script Help Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.234