Author Topic: Evented Variable Saver [EventScript]  (Read 57 times)

Hey! These events will allow players to save VCE variables and have their values saved as named bricks. Each player gets their own personal brick to saved on too! These events require the latest version of fireRelayNum and VCE. To easily copy the events from here use event script.

This sets up a player's varaible gate if they don't already have one.
Code: [Select]
[x][33] onActivate -> "dataBrick" -> fireRelaySouth(0, 0, 0, 0)
[x][33] onActivate -> "dataBrick" -> VCE_relayCallFunction("South", "checkBLID", "", 0, 0, 0, 0)
[x][0] onActivate -> Self -> VCE_ifValue("<var:cl:dataExists>", "==", 1, "3 3", 0, 0, 0, 0)
[x][0] onVariableFalse -> Self -> pickRandNamedBrick("dataBrick", "0 1", 0, 0, 0, 0)

This writes "variableData" into "varaibleName".
Code: [Select]
[x][33] onActivate -> "dataBrick" -> fireRelaySouth(1, 0, 0, 0)
[x][0] onActivate -> Self -> VCE_modVariable("Client", "dataCheck", "Set", "variableName", 0, 0, 0, 0)
[x][0] onActivate -> Self -> VCE_modVariable("Client", "data", "Set", "variableData", 0, 0, 0, 0)
[x][0] onActivate -> "dataBrick" -> VCE_relayCallFunction("South", "writeData", 0, 0, 0, 0, 0)

This will read "variableName" and the data will be returned with the client variable brickReturn. This brick must be named "dataRead".
Code: [Select]
[x][33] onActivate -> "dataBrick" -> fireRelaySouth(0, 0, 0, 0)
[x][0] onActivate -> Self -> VCE_stateFunction("returnData", "5 5", 0, 0, 0, 0)
[x][0] onActivate -> Self -> VCE_modVariable("Client", "dataCheck", "Set", "variableName", 0, 0, 0, 0)
[x][0] onActivate -> Self -> VCE_modVariable("Client", "brickReturn", "Set", "a", 0, 0, 0, 0)
[x][0] onActivate -> "dataBrick" -> VCE_relayCallFunction("South", "getData", 0, 0, 0, 0, 0)
[x][0] onVariableFunction -> Self -> VCE_ifValue("returnData", "!=", "", "6 6", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_ifValue("<var:cl:brickReturn>", "==", "a", "7 7", 0, 0, 0, 0)
[x][0] onVariableTrue -> Client -> CenterPrint("<var:cl:dataName>", 3, 0, 0, 0, 0)



This is the yellow bricks in the image. This brick will turn red when someone has claimed the brick. It must be named "dataBrick" and is the head of the dataBrick system.
Code: [Select]
[x][0] onPickedRandNamedBrick -> Self -> VCE_relayCallFunction("South", "setBLID", "", 0, 0, 0, 0)
[x][0] onPickedRandNamedBrick -> Self -> setColor("1.000000 0.000000 0.000000 1.000000", 0, 0, 0, 0)

This is the green bricks in the image. This stores the clients BLID as it's name and acts as a gate for their data. This must be south of the a yellow brick to work.
Code: [Select]
onRelay0: [x][0] onRelay -> Self -> VCE_stateFunction("setBLID", "4 4", 0, 0, 0, 0)
onRelay1: [x][0] onRelay -> Self -> VCE_stateFunction("checkBLID", "6 6", 0, 0, 0, 0)
[x][0] onRelay -> Self -> VCE_stateFunction("getData", "9 9", 0, 0, 0, 0)
[x][0] onRelay -> Self -> VCE_stateFunction("writeData", "12 12", 0, 0, 0, 0)
[x][0] onVariableFunction -> Self -> VCE_ifValue("setBLID", "!=", "", "5 5", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_modVariable("Brick", "name", "Set", "<var:cl:bl_id>", 0, 0, 0, 0)
onVariableFunction6: [x][0] onVariableFunction -> Self -> VCE_ifValue("checkBLID", "!=", "", "7 7", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_ifValue("<var:cl:bl_id>", "==", "<var:br:name>", "8 8", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_modVariable("Client", "dataExists", "Set", 1, 0, 0, 0, 0)
[x][0] onVariableFunction -> Self -> VCE_ifValue("getData", "!=", "", "10 10", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_ifValue("<var:cl:bl_id>", "==", "<var:br:name>", "11 11", 0, 0, 0, 0)
[x][33] onVariableTrue -> Self -> fireRelayNum([onRelay0,onRelay1], "South", 0, 0, 0, 0)
[x][0] onVariableFunction -> Self -> VCE_ifValue("writeData", "!=", "", "13 13", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_ifValue("<var:cl:bl_id>", "==", "<var:br:name>", "14 14", 0, 0, 0, 0)
[x][33] onVariableTrue -> Self -> fireRelayNum([onRelay0,onVariableFunction6], "South", 0, 0, 0, 0)

This is the cyan bricks in the image. There can be as many of these bricks as you want for each variable you want to save. On the first line repalce "variableName" with your variable's name. These bricks must be south of a green brick or another cyan brick.
Code: [Select]
onRelay0: [x][0] onRelay -> Self -> VCE_modVariable("Brick", "dataName", "Set", "variableName", 0, 0, 0, 0)
onRelay1: [x][0] onRelay -> Self -> VCE_ifValue("<var:br:dataName>", "==", "<var:cl:dataCheck>", "2 5", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_modVariable("Client", "dataName", "Set", "<var:br:name>", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_modVariable("Client", "dataCheck", "Set", "", 0, 0, 0, 0)
[x][33] onVariableTrue -> "readData" -> VCE_callFunction("returnData", "", 0, 0, 0, 0)
[x][33] onVariableFalse -> Self -> fireRelayNum([onRelay0,onRelay1], "South", 0, 0, 0, 0)
onRelay6: [x][0] onRelay -> Self -> VCE_ifValue("<var:br:dataName>", "==", "<var:cl:dataCheck>", "7 9", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_modVariable("Brick", "name", "Set", "<var:cl:data>", 0, 0, 0, 0)
[x][0] onVariableTrue -> Self -> VCE_modVariable("Client", "dataCheck", "Set", "", 0, 0, 0, 0)
[x][33] onVariableFalse -> Self -> fireRelayNum([onRelay0,onRelay6], "South", 0, 0, 0, 0)

This is semi-complicated to set up. If you need help or if I need to clarify how to use something just ask.