Author Topic: Pre Events  (Read 1568 times)

How do I script a brick to have events in it when you plant the brick? Like with JVS doors and switches.

Take a look at a JVS door .blb file. It has the events if I recall correctly.

No the .cs files have the events but I don't understand it completely.

The part I don't understand is the
Code: [Select]
$Brick::Content::Type:

Look at the checkpoint brick that comes with the game.

Look at the checkpoint brick that comes with the game.
D: that code looks even more complicated then the JVS door's.

Code: [Select]
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);
}

function brickCheckpointData::onLoadPlant(%data, %obj)
{
   Parent::onLoadPlant(%data, %obj);
   %obj.enableTouch = true;
}

How is that complicated?

Code: [Select]
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);
}

function brickCheckpointData::onLoadPlant(%data, %obj)
{
   Parent::onLoadPlant(%data, %obj);
   %obj.enableTouch = true;
}

How is that complicated?
I don't get the %par1

%par1 is created the line before
"   %par1        = Beep_Popup_Sound.getId();"
and all it is doing is telling it what sound to play, like on the event you pick "Bep_Poppup

I don't get the %par1
Parameter 1. You know, the first selectable option for PlaySound.


And basically you need this
%outputEvent
%inputEvent

And for the whole thing you need this,
Code: [Select]

function brick[b]BRICKNAME[/b]Data::onPlant(%data, %obj)
{
   %obj.enableTouch = true;

   %enabled     = 1;
   %delay       = 0;
   %inputEvent  = "[b]INPUTEVENTHERE"[/b];
   %target      = "[b]TARGEt,SELF,NAMEDBRICK,WHATVER[/b]";
   %outputEvent = "[b]OUTPUTEVENTHERE[/b]";
   %par1        = ; //You may need this line or no, it depends.
   %obj.addEvent(%enabled, %delay, %inputEvent, %target, %outputEvent, %par1); //Obvious
}

Quote from: Ephialtes
Lol @ desperate to prove himself good at scripting ^^

Can I have multiple OnPlant functions? or should they be OnPlantTwo and OnPlantThree ect