Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Edit Trigger by Lua

 
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 >> Edit Trigger by Lua Page: [1]
Login
Message << Older Topic   Newer Topic >>
Edit Trigger by Lua - 11/4/2017 2:47:16 PM   
M1A2G

 

Posts: 29
Joined: 9/13/2017
Status: offline
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',targetfilter={SPECIFICUNIT='Vehicles (Truck x 4)'},area={'rp-261','rp-262','rp-263','rp-264'},td='9 hours'})

I write this to change Trigger's time,but it showes "ScenEdit_SetTrigger 1 : ,Error in Trigger.RemainsIn TDA".
What's wrong with this ?

Attachment (1)

< Message edited by M1A2G -- 11/5/2017 1:50:55 AM >
Post #: 1
RE: Edit Trigger by Lua - 11/4/2017 3:32:28 PM   
michaelm75au


Posts: 13421
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Format for TDA is days:hours:minutes:seconds from WIKI

So should read as "td=0:9:0:0"

_____________________________

Michael

(in reply to M1A2G)
Post #: 2
RE: Edit Trigger by Lua - 11/5/2017 1:50:40 AM   
M1A2G

 

Posts: 29
Joined: 9/13/2017
Status: offline
Thanks,and wiki page is "Command Lua Documentation" ?

(in reply to michaelm75au)
Post #: 3
RE: Edit Trigger by Lua - 11/5/2017 1:55:53 AM   
michaelm75au


Posts: 13421
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
yes

_____________________________

Michael

(in reply to M1A2G)
Post #: 4
RE: Edit Trigger by Lua - 11/5/2017 6:52:53 AM   
M1A2G

 

Posts: 29
Joined: 9/13/2017
Status: offline
if ScenEdit_GetUnit({side="T", name="Vehicles (Truck x 5)"}) ~= nil then
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',td='0:0:10:0'})
else ScenEdit_GetUnit({side="T", name="Vehicles (Truck x 5)"}) == nil then
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',td='0:0:15:0'})
End

This showed "ERROR: [string "Console"]:3: unexpected symbol near '=='"

How to edit it ?

I want to let action judge that unit has been destoryed then change the Trigger

(in reply to michaelm75au)
Post #: 5
RE: Edit Trigger by Lua - 11/5/2017 8:41:06 AM   
michaelm75au


Posts: 13421
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
My guess is the missing 'IF' after the ELSE on the 3rd line???

_____________________________

Michael

(in reply to M1A2G)
Post #: 6
RE: Edit Trigger by Lua - 11/5/2017 8:54:28 AM   
M1A2G

 

Posts: 29
Joined: 9/13/2017
Status: offline
if ScenEdit_GetUnit({side="T", name="Vehicles (Truck x 5)"}) ~= nil then
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',td='0:0:10:0'})
else if ScenEdit_GetUnit({side="T", name="Vehicles (Truck x 5)"}) == nil then
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',td='0:0:15:0'})
end

This showed "ERROR: [string "Console"]:5: 'end' expected (to close 'if' at line 1) near <eof>" ......

(in reply to michaelm75au)
Post #: 7
RE: Edit Trigger by Lua - 11/6/2017 7:51:08 AM   
michaelm75au


Posts: 13421
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Shouldn't it be ELSEIF

_____________________________

Michael

(in reply to M1A2G)
Post #: 8
RE: Edit Trigger by Lua - 11/6/2017 8:03:08 AM   
M1A2G

 

Posts: 29
Joined: 9/13/2017
Status: offline
if ScenEdit_GetUnit({side="T", name="Vehicles (Truck x 5)"}) ~= nil then
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',td='0:0:10:0'})
elseif ScenEdit_GetUnit({side="T", name="Vehicles (Truck x 5)"}) == nil then
ScenEdit_SetTrigger({mode='update',type='UnitRemainsInArea',name='Truck Remains Area',td='0:0:15:0'})
end

This showed"ScenEdit_GetUnit 1 : ,Can't find Unit 'Vehicles (Truck x 5)' on Side 'T'"

But I want to let it judge that the unit is existing or not and then change the trigger...

(in reply to michaelm75au)
Post #: 9
RE: Edit Trigger by Lua - 11/6/2017 9:03:39 AM   
michaelm75au


Posts: 13421
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
This is from the Lua Documentation:
Note: Due to how errors are now handle from SR7, if a command fails in the console window, it will show an error. If the command runs outside the console (as in an event script), it will not fail with a visible error but return a nil or or some other value. One issue with commands running in an event is that sometimes they fail with an in-game message that actually stops the rest of the script from running. Now, these event scripts will run without any in-game message showing, and the designer should check the result of the command and handle any error condition, and let the remaining script run as needed.

My intent is have all command errors behave in the same fashion in the console window; and the command errors outside a console behave without stopping the script. Which requires the designer to cater for the specific error conditions.

To emulate the expected outcome from an event, put 'Tool_EmulateNoConsole(true)' at the start of the script to be tested; it is not required in the event code as the script is already not running in a console.

Note also, that the Lua history log should also record the event script errors.


Run the command 'Tool_EmulateNoConsole(true)' at the start of the script in the console so that the GetUnit() will return nil, and the script should work.
If the script is part of an event action, then the 'Tool' command is not needed. It just emulates what would happen in a non-console script.

_____________________________

Michael

(in reply to M1A2G)
Post #: 10
RE: Edit Trigger by Lua - 11/6/2017 11:08:07 AM   
M1A2G

 

Posts: 29
Joined: 9/13/2017
Status: offline
Yeah this worked,thanks.

I try to create an event and as you say the 'tool'command is not needed.

(in reply to michaelm75au)
Post #: 11
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Edit Trigger by Lua 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

0.371