Event Manager 3 (project cancelled)

A place to discuss mods in development and concepts for new mods.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I am rebuilding the Event Manager / Global timer for 099c.

What kinds of event handling will be helpful?

Alert Message (implemented)- Simply sends a message after given ticks have passed.

format: (tmrSetMessageAlert [delay] [message])

Set gPlayership data (implemented)- Specific data on gPlayership altered to stored value after given ticks have passed.

format: (tmrSetPlayerData [delay] [dataName] [data])

Set System data (implemented)- Specific data in a given system nodeID altered to stored value after given ticks are passed.

format (tmrSetSystemData [delay] [sysID] [systemDataName] [data])


What kinds of release packages will be desired?

1) Stand alone, using stargates (simplest override)?
2) Integrated with Navigation Computer (to be expected first I suppose)
3) ATA system override (using own station rather than stargate)?
4) <OnGlobalSystemCreated> method or <OnCreate> method code on own?

Anything besides 2 by request.
Last edited by Periculi on Fri Sep 05, 2008 9:08 pm, edited 1 time in total.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

1 sounds the best I would like that
what is the interface to just run an event every 4 seconds (or whatever it will be)

when is the earliest it can be done (like does it need gplayership or gplayer)

will there be a place where we can just put our calls so that we do not have to worry about it running more than once?


offtopic: can more than one OnGlobalSystemCreated or the network one be in a mod? if so that might be better.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

I think that you can use more than 1 <OnGlobalSystemCreated> in the game. If not, Huaramarca might be having troubles in ATA! For that method the timer needs object events to use. In the <OnGlobalSystem version I figured I would need to create a 1 pixel station that handled the timer and events. I haven't built this version yet- the timer I am working on now is integrated with the stargate override I wrote for the navigation computer.

The problem with the stargate override is I also use it for other things- so a stand-alone version wouldn't work with the Navigation mod, for instance.

That is why I am planning to have several versions- so that you can get the mod somewhere that it won't cause other mods to break.

The timer itself is available once either A) the first stargate is created, or B) the timer event station is created. This usually happens before gPlayership is added to a system.

The timer can set data when the object is available. In the case of gPlayership there can be moments when it is not accessible. Setting data on the timer object (global data on a blank station like stDomina) or on the system is allowed any time. I am thinking of adding a success check to get the outcome of the event to check for gPlayership. I haven't done anything with gPlayer, but if you think you need I can add that easily enough.

Your real time event calls get added to an activeEventList, by class- AlertMessage performs a message- but sometimes messages can get lost if many happen at once or gPlayership can't be messaged.

There are also passive calls that can be used in stations or dockscreens that perform an event if the time has elapsed- but not actively when the player is flying around the universe. Passive calls can be more complex because they don't run in the background or get added to the activeEventList.

For instance- (tmrGetCurrentDate) for the calendar in the ship screens I have for testing is set up to only update when viewed in the dockscreen- so all the code to update the calendar is only called when the display is desired.


For custom functions and events I am planning to have several ways to just call a function or event directly without changing the EM3 code too much- one way I thought of this was to use <Events> and objFireEvent - then you just need to name the event in your trigger event. Functions are a little tricky, as I have never had much luck getting something like (cat "my" "Function" i) to return myFunction1 and turn it into (myFunction1 [data]) any help on dynamic function name building and calling would be great. (can you store a function name on a list to get back and perform later?)
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

isn't that how eval is supposed to work? just make things into lists and eval that list.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Not sure how that would help getting dynamic named functions onto the list.

I am trying to get it so that you don't have to add any code to EM3 to target a custom event or function you made.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

you can pass a string with the name of your function and store it

in your code you would call it with eval

(will start fun with eval later today)

an example

(setq myVar "subtract")

(eval (list myVar 10 4))

that eval will return 6
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

So would (eval (list myFunction)) return whatever myFunction returns?

Then I could just store (list [funcName]) to trigger a function when (eval is performed?
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

you don't store the list but yes you could just store the function names and just call them later with eval and list

edit: hmm I don't know if that would work will test the (eval "(myFunction)")
Last edited by Betelgeuse on Wed Aug 27, 2008 8:55 pm, edited 1 time in total.
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Well that should simplify matters.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

nope you can't do (eval "(myFunc)")
but you can do (eval (list "myFunc"))

the string case of eval expects it to name a variable (it is a way of getting dynamically named variables data)
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

tmrSetCustomFunction added to perform custom function calls.
format: (tmrSetCustomFunction [delay] [funcName])

Now I think I need to work out a way to pass in data for a function.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

tmrSetDataFunction is working- now the event manager can call a function with passed in data of any sizes.

format (tmrSetDataFunction [delay] [funcName placeholder] (list [funcName] [data...]))

I use the same eval block to perform both types of functions. If the function event doesn't have a trailing list using (tmrSetCustomFunction) the event manager simply calls the function and performs it. If the function needs (lambda (values) then use (tmrSetDataFunction) and put the passed in values on the trailing list.. easy!

Because these two functions provide so much flexibility I am not adding anymore custom event handlers for functions- if you want to set data, get data, increment or decrement, juggle, or otherwise process data, write a function to do it and call it from the event manager for a time delay effect.

I will be adding (objFireEvent) methods, although this can be handled just as easily from the above function handlers. I am adding these to make it slightly easier for people to manage events in gPlayership mainly, and for some stock event methods that get stored as <Events>.

Position tracking is also implemented- the tracker can call <OnEnterSystem> and <OnExitSystem> events in addition to keeping track of the current system, duration of the visit, duration of previous visits to the system, number of individual system visits, and past 5 visited systems. These will be included in the navigation computer (basic) and also be available in the stand alone version of this mod as local data on a system.
Last edited by Periculi on Thu Aug 28, 2008 4:33 am, edited 1 time in total.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

can we get a example of tmrSetDataFunction
I don't understand why funcName is repeated and what placeholder is
Crying is not a proper retort!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

The placeholder simply means that one (eval method is working for two types of function events.

(tmrSetCustomFunction [delay] [funcName]) creates a list entry on eventActiveList = (list "DoCustomFunction" [onThisTick] [funcName])

(tmrSetDataFunction [delay] [placeholder] (list [funcName] [data]) creates a list entry on eventActiveList = (list "DoCustomFunction" [onThisTick] [ignored] [(list funcName data)])

Both types of event items get processed by "DoCustomFunction".

Which simply gets the list entry and does this:
(if (not (item eventList 3))
(eval (list (item eventList 2)))
(eval (item eventList 3))
)

Maybe I don't even need them both- I just added the list on later- if item 2 is already (list funcName) or (list funcName data data) I wonder if would work just the same.
But then you have to remember to make funcName a list.
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

I would make them the same function and before you put it in your list check if it is a list and if not put it in a list (isList X)
8)

edit: sorry I forgot it is (not (isAtom X)) to see if it is a list
Crying is not a proper retort!
Post Reply