Author Topic: Input Events  (Read 2345 times)

Hey,
Does anyone know how to make a input event? I saw spaceguy's tutorial but I didn't get it. I just want a input event triggered by a function. For example executing a input event when a command is triggered via GUI
Can anyone help me,
Thanks,
RarwMuffinz


Use it, it is very helpful. There are a lot of results that would match with this.


Use it, it is very helpful. There are a lot of results that would match with this.
Don't be a smartass. I searched and found nothing. Instead of just saying "search it" could you actually post a link to the topic?

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.

<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);
}

See the "In an Input function" section for an example.

Don't be a smartass. I searched and found nothing. Instead of just saying "search it" could you actually post a link to the topic?
I have tried to help you so you know what to do. I am not being an ass or anything, but if you want to be like that be my guest, I will just not help you at all.

If you used the search button you would have found what Greek found. (Well it is on top of the coding help list, no search for this, unless you can't find it, then use search)
« Last Edit: September 20, 2013, 10:43:05 AM by Advanced Bot »

Thanks Greek,
But I already saw that on Space Guy's thread. I just don't understand it

1. Change onToolBreak in the registerInputEvent call to whatever you want the event named
2. Write a fxDtsBrick::<yourEventName> method.
3. Copy the $InputTarget_ variable definitions in the example to your function
4. In the serverCmd that's called when a client presses the gui button, you'll need to somehow choose a brick that has the event on it, then call %brick.processInputEvent(<yourEventName>);

I think that's it, I've only ever written an input event once

Thanks Headcrab. I Think i got it now :cookieMonster:

Problem.
"Unable to find function registerInputEvent"
Halp pls

Problem.
"Unable to find function registerInputEvent"
Halp pls

You are executing this on a server, right?

Yes Greek. Im using it on my own server