Author Topic: Advanced VCE techniques?  (Read 1279 times)

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: [Select]
onActivate - Self - VCE_modVariable - colorid - Set - 0This will set the brick color to the first color in the server's color set


~Creating Variable Arrays:
Code: [Select]
onActivate - Self - VCE_modVariable - number - Add - 1
onActivate - Self - VCE_modVariable - player<var:br:number> - Set - <var:cl:name>
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: [Select]
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
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: [Select]
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>
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: [Select]
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>
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.

do you know how to use functions?

wow, nice stuff.
are you familiar with varlinks?

Yes i've read the manual forwards and backwards (which was really unproductive) so i know about functions and varlinks

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: [Select]
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>
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: [Select]
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
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: [Select]
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
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.
« Last Edit: May 24, 2013, 12:58:30 AM by WALDO »

Here's an idea I had for something- Do you think using VCE you could find a players BL_id, and then transfer it to print bricks?

Like a player steps on a brick, and then for me, 18923 would show up on 5 print bricks

Here's an idea I had for something- Do you think using VCE you could find a players BL_id, and then transfer it to print bricks?

Like a player steps on a brick, and then for me, 18923 would show up on 5 print bricks
You can. I wont work it out in Events, but this is how you do it:
1. Round down (floor) the BL_ID/10000 to get the first digit, set first print to that using var:brick:printcount or whatever it was.
2. Round down the (BL_ID - First digit)/1000 to get the second digit.
3. Round down the (BL_ID - First digit - Second Digit)/100 to get the third.

Carry it on. I tried to do this a long time ago, didn't think of a solution, but the problem was stuck in my head until i solved it.

~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: [Select]
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>
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: [Select]
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>
Every press will read you the next item in the database.

Uhm. I'm pretty sure that strings are capped at 200 characters. So the "infinately large" part isn't quite true...

"//" Is calling a comment.



Functions
Functions are good ways to do something without spreading the event to every brick. It's a good use for creating a single math algorithm that can be used by a multitude of bricks.
Code: [Select]
Brick #
onActivate NamedBrick_example callFunction dostuff // This will call the respective function from the "example" brick.
Code: [Select]
Brick #example
onActivate Self stateFunction dostuff [number range] // This states a function, so the called function "domath" will call the respective [number range]. Number range should be the range where onVariableFunction is used.
onVariableFunction dostuff // dostuff can be anything you need.
onVariableFunction dostuff // You can make stateFunction call more onVariableFunction as long as they fit the number range.



Item "Key" ifVariable
This is a simple one, this basically makes any item a key. Take note that it can only be used on minigames with painting off. Using the paint changing button with an item in a minigame activates stuff.
Code: [Select]
Brick #
onActivate Self VCE_ifVariable <var:pl:currentitem> == [precise item name]



Item Saver
This is an alternative to the saveItem and loadItem events. The good thing in this one is that it keeps the item locations and multiple saving instances can be done. If you want to hold the items after leaving the server, use the comment event lines too.
Code: [Select]
Brick #saver
onActivate Client VCE_modVariable item1 Set <var:pl:item1>
onActivate Client VCE_modVariable item2 Set <var:pl:item2>
onActivate Client VCE_modVariable item3 Set <var:pl:item3>
onActivate Client VCE_modVariable item4 Set <var:pl:item4>
onActivate Client VCE_modVariable item5 Set <var:pl:item5>
// onActivate Client VCE_saveVariables Client "item1 item2 item3 item4 item5"
Code: [Select]
Brick #loader
// onActivate Client VCE_loadVariables Client "item1 item2 item3 item4 item5"
onActivate Player VCE_modVariable item1 Set <var:cl:item1>
onActivate Player VCE_modVariable item2 Set <var:cl:item2>
onActivate Player VCE_modVariable item3 Set <var:cl:item3>
onActivate Player VCE_modVariable item4 Set <var:cl:item4>
onActivate Player VCE_modVariable item5 Set <var:cl:item5>
If you want to do multiple "kits" or saving instances, change the values that the the player items get sent to as client values.



