Blockland Forums > General Discussion
Advanced VCE techniques?
<< < (2/3) > >>
Mysteroo:
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
boodals 2:

--- Quote from: Mysteroo on May 25, 2013, 10:24:12 AM ---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

--- End quote ---
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.
King Leo:

--- Quote from: tredden on May 23, 2013, 08:18:46 PM ---~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.


--- End quote ---
Uhm. I'm pretty sure that strings are capped at 200 characters. So the "infinately large" part isn't quite true...
LeetZero:
"//" 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: ---Brick #
onActivate NamedBrick_example callFunction dostuff // This will call the respective function from the "example" brick.

--- End code ---

--- Code: ---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.

--- End code ---


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: ---Brick #
onActivate Self VCE_ifVariable <var:pl:currentitem> == [precise item name]

--- End code ---


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: ---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"

--- End code ---

--- Code: ---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>

--- End code ---
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: ---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.

--- End code ---
Mysteroo:

--- Quote from: LeetZero on May 26, 2013, 01:51:36 PM ---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: ---Brick #
onActivate Self VCE_ifVariable <var:pl:currentitem> == [precise item name]

--- End code ---

--- End quote ---
Oh cool, never thought of this one, I may use this
Navigation
Message Index
Next page
Previous page

Go to full version