| Blockland Forums > Modification Help |
| Objects that emit a player detecting radius |
| << < (2/4) > >> |
| Red_Guy:
--- Quote from: Obibital on June 09, 2011, 10:20:08 PM ---I was told about those, but don't they have to be stepped on to activate? I'm planning on the block to be placed in a building, and upon entering the building you will gain radiation. I don't want the player to have to activate the block for it to start to effect variables. Think of it as a radioactive zone. --- End quote --- Triggers are always active. you get a script notification / callback whenever a player enters or leaves a trigger. If you want placing a brick to create a trigger, make sure your script also deletes the trigger when the brick is removed. Otherwise you will get weird effects and odd errors from your triggers activating when there are no bricks around. You will have 2 methods for your trigger class -- onEnterTrigger and onTickTrigger You can look up examples and explanations on the garagegames site. |
| Obibital:
--- Quote from: Red_Guy on June 10, 2011, 02:20:00 PM ---Triggers are always active. you get a script notification / callback whenever a player enters or leaves a trigger. If you want placing a brick to create a trigger, make sure your script also deletes the trigger when the brick is removed. Otherwise you will get weird effects and odd errors from your triggers activating when there are no bricks around. You will have 2 methods for your trigger class -- onEnterTrigger and onTickTrigger You can look up examples and explanations on the garagegames site. --- End quote --- Thanks a ton, I'll defiantly be using these now. I'll be posting a sneak-peek of the mod later on today. |
| Obibital:
--- Code: ---package radZone { function createRadZone(%brick, %owner) { if(!isobject(%brick)) return; %position = %brick.getboxcenter(); %trigger = new trigger() { datablock = brickFalloutRadArea; owner = %owner; }; %trigger.settransform(%position); %trigger.setscale(30); } function fxDtsBrick::onPlant(%brick) { echo("Radzone brick planted!"); echo(%brick @ "Was planted!"); createRadZone(%brick, %owner); } function brickFalloutRadArea::OnEnterTrigger(%this, %trigger, %obj) { echo("HOLY stuff YOUR IN A RAD ZONEEEEEEEEEEEEEEEEEEEEEEEEEEE"); echo( %client.Name @ " is in deep stuff."); } }; activatePackage(radZone); --- End code --- Well, this is mostly just a random stab at having a placed brick spawn a trigger around it. It didn't work because half of this made up. If you have any obvious errors/comments to make on it, please feel free to do so. I'll continue doing this in the morning, since right now I just don't have the mind for this. Good night. |
| Placid:
Umm, well, i'm pretty sure your script will, every time you plant a brick, say "Radzone brick was planted!". it will then commence to create rad zones on every brick you plant. plus, i think you would have to define %owner before you use it in the function. |
| otto-san:
You broke onPlant because you didn't call the parent. The trigger should be having a class, not a datablock. I'd strongly recommend looking for a certain type of brick or a variable on the client flagging if they said they're trying to plant rad areas, instead of EVERY SINGLE BRICK being one. %owner was never defined, should be %brick.client. |
| Navigation |
| Message Index |
| Next page |
| Previous page |