Hello everyone,
I am johnwiliam I am new for this site and this is my first post here, hope all are doing well to sharing information here with others
Trust me, I’ve read the wiki; however, I just can’t seem to get DataStore to work correctly. And it does need to be save-specific, so .settings
is not what I need.
How exactly does GDT.fire
work? I have read the wiki, but I don’t fully understand it. An example would be awesome.
I suppose you want a custom event?
The way the event system works is, you add a callback function to a ‘key’.(with the GDT.on function) after that everytime you fire that event the code will be run so to add a new event you just do something like this:
var MODGLOBALSCOPEVARIABLE = {};
MODGLOBALSCOPEVARIABLE.eventKeys = {
globalEvents: {
testEvent1: 'modname.global.testEvent1',
testEvent2: 'modname.global.testEvent2'
},otherevents: {
testEvent3: 'modname.otherevents.testEvent3'
}
}
Then you add your listeners and methods:
var testFunc = function(item){
// Do something
alert("itemId : " + item.id);
};
GDT.on( MODGLOBALSCOPEVARIABLE.eventKeys.testEvent1,testFunc);
After that you need to trigger the event for example when clicking a button somewhere you use:
GDT.fire(MODGLOBALSCOPEVARIABLE.eventKeys.globalEvents.testEvent1, {objectId:test, othervars:'blabla' } );
note the object you pass is optional.(if the handler method doesn’t require the object.
Does that clear it up?
greetz
Ahhhh ok. Asked mostly out of curiosity, but It’s something I may use. As always, thanks dude!
Somehow I think your mod will be great. By looking at everything in this topic, and your Unfinished AI Internet project, I have come up with my own thoughts of what you are doing. I think this mod will be very fun. Carry on!
Really means a lot, dude! Community support is much appreciated in a time when the forum is quiet.
Hoping to show some screenshots when I have a sufficient build ready.