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

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
tjhkkr
Posts: 2431
Joined: Wed Jun 02, 2010 11:15 pm
Contact:

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

Post 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?
Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

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

Post 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.
Michael
User avatar
tjhkkr
Posts: 2431
Joined: Wed Jun 02, 2010 11:15 pm
Contact:

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

Post 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!
Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.
Betty_YueTu
Posts: 4
Joined: Fri Apr 13, 2018 12:54 am

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

Post 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.
Post Reply

Return to “Lua Legion”