Create a Special Action using Lua...

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

Create a Special Action using Lua...

Post by jkgarner »

I would like to create a special action in a Lua Script.
Before the script runs, the special action does not exist.
After executing the script, the Special action exist.

Of course, it would need to detect whether the action has been created previously, and skip if called multiple times.

The inverse function to remove the special action would also be helpful. but is not entirely needed.

The only function I see in the documentation is ScenEdit_SetSpecialAction, which states that it is for modifying the attributes of an EXISTING special action.

Any thoughts on how I can do this?
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Create a Special Action using Lua...

Post by KnightHawk75 »

You can not programmatically generate SA's at present, all you can do is stage them and hide them. Nor can you update\replace the ScriptText via lua. :-( As for checking existence there is trapping the errors thrown on a ScenEdit_GetSpecialAction call or ScenEdit_SetSpecialAction attempts.

Unrelated - With pro edition you might be able to import\export the whole event stack (a feature I really don't understand why isn't in basic version) saving time, during scene construction, but even that I think is just in the gui (and I only saw that via a video a long time ago).


jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

RE: Create a Special Action using Lua...

Post by jkgarner »

I can programmatically create events and triggers, and actions.
With actions I can programmatically change them, even the script text using

Code: Select all

ScenEdit_SetAction({
     mode="update", 
     type="LuaScript", 
     name='LeMayLuaInit',
     scriptText = "ScenEdit_UseAttachment('Lua script: LeMayLuaLibrary_0.1.0.0.lua')"
 })
But I must know the name of the action, because there is no way to examine the list of events.
ScenEdit_GetEvents does not work in my version:
(ERROR: [string "Console"]:54: attempt to call global 'ScenEdit_GetEvents' (a nil value)


I would think that Special Actions would be similar, but apparently they are not.

One difference that I have noticed is that events are not side specific, while Special Actions are side specific. You can not create a Special Action until AFTER you have created a side to tie the special action to.



KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Create a Special Action using Lua...

Post by KnightHawk75 »

Yes as I think we established some time back lastest pro like with vp_getsides doesn't have getevents yet, if I recall they were in the same update or one right after the other.
I would think that Special Actions would be similar, but apparently they are not.
Agreed. I want it too. If i had to guess...that's probably been more a priorities (maybe not enough requests\demand) thing less than some design actual decision.
One difference that I have noticed is that events are not side specific, while Special Actions are side specific. You can not create a Special Action until AFTER you have created a side to tie the special action to.

Yup I ran into that not long ago too, not only that don't name them the same on both sides, try flipping to side red create action with name abc, flip to side blue, create one with name abc, flip back to red... gone at least from gui. :) Found that one out the hard way after doing 16 actions couple months back. Wonder if it's still a thing. ;)

Come to think of it GetEvents probably need a level 5 setting for special actions listing too.

User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Create a Special Action using Lua...

Post by michaelm75au »

I have added SpecialActions to my list to review.
Michael
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

RE: Create a Special Action using Lua...

Post by jkgarner »

Thank you.
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Create a Special Action using Lua...

Post by michaelm75au »

These are the planned changes:
1. New function AddSpecialAction({table_select}) - side is mandatory
2. New parameters to table_select
[optional] 'side=' to limit functions to a side
[optional] 'mode=' use 'remove' on SetSpecialAction() to delete SA
use 'list' on GetSpecialAction() to list SAs on the side if supplied, or all sides if not
3. Wrapper/table parameters
side = side GUID
ScriptText = Lua script (note: The script as a multi-line string, requires a '\r\n' to be appended after each line so it is formatted in the Editor. It can run without the CRLF as Lua executes on CRLF or LF line breaks.
Michael
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

RE: Create a Special Action using Lua...

Post by jkgarner »

This is excellent.
Thank you.
[:)]
Post Reply

Return to “Lua Legion”