Page 1 of 1

Create a Special Action using Lua...

Posted: Tue Jun 30, 2020 6:56 pm
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?

RE: Create a Special Action using Lua...

Posted: Wed Jul 01, 2020 12:43 am
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).



RE: Create a Special Action using Lua...

Posted: Wed Jul 01, 2020 9:33 am
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.




RE: Create a Special Action using Lua...

Posted: Wed Jul 01, 2020 2:18 pm
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.


RE: Create a Special Action using Lua...

Posted: Fri Jul 03, 2020 12:12 am
by michaelm75au
I have added SpecialActions to my list to review.

RE: Create a Special Action using Lua...

Posted: Sat Jul 04, 2020 5:50 am
by jkgarner
Thank you.

RE: Create a Special Action using Lua...

Posted: Sat Jul 04, 2020 7:45 am
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.

RE: Create a Special Action using Lua...

Posted: Sat Jul 04, 2020 1:17 pm
by jkgarner
This is excellent.
Thank you.
[:)]