Holding decimals from a floor/ceil
Instead of getting a strict number from a inf. decimal one (10.2373... > 10) you can keep part of it (10.2373... > 10.23). // "..." is an infinity of numbers.
Code: [Select]
Brick #
onActivate Self VCE_modVariable theVariable Multiply 100 // Replace 100 to 10 to hold a decimal, 1000 for three etc. This will turn 10.2373... to 1023.73.
onActivate Self VCE_modVariable theVariable Floor/Ceil // This will turn 1023.73 to 1023.
onActivate Self VCE_modVariable theVariable Divide 100 // Replace 100 if you used another value from above. This will turn 1023 to 10.23.
« Last Edit: May 26, 2013, 02:06:47 PM by LeetZero »

Item "Key" ifVariable
This is a simple one, this basically makes any item a key. Take note that it can only be used on minigames with painting off. Using the paint changing button with an item in a minigame activates stuff.
Code: [Select]
Brick #
onActivate Self VCE_ifVariable <var:pl:currentitem> == [precise item name]
Oh cool, never thought of this one, I may use this

Uhm. I'm pretty sure that strings are capped at 200 characters. So the "infinately large" part isn't quite true...

Strings do not have caps. The number of characters that can be displayed on a single entry. (255 to be exact)

I have combined 3 of the above mentioned "advanced techniques" to show you about infinite databases.

Code: [Select]
0. onActivate Self VCE_modVariable  Brick  num  Add  1
1. onActivate Self VCE_modVariable  Brick  data  Set  <var:br:data> <var:br:num>
2. onActivate Self VCE_modVariable  Brick  check  Set  -1
3. onActivate Self VCE_ifVariable  false  ==  false  4 8
4. onVariableFalse Self VCE_modVariable  Brick  check  Add  1
5. onVariableFalse Self VCE_modVariable  Brick  temp  Set  <var:br:data>
6. onVariableFalse Self VCE_modVariable  Brick  temp  Words  <var:br:check>
7. onVariableFalse  Client  ChatMessage  <var:br:temp>
8. onVariableFalse  Self  VCE_ifVariable  temp   ==   4 8

If you notice on event line 1, the variable "data" would be set to itself, then would add the variable "number" to the end of it with a space between them. As you can figure out, the database would become increasingly bigger on every click.

Now, I could just display the variable "data" to the client, but as I mentioned, there is a 255 character limit. So instead, i used a variable to loop to display every single item in the database. Heres proof:





ETC. ETC. ETC.





As you can plainly see, there is no character cap for strings. And if you don't believe the pics, use the events from the code, click it a bunch of times, then scroll up your chat.



And as for combining all 4 techniques for the animation studio, i used colorids instead of numbers. Im not going to tell you about one more crucial step for the studio, but i bet someone can figure it based on all this information...
« Last Edit: May 26, 2013, 06:36:22 PM by tredden »

Item "Key" ifVariable
This is a simple one, this basically makes any item a key. Take note that it can only be used on minigames with painting off. Using the paint changing button with an item in a minigame activates stuff.
Code: [Select]
Brick #
onActivate Self VCE_ifVariable <var:pl:currentitem> == [precise item name]
So if I were to use the deflector, what would I put in for the item name? I tried "Deflector" but it isn't working for some reason, and yes I have painting disabled and everything

So if I were to use the deflector, what would I put in for the item name? I tried "Deflector" but it isn't working for some reason, and yes I have painting disabled and everything
Do a chatMesssage with "<var:pl:currentitem>" and see what it says. Include the "s to check for any spaces.

Strings do not have caps. The number of characters that can be displayed on a single entry. (255 to be exact)
Hmm... that's very interesting. I didn't know that. The sting contains more than 255 words (bad images in that respect btw, you should've shown one that displays a larger number than 255). If I print the entire "data" string, it will only display the words up to "88", since the total string length up to that point is 255 characters.