Random posture change

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
ParachuteProne
Posts: 232
Joined: Mon Aug 02, 2004 1:35 pm

Random posture change

Post by ParachuteProne »

Hi: I'm very new to Lua.

Is there a script that would check at say the top of every hour giving say a 10% chance that a side or sides change their posture towards another side or sides ?

I see a Lua "scenedit set side posture , however how do I do it randomly ?

I have 4 sides, I would like one to change it's posture towards another if a certain number range is randomly generated.
ie: 0-10% chance.

Thanks for any help !
Mark352
Posts: 75
Joined: Thu Jul 25, 2024 2:35 pm

Re: Random posture change

Post by Mark352 »

You can do this with a repeatable Event set to run at 10% probability that uses a Regular Time Trigger set at 1-hour and an Action Lua Script that changes postures and disables the Event. I suspect you want the event to cease repeating once postures are changed.

1. Create the Regular Time Trigger set to 1-hour.
2. Create the Action Lua Script using this example code;

Code: Select all

ScenEdit_SetSidePosture("Blue","Red","H") --Posture of Blue Side towards Red Side hostile

ScenEdit_SetEvent('POSTURE_CHANGE', {IsRepeatable = false}) --Turns off the repeatable POSTURE_CHANGE event
3. Create the repeatable Event using the Trigger and Action you created. Set the probability to 10 percent.

In this example Blue becomes hostile to Red. The Event name in this example is POSTURE_CHANGE. Try it on a small ship on ship scenario to make sure it does what you need. Hope this helps. Good luck.
ParachuteProne
Posts: 232
Joined: Mon Aug 02, 2004 1:35 pm

Re: Random posture change

Post by ParachuteProne »

Will give it a shot.
Thanks for the help
Post Reply

Return to “Lua Legion”