ScenEdit_GetEvents(string,int) documented but not registered?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

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

ScenEdit_GetEvents(string,int) documented but not registered?

Post by KnightHawk75 »

So I went to use ScenEdit_GetEvents() and it's not a recognized function anymore.
It's documented and it would appear at a glance the underlying code is there in command.exe but it's not registered in the LUA sandbox. Is this an oversight in the registration list in LuaSandbox.RefreshStat() or has it been withdrawn?


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

RE: ScenEdit_GetEvents(string,int) documented but not registered?

Post by michaelm75au »

Looks like it never has been registered. To dump out events for checking, there is 'Tool_DumpEvents'.
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: ScenEdit_GetEvents(string,int) documented but not registered?

Post by KnightHawk75 »

Not sure how the blobs of xml the Tool_Dumpevents() function outputs help me enumerate though a list of all existing events though, short of writing my own parser for it? Was hoping to use GetEvents() as documented on Commandlua.github.io.
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: ScenEdit_GetEvents(string,int) documented but not registered?

Post by michaelm75au »

So you want to scan thru all events during a scenario?
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: ScenEdit_GetEvents(string,int) documented but not registered?

Post by KnightHawk75 »

Exactly.

Basically I hoping to get back a table of just events containing maybe id\guid and name\description (just enough to call getevent() for more investigation). It would enable me to scan through the full list. Otherwise I'm forced to know the the 'name' of all events ahead of time and getevent() them and check for nil (in addition to EnmunlatingNoConsole enabling\disabling throughout if not inside an event) in order to see if they exist yet.


Also related - Ideally I wish I could do the same for triggers and actions too. Yesterday came across situation where I wanted to check if a particular action existed already for code that created them dynamically (Gunners recent question). Even when knowing the name of the trigger I couldn't find a way to essentially check for nil as there is no GetTrigger() like there is for events. Using SetTrigger() mode=list didn't much help because if you feed it an invalid Trigger name it sends back a full table dump (in xml) instead of nil\error like GetEvent() does. idk if a GetTrigger or GetAction is really needed though if GetEvents did something like the following.

I was thinking\expecting GetEvents(level) to return something like this:
GetEvents(0) would return a table of side=,id=,guid=,name=,type= where type was not filtered
GetEvents(1) would return a table of side=,id=,guid=,name=,type= where type was Events only
GetEvents(2) would return a table of side=,id=,guid=,name=,type= where type was Triggers only
GetEvents(3) would return a table of side=,id=,guid=,name=,type= where type was Conditions only
GetEvents(4) would return a table of side=,id=,guid=,name=,type= where type was Action only
Nil on no entries for given level.

Code: Select all

local allEvents = ScenEdit_GetEvents(0);
 print(allEvents);
 [1]{id='agah-fasdfasdfasd',name='some event #1',type='Event',side='red'}
 [2]{id='agah-dfasd23ssdfs',name='some trigger name',type='Trigger',side='red'}
 [3]{id='aghsf-dfasd22sdfs',name='some condition name',type='Condition',side='red'}
 [4]{id='aghsf-dfasdsasfvs',name='some action name',type='Action',side='red'}
 [5]{id='aghsf-dfasdsahhvs',name='some action name',type='Action',side='blue'}
 
 local allEvents = ScenEdit_GetEvents(2);
 print(allEvents);
 [1]{id='agah-dfasdfassdfs',name='some trigger name,type='Trigger',side='red'}
 

Then not only does it solve the 'get a full list of all events' problem but also solves the ability to check if a particular action or trigger exists already via GetEvents(x) and scanning the table if not already coming back nil. Originally I thought this more or less existed already since I saw docs and the method in the code, but if it was never actually implemented I get this is additional work and some low priority work at that most likely. Just providing some feedback\suggestions as I encounter challenges.

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

RE: ScenEdit_GetEvents(string,int) documented but not registered?

Post by michaelm75au »

I don't know what happened to GetEvents(). It wasn't registered as far back as when I added all the Lua event functions.
I think I may have copied the GetEvent() code and then changed GetEvents() to drop the need for an event id. But didn't finish it.
I have updated the registering of the new function so it should be in a future build.
Michael
Post Reply

Return to “Lua Legion”