• Hey! Register here to create your account, engage with the community, and talk about what is new!

Var manipulation: editing vars by using names of other vars

Geodefence

New member
Joined
Mar 10, 2023
Messages
16
Reaction score
2
This is a simple, yet extremely helpful mechanic that allows for all sorts of things, storing list names in a list, removing money from a player who died, ect. I will not be going into detail in this guide, just how to use this and some examples.

Example 1. Death money penalty: A simple thing most players have made, but still helpful to touch on for the basics of this tutorial. Now, let's say a player killed another player, and you have a money system in your game. To edit the victims money, you can do %victim money or something like that. Now, if the money that increases/decreases is a saved var, the var you are editing MUST be a saved var as well.

Example 2. Tp ask system: Now, let's say you wanted to have a tp ask system. Using this, you can easily do it. Now, when a player does a command, let's say @tpask (player) we can get the 2nd command arg by getting the 2nd list value of command args, we will make this var name "tprequest" (local). Then, we can add a value to a list of the player you requested to tp to like this: "%var(tprequest) tp requests" now you can add the name of the var to anything after the %var. We can then start a process to remove that in, let's say 2 minutes. You can do this by setting a local var called something like "canceltpvarname", that you set to tprequest. then call a process (DO NOT FORGET TO SET LOCAL VARS TO COPY) that, after 2 minutes, removes the list value %default from the var %var(tprequest) (enter tp list name here). Now onto the teleport mechanic. We can do something like @tpaccept (player) and then, if the tpask list has the 2nd the value of the 2nd command arg in it, we remove the value then select the player written in the 2nd command arg. We can then tp the orginal player by getting the foot location of selection using a game value. Now, there are multiple bugs with this system, but this is just a example of what you can do with this.

Example 3. Easily get names of lists and cycle through them: Now, let's say you had a team system, and you stored the names of the list vars in another list var. You can pretty easily cycle through them by using a repeat for each in list, you put in the list of names of the list vars, then put in another var that gets the current value. Then, you can check if player is in a team by if %var(var that gets current value) (DO NOT FORGET TO SET THE VAR TO A SAVED VAR IF THE TEAM VARS ARE SAVED) contains value %default: do whatever you want in here.

So yeah, this is a really helpful system that can be used for a lot, I only scratched the surface with this one, there are probably even more things you can do with this.
 
Top Bottom