Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Dynamic event system (requires IanM's Matrix1utility pack)

Author
Message
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Sep 2007 14:21
Just make an inlude containing the following code, and you can have a dynamic event system!

Call InitEvents first!

To create an event, use CreateEvent(Name as string). It returns the ID of the event.
To get the ID of an existing event, use GetEventID(Name as string).
To raise an event, use RaiseEvent<suffix>(ID, <parameter list>
(There are some other commands as well)

Because DBP does not support over-loaded functions, functions for each type of parameters has a different suffix:
no parameters:
RaiseEvent(ID)

Integer parameter:
RaiseEvent_S32(ID, Param1 as integer)

Integer, Double float:
RaiseEvent_S32F64(ID, Param1 as integer, Param2 as double float)

There are versions of the function for all base types for up to 2 parameters, and support for integer/dword/float/string with 3 parameters. Custom versions can also be created, for any combination of types that you need, by modifying the function template at the top.

The code:


Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 8th Sep 2007 14:38
Sounds interesting, but... What is "function ptr is valid" and "call function ptr"? It's neither hightlighted nor compiles it. Do I need a DLL to run it?
Also I'd prefer functions with prefix, so all the functions begin with "des_" for Dynamic Event-System or so, to avoid functions with the same name, and to make the code easier to read.
Apart from that, could you write an example-program to demonstrate, what exactly the functions are good for? I'm not really sure for what to use them.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Sep 2007 14:41 Edited at: 8th Sep 2007 14:42
@Mr Kohlenstoff
Check the title

I will make an example though

Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 8th Sep 2007 14:47
Quote: "Check the title "


... Sorry, didn't see it.
But I thought I have installed this plugin.. however, I'll download it again then.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Sep 2007 14:57
Here is an example showing how to use it. Although what it is being used for is not that useful, there are times when it can be very useful!


aXeon
17
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 9th Sep 2007 19:14
I use the same sort of system in my Inherit²Engine.
It works like this:

RegisterEvent("F10","ToggleConsole")

Or...

RegisterEvent_ToConsole("EventNameForIndex","TAB","cg_showscores 1")

To call up the commands inside source:

If GetEvent("ToggleConsole") Then ........

- : aXeon Essentials : -
Essence
22
Years of Service
User Offline
Joined: 12th Oct 2002
Location: The Netherlands
Posted: 5th Oct 2007 17:59
I dont really get the point of this.

Current project: MiRevu Visual Gaming Engine
thread: http://forum.thegamecreators.com/?m=forum_view&t=103073&b=8
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 5th Oct 2007 20:24
Essence, if you search for a recent thread in the DBPro Board that I made called "Triggers", you will find out

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers

Login to post a reply

Server time is: 2024-11-22 13:09:44
Your offset time is: 2024-11-22 13:09:44