Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Checking for an Event...

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Checking for an Event... Page: [1]
Login
Message << Older Topic   Newer Topic >>
Checking for an Event... - 6/12/2020 12:27:51 PM   
jkgarner

 

Posts: 174
Joined: 4/30/2020
Status: offline
I need to silently check for the existence of an event by name.

If I call ScenEdit.GetEvent(), and the event exists, the code works fine, no error, the event is found.

If I call ScenEdit.GetEvent(), and it does not exist, Command throws up an error message to the user (not silent) AND the script stops executing.

If I wrap the ScenEdit.GetEvent() with pcall or xpcall to trap the error, the same thing happens. (not silent) AND the script stops executing.

So I tried ScenEdit_GetEvents() to iterate through the list manually...
but this returns an error: attempt to call global 'ScenEdit_GetEvents' (a nil value)

Perhaps I am missing something, but I still need to test for the existence of my event.

Any thoughts?

Post #: 1
RE: Checking for an Event... - 6/12/2020 5:03:26 PM   
KnightHawk75

 

Posts: 1347
Joined: 11/15/2018
Status: offline
I think the GetEvents() issue there is you're on Pro and it was a recent addition\re-addition.

Odd I don't see that same behavior in commerical release. ie
local a = ScenEdit_GetEvent('SomeEventDoesNotExist');
Doesn't generate a error - not when it 'actually' runs inside an event.
It does of course in the lua console though, which can throw one off.
If you see that when you run it in the lua console or via special action try wrapping it in a
Tool_EmulateNoConsole(true)
..your code here..
Tool_EmulateNoConsole(false)
Which will try to force suppressing the error and the result of the above in the console should be no error and a==nil.


(in reply to jkgarner)
Post #: 2
RE: Checking for an Event... - 6/12/2020 5:47:26 PM   
jkgarner

 

Posts: 174
Joined: 4/30/2020
Status: offline
Does Tool_EmulateNoConsole have an effect when I am running in an event (not the console)?

Specifically, is it safe to throw in the script and leave there when there is a chance the script will be run in an event?

(in reply to KnightHawk75)
Post #: 3
RE: Checking for an Event... - 6/12/2020 7:47:34 PM   
KnightHawk75

 

Posts: 1347
Joined: 11/15/2018
Status: offline
I think that flag gets set on it's own when running in an event (or isn't checked cause it already knows itself it's inherently running in an event), but I could be wrong, so setting it shouldn't have an effect either way if it's really running in an event. That's definitely a Michael question. It shouldn't hurt if it's included though, it's lost after a chunk is done in my experience, ie it's not a global flag it's just for that execution. If running outside an event when the chuck is done running it will revert back to false, I know it does for console and SA.

(in reply to jkgarner)
Post #: 4
RE: Checking for an Event... - 6/13/2020 1:50:59 AM   
michaelm75au


Posts: 13419
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Tool_EmulateNoConsole() makes the script run as if it was in the "background" (like a normal event in game).
If you include it in an event script but have it 'false', it may cause the event to stop on an error. However, leaving it in with it set to 'true' should have no impact.

_____________________________

Michael

(in reply to KnightHawk75)
Post #: 5
RE: Checking for an Event... - 6/13/2020 1:54:55 AM   
michaelm75au


Posts: 13419
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline

quote:

ORIGINAL: jkgarner

I need to silently check for the existence of an event by name.

If I call ScenEdit.GetEvent(), and the event exists, the code works fine, no error, the event is found.

If I call ScenEdit.GetEvent(), and it does not exist, Command throws up an error message to the user (not silent) AND the script stops executing.

If I wrap the ScenEdit.GetEvent() with pcall or xpcall to trap the error, the same thing happens. (not silent) AND the script stops executing.

So I tried ScenEdit_GetEvents() to iterate through the list manually...
but this returns an error: attempt to call global 'ScenEdit_GetEvents' (a nil value)

Perhaps I am missing something, but I still need to test for the existence of my event.

Any thoughts?



Is this in a console or an event?
If a console, it will give an error.
If in an event, it should return nothing/nil.


_____________________________

Michael

(in reply to jkgarner)
Post #: 6
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Checking for an Event... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.195