Author Topic: Event System - Register Inputs/Outputs  (Read 28369 times)

Hacked out details from a console log, use it however. (Needs corrections and clarification)


Register an Input event:
Code: [Select]
registerInputEvent(fxDTSBrick, onActivate, Self fxDTSBrick Player Player Client GameConnection MiniGame MiniGame)
Code: [Select]
registerInputEvent(CLASS NAME, FUNCTION, MENUNAME CLASS NAME 2 MENUNAME CLASS NAME 2 ...)CLASS NAME likely has to be fxDTSBrick all the time, then your mod would call fxDTSBrick::FUNCTION.
MENUNAME is something like "Self", "Player" and sets the outputs list as the ones relevant to the CLASS NAME 2. (A class name like Player, GameConnection or MiniGame) Each pair is split by a tab.

e.g.
Code: [Select]
function fxDTSBrick::stuffHappens(%brick)
{
 //This is called when Stuff Happens
}
registerInputEvent("fxDTSBrick","stuffHappens","Self fxDTSBrick Player Player Client GameConnection");

... Would let you create an input called stuffHappens, which can then cause events to happen to a Player, Client or Itself. See In an Input function for how to set variables for the targets.
<NAMED BRICK> seems to be automatically added.


In an Input function: (Thanks, TheGeek!)
Set variables for each of the targets, depending on the function, then call processInputEvent.
Code: [Select]
registerInputEvent("fxDTSBrick", "onToolBreak",  "Self fxDTSBrick" TAB
                                                 "Player Player" TAB
                                                 "Client GameConnection" TAB
                                                 "MiniGame MiniGame");

function fxDTSBrick::onToolBreak(%obj, %client)
{
   //setup targets
   //player = person who destroyed it
   $InputTarget_["Self"]   = %obj;
   $InputTarget_["Player"] = %client.player;
   $InputTarget_["Client"] = %client;

   if($Server::LAN)
   {
      $InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
   }
   else
   {
      if(getMiniGameFromObject(%obj) == getMiniGameFromObject(%client))
         $InputTarget_["MiniGame"] = getMiniGameFromObject(%obj);
      else
         $InputTarget_["MiniGame"] = 0;
   }
   //process the event
   %obj.processInputEvent("OnToolBreak", %client);
}


Register an Output event:
Code: [Select]
registerOutputEvent(fxDTSBrick, setColorFX, list None 0 Pearl 1 Chrome 2 Glow 3 Blink 4 Swirl 5 Rainbow 6, 0)
registerOutputEvent(fxDTSBrick, disappear, int -1 300 5)
registerOutputEvent(Player, SetPlayerScale, float 0.2 2 0.1 1)
registerOutputEvent(fxDTSBrick, fakeKillBrick, vector^int 0 300 5)
Code: [Select]
registerOutputEvent(%class, %name, %parameterList, %appendClient)
registerOutputEvent("CLASS NAME", "FUNCTION", "argumenttype BOUNDS OR SETTINGS argumenttype BOUNDS OR SETTINGS ...", APPENDCLIENT)

CLASS NAME is the same as the CLASS NAME 2's defined in the last function. When you select one of the Targets, all the outputs for objects with the same class name will show.
FUNCTION is the function called.
The arguments start with a lower case type and the bounds/settings for it after. Multiple settings can be given with tabs. If you set this string to "", there are no arguments. I am guessing these are the arguments passed to the function, starting with the object's ID.
If APPENDCLIENT is set, the triggering client will be added to the end of the arguments.

Known types:
int MININUM MAXIMUM DEFAULT (Integer, must be a whole number but can be below zero)
float MINIMUM MAXIMUM STEPSIZE DEFAULT (Floating point number. Displays a slider which snaps to the nearest (stepsize) amount when you drag it and let go.)
list ITEM returnNo. ITEM returnNo. ITEM returnNo. (Returns returnNo. when the item before it is selected?)
bool (Checkbox)
intList NUMBER (List of integers, separated by spaces. The number is the text box length.)
datablock TYPE (Either a datablock type like ProjectileData or ItemData, shows all ones with uiNames, or something like "Vehicle" or "Music" which shows valid music audioProfiles and all rideable vehicles, including player-based ones like Horses)
string CHARACTERS LENGTH (Displays a text box of length LENGTH which can hold up to CHARACTERS letters or numbers)
vector (Displays three boxes which let you input a 3d vector)
paintColor 0 (Displays a selector for a paint colour type. I am not sure what function the 0 has.)


Anyway, do whatever you like with this list, these are my guesses at how to add events and things to the system.

EDIT: Corrections, thanks to TheGeek.

EDIT 2: Corrected argument types float and string and clarified some of the argument types a little more.
« Last Edit: October 28, 2015, 11:04:28 AM by Badspot »

This will be very useful, thanks space guy.



string NUMBER NUMBER (Letters, numbers, etc. NUMBERS are Max characters, box length)
int MINIMUM MAXIMUM DEFAULT (No decimal number, default is the value it starts on, or what it sets to if left blank.)

It turns out "float" (floating point decimal) has something like "step length" settable but I can't figure out where or how. It's probably something to do with adding "3.0" to the settings which lets you specify up to tenths of a number but I haven't tried this.

registerOutputEvent(Player, SetPlayerScale, float 0.2 2 0.1 1)
It seems to have 4 numbers.
I think it may be, Min, Max, decimal places, and Default.

Ah, checking it again, "float" displays a slider rather than a text box:
Code: [Select]
Entering registerOutputEvent(Projectile, Bounce, float 0 2 0.1 0.5)
float Minimum Maximum StepSize Default

Step size is the value it snaps to when you let go of the slider: here, it defaults to the nearest 0.1.
« Last Edit: September 17, 2008, 10:06:00 AM by Space Guy »

You have String backwards. :P
But yeah, thats what I was trying to say about float.


Bumping this because it's helpful, who else here thinks this should be stickied?

Yeah this is pretty helpful.


This is definately worth a sticky.

The above is why I will probably never make an event.

The above is why I will probably never make an event.
Not if you know programming logic.