Author Topic: Help with Events and OnPlant  (Read 1081 times)

How would I add custom variables to bricks?
How would I make a check for X variable of a brick when it's planted?
How can I make an output event? I'm familiar with input but I can't figure out the output events.

Please note, my PC is decommissioned (I spilled water on the mobo) so I can't access my HDDs as they're IDE drives and my netbook doesn't have IDE connectors.

How would I add custom variables to bricks? VCE or normal coded variables?
How would I make a check for X variable of a brick when it's planted? Package fxDTSBrick::onPlant, if your using normal variables just use a regular if statement.
How can I make an output event? I'm familiar with input but I can't figure out the output events. Its all explained here

Normal coded variables.

It think packaging function yourbrickDatablock::onPlant(%data,%obj) would help.

Example from Brick_Checkpoint

function brickCheckpointData::onPlant(%data, %obj)
{
   %obj.enableTouch = true;

   %enabled     = 1;
   %delay       = 0;
   %inputEvent  = "OnPlayerTouch";
   %target      = "Self";
   %outputEvent = "PlaySound";
   %par1        = Beep_Popup_Sound.getId();
   %obj.addEvent(%enabled, %delay, %inputEvent, %target, %outputEvent, %par1);
}


What do you mean by X variable?



For input events

You could use something, like this onItemPickup event. When someone picks up an item from the brick, that brick is triggered by "%brick.processInputEvent("eventname",%client); but it needs to use these variables before doing this


   $InputTarget_["Self"]   = %brick;
   $InputTarget_["Player"] = %client.player;
   $InputTarget_["Client"] = %client;
   $InputTarget_["MiniGame"] = getMiniGameFromObject(%brick);


Example from Event_onItemPickup

registerInputEvent(fxDTSBrick,onItemPickup,"Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame Minigame");

package itemPickup
{
 function Player::pickup(%this,%item)
 {
  %brick = %item.spawnBrick;
  %val = Parent::pickup(%this,%item);
  if(%val == 1 && isObject(%brick) && %this.getClassName() $= "Player" && isObject(%this.client))
  {
   %client = %this.client;
   $InputTarget_["Self"]   = %brick;
   $InputTarget_["Player"] = %client.player;
   $InputTarget_["Client"] = %client;

   if($Server::LAN)
   {
      $InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
   }
   else
   {
      if(getMiniGameFromObject(%brick) == getMiniGameFromObject(%client))
         $InputTarget_["MiniGame"] = getMiniGameFromObject(%brick);
      else
         $InputTarget_["MiniGame"] = 0;
   }

   %brick.processInputEvent(onItemPickup,%client);
  }
  return %val;
 }
};
activatePackage(itemPickup);
« Last Edit: April 18, 2014, 02:00:49 AM by Advanced Bot »

Thanks, that was all I needed.