Page 1 of 1

[ANSWERED] Technique to test scripts using Unit Damaged/Unit Destroyed trigger.

Posted: Fri Dec 01, 2017 2:12 am
by tjhkkr
Hello,

I am trying to work through a lua script that is triggered by the Unit Damaged/Unit Destroyed triggers. Has anyone found a good way to test this?
I am trying to set up the script that if two bridges are blown up, it shuts down the mission; I have the code, I simply need to test it. I do not know how I can do that from the LUA screen code tester.

Anyone in the community have any ideas?

RE: Technique to test scripts using Unit Damaged/Unit Destroyed trigger.

Posted: Fri Dec 01, 2017 4:19 am
by michaelm75au
While game is running, open the Lua console, and run something like:
ScenEdit_SetUnitDamage({side='SideA', unitname='Ship1', dp=xxx}) where xxx is the damage points
The event should trigger.

RE: Technique to test scripts using Unit Damaged/Unit Destroyed trigger.

Posted: Fri Dec 01, 2017 4:54 pm
by tjhkkr
ORIGINAL: michaelm75au
While game is running, open the Lua console, and run something like:
ScenEdit_SetUnitDamage({side='SideA', unitname='Ship1', dp=xxx}) where xxx is the damage points
The event should trigger.
EXCELLENT... and DUH (the DUH is aimed at me).
Thank you!

RE: Technique to test scripts using Unit Damaged/Unit Destroyed trigger.

Posted: Fri Apr 13, 2018 11:13 pm
by Betty_YueTu
Hi,tjhkkr

You can use the 'Message' action to test your code like this:

Code: Select all

ScenEdit_SetEvent('destroy_event',{mode = 'add'})
 ScenEdit_SetAction({mode = 'add', type = 'Message', name = 'destroy_action', SideId = 'LuaSideA', Text = 'Destroied'})
 ScenEdit_SetTrigger({mode = 'add', name = 'destroy_trigger', type = 'UnitDestroyed', targetfilter = {TargetSide = 'LuaSideB',TargetType = '2'}})
 
 ScenEdit_SetEventAction('destroy_event', {mode = 'add', name = 'destroy_action'})
 ScenEdit_SetEventTrigger('destroy_event', {mode = 'add', name = 'destroy_trigger'}) 

hope it can help you.