Blockland Forums > General Discussion
Advanced VCE techniques?
tredden:
I have been VCEventing for quite some time and have found a few "advanced" techniques.
~Both a brick's printid and colorid can be modified as a variable:
--- Code: ---onActivate - Self - VCE_modVariable - colorid - Set - 0
--- End code ---
This will set the brick color to the first color in the server's color set
~Creating Variable Arrays:
--- Code: ---onActivate - Self - VCE_modVariable - number - Add - 1
onActivate - Self - VCE_modVariable - player<var:br:number> - Set - <var:cl:name>
--- End code ---
This one will set the player's name to a different variable every click. Ex. The first click will set the player's name to variable "player1." The second will set it to "player2." etc.
~Creating Variable Loops:
--- Code: ---0 [0] onActivate - Self - VCE_modVariable - timer - Set - 60
1 [0] onActivate - Self - VCE_ifVariable - timer - > - 0 [2 4]
2 [0] onVariableTrue - Self - VCE_modVariable - timer - Subtract - 1
3 [1000] onVariableTrue - Self - VCE_ifVariable - timer - > - 0 [2 4]
4 [0] onVariableFalse - Self - playSound - Beep_No.wav
--- End code ---
This makes the variable "timer" 60. Then checks if the var is greater than 0. It is true, so "timer" would subtract 1, becoming 59. Then, after 1000ms (or 1 second), it checks it again, starting the loop over again, until eventually reading false, which ends the loop and plays a buzzer sound.
~Variable Databases:
This is the most advanced one i have learned. You can create infinitely large (in theory) databases on a single variable. How? Well it mostly has to do with the VCE_modVariable Word function. For instance:
--- Code: ---0 [0] onActivate - Self - VCE_modVariable - data - Set - "orange apple banana grape"
1 [0] onActivate - Self - VCE_modVariable - temp - Set - <var:br:data>
2 [0] onActivate - Self - VCE_modVariable - temp - Word - 1
3 [0] onActivate - Client - centerPrint - <var:br:temp>
--- End code ---
I bet just by reading the code, you can figure out what it will display.
Can ya guess?
That's right!
"banana"
Wait what?
The numbering that is used when using VCE_modVariable Word, starts at -1 and goes up from there. (A simple solution for this if you don't feel like doing a little a math is put 2 spaces at the front of the database)
So what can you do with this?
Well. Lets say you use something instead of that 1. Liiiiiiiike a variable replacer.
--- Code: ---0 [0] onActivate - Self - VCE_modVariable - data - Set - " orange apple banana grape"
1 [0] onActivate - Self - VCE_modVariable - number - Add - 1
2 [0] onActivate - Self - VCE_modVariable - temp - Set - <var:br:data>
3 [0] onActivate - Self - VCE_modVariable - temp - Word - <var:br:number>
4 [0] onActivate - Client - centerPrint - <var:br:temp>
--- End code ---
Every press will read you the next item in the database.
I have actually combined every single one of these techniques in order to create an infinite slide animation studio. But i bet thats a walk in the park now that you know all this!
So this is what i know. I was wondering if anyone had found anything else out that you can do with VCE.
Night Fox:
do you know how to use functions?
AromaniaFTW:
wow, nice stuff.
are you familiar with varlinks?
tredden:
Yes i've read the manual forwards and backwards (which was really unproductive) so i know about functions and varlinks
WALDO:
Not sure if they're all advanced or not but they're still pretty neat:
Brick to Brick Data Transfer (Sending brick variables to other bricks by using a client to transfer the data.)
--- Code: ---Events from brick1:
0. [√] [0] onActivate - Self - modVariable <var:cl:tempdata> Set <var:br:brick1data>
1. [V] [33] onActivate - namedbrick brick2 - fireRelay
Events from brick2:
0. [√] [0] onRelay - Self - modVariable <var:br:sentbrick1data> Set <var:cl:tempdata>
--- End code ---
It's that easy but it's also very handy to use. If you want the receiving brick to know what brick told the client to carry the data over or any other information, just add more variables to the client so it can know all that.
External Client Event Activation (Making other clients activate events from a relay by a touchable brick.)
--- Code: ---Events from activator brick:
0. [√] [33] onActivate - namedbrick PlayerTouchMe - fireRelay
Events from brick that should touch another client's player (PlayerTouchMe):
0. [√] [0] onRelay - Self - ToggleEventEnabled 1 2
1. [ ] [0] onPlayerTouch - Client - centerPrint Hello world!
2. [ ] [0] onPlayerTouch - Self - ToggleEventEnabled 1 2
--- End code ---
So far I have only found 1 way to make other clients, besides the client who activated the relay, to activate the events I want them to do from a relay. This is that way. By using this technique, you can make other clients activate the events that you want them to do by another brick telling them when to do so. The only downside to this is, you must have the client's player touching the receiving brick in order for it to work. If no players touches the brick that they should touch and you want the system of your events to continue on even without your player touching brick being triggered, do something like this:
--- Code: ---Events from activator brick:
0. [√] [33] onActivate - namedbrick PlayerTouchMe - fireRelay
Events from brick that should touch another client's player (PlayerTouchMe):
0. [√] [0] onRelay - Self - ToggleEventEnabled 2 3 4
1. [√] [1000] onRelay - Self - ToggleEventEnabled 2 3 4
2. [ ] [0] onPlayerTouch - Client - centerPrint Hello world!
3. [ ] [0] onPlayerTouch - Self - ToggleEventEnabled 2 3 4
4. [ ] [0] onPlayerTouch - Self - CancelEvents
--- End code ---
As you can see in the above, I added a delayed onRelay event to toggle the events back if no one touches the brick. If someone does touch the brick, it will cancel all events currently being run so the enabled/disabled order doesn't get messed up.
If you combine both of the techniques I mentioned, you can create an even better version of the External Client Event Activation technique so you can have a wider range of different kinds of events activated by other clients during different moments of your event system by still using 1 brick as the player touching brick.