Blockland Forums > General Discussion
Event Loops
(1/1)
tredden:
Just want a list that has the different kinds of event loops.

Single Brick

Relay Loop:

--- Code: ---X 33ms onActivate   Self   fireRelay
X 33ms onRelay   Self   fireRelay
X 0ms onRelay   -do stuff-

--- End code ---
A relay is fired upon itself, which triggers onRelay. Basic loop with a minimum 33ms delay.


ifVariable Loop

--- Code: ---X 0ms onActivate        Self VCE_ifVariable -var- == -anything-    1 99
X 0ms onVariableFalse    Self VCE_ifVariable -var- == -anything-    1 99
X 0ms onVariableFalse    -do stuff-

--- End code ---
As long as -var- is not set -anything- it should return false, which triggers the same comparison again. Probably the fastest and most efficient one; easily canceled if -var- becomes -anything-.


VariableUpdate Loop:

--- Code: ---X 0ms onActivate         Self VCE_modVariable -var- Set -anything-
X 0ms onVariableUpdate Self VCE_modVariable -var- Set -anything-
X 0ms onVariableUpdate -do stuff-

--- End code ---
A VCE variable is updated, which triggers onVariableUpdate. Not useful if you want to use VCE_modVariable again.


VariableFunction Loop

--- Code: ---X 0ms onActivate Self VCE_stateFunction -name- 2 99
X 0ms onActivate Self VCE_callFunction -name-
X 0ms onVariableFunction Self VCE_callFunction -name-
X 0ms onVariableFunction -do stuff-

--- End code ---
You have to state and call the function, which triggers onVariableUpdate. Stating required and sometimes functions can be unwieldy (for me at least).


Gravity Projectile Loop

--- Code: ---X 0ms onActivate Self spawnProjectile 0 0 3 Arrow
X 0ms onProjectileHit Self spawnProjectile 0 0 3 Arrow
X 0ms onProjectileHit -do stuff-

--- End code ---
A projectile goes up and comes back down, which triggers onProjectileHit. Also known as the "Why are you hitting yourself?" Loop. Slow and ineffective. Easily stopped by something getting in the way.


Multi-Brick

Relay Loop

--- Code: ---X 33ms onActivate Self fireRelayDown
X 0ms onRelay Self fireRelayDown
X 0ms onRelay -do stuff-

--- End code ---

--- Code: ---X 0ms onRelay      Self    fireRelayUp

--- End code ---
Two bricks; one on top of the other. Brick fires down, brick fires up.


Projectile Loop

--- Code: ---X 0ms onActivate Self spawnProjectile 0 5 0 Pong
X 0ms onProjectileHit Self spawnProjectile 0 5 0 Pong
X 0ms onProjectileHit -do stuff-

--- End code ---

--- Code: ---X 0ms onProjectileHit Self spawnProjectile 0 -5 0 Pong

--- End code ---
Two bricks; one north of the other. Brick shoots one; it shoots back.
boodals 2:

--- Quote from: tredden on July 10, 2013, 06:08:24 PM ---Gravity Projectile Loop

--- Code: ---X 0ms onActivate Self spawnProjectile 0 0 3 Arrow
X 0ms onProjectileHit Self spawnProjectile 0 0 3 Arrow
X 0ms onProjectileHit -do stuff-

--- End code ---
A projectile goes up and comes back down, which triggers onProjectileHit. Also known as the "Why are you hitting yourself?" Loop. Slow and ineffective. Easily stopped by something getting in the way.

--- End quote ---

Last time i checked, this does not allow you to access the client. In fact, I think Badspot forcefully removed the client so players cant make these sort of loops with default events. Although the client and player targets are there, it simply does not work.

EDIT: Just tested, Client target works, however Player does not.
Deve111²:

--- Quote from: boodals 2 on July 10, 2013, 06:15:36 PM ---Last time i checked, this does not allow you to access the client. In fact, I think Badspot forcefully removed the client so players cant make these sort of loops with default events. Although the client and player targets are there, it simply does not work.

--- End quote ---

You could probably work around it.
Navigation
Message Index

Go to full version