Crash Course in using Variable String (vstr)

henry winkler Jan 9, 2011

  1. he

    henry winkler Gold Member Gold Subscriber
    0/47

    Joined:
    Oct 7, 2010
    Messages:
    251
    Likes Received:
    301
    Trophy Points:
    0
    Console:
    Nintendo
    [font="arial][size="2"]Credit goes to walkerneo


    I was planning on making this earlier, but I was busy fixing my gpd for the latest bypass and I had some trouble. Variable string is extremely useful if you know how to use it, and if used effectively, works wonders.


    Like in Algebra, the variable (string) can be set and can be changed. Look:
    Code:
    bind BUTTON_RB "vstr x"
    set x "noclip"
    This binds variable string x to the right bumper. set x "noclip" sets the variable string x to enable or disable noclip.Of course, using it like this wouldn't be practical, so I'll move on to its first use.

    Due to the playlist update that patched setting the buttons config to null, in order to use binds, commands had to be set to the stick layout. All of the button binds had to be set to movement of the analog sticks. Before that playlist update, gpds would look something like:
    Code:
    set gpad_buttonsConfig "null"
    bind BUTTON_RSHLDR "noclip"
    bind BUTTON_LSHLDR "godmode"
    bind DPAD_DOWN "drop weapon"
    ......
    After the pu (playlist update) that wouldn't work and setting the buttons config to null would disable all commands on all buttons. To get around that, people did the following:
    Code:
    set gpad_sticksConfig "null"
    bind APAD_DOWN "bind BUTTON_RSHLDR noclip;bind BUTTON_LSHLDR god;bind DPAD_DOWN dropweapon..."
    *side note when I put the periods at the end of the code, it's not actually part of the code, I'm putting that to represent a continuation of code in a similar manner.


    The above code will work just fine, but I think that looks way too messy AND there's a conflict. Say you wanted to get the upgraded ray gun and the death machine when you press left on the dpad. So, you type in:

    Code:
    set gpad_sticksConfig "null"
    bind APAD_DOWN "bind DPAD_LEFT give ray_gun_upgraded_zm;give minigun_zm;bind BUTTON_RSHLDR noclip;bind BUTTON_LSHLDR god;bind DPAD_DOWN dropweapon..."
    bind DPAD_LEFT give ray_gun_upgraded_zm;give minigun_zm was added

    Most of you will probably see that that code will not work the way you want it to. give minigun_zm will be binded to APAD_DOWN and not DPAD_LEFT, so here's the first practical use of variable string.

    Code:
    set gpad_sticksConfig "null"
    bind APAD_DOWN "bind DPAD_LEFT vstr x;bind BUTTON_RSHLDR noclip;bind BUTTON_LSHLDR god;bind DPAD_DOWN dropweapon..."
    set x "give ray_gun_upgraded_zm;give minigun_zm"
    In that code, variable string x was binded to DPAD_LEFT and then it was set to give the ray gun and death machine.

    The final use of variable string I will be discussing is the pinnacle of my modded zombie gpd. This is to toggle two different sets of controls. I owe this use of vstr to this thread. This is quite hard to understand at first, but I'll try my best.

    We want DPAD_UP to switch between two different sets of controls, so we are going to bind it to a variable. You can name your variables what you want, so long as they don't already do something in the game. You can use single numbers or letters, but for the purpose of this tutorial, I will name them better.

    First, we bind DPAD_UP to a variable string. In this case I use "tggle" (toggle) because we will be changing the value of that variable string. I then set "tggle" to variable string "ctrl1" (the first and primary button binds).

    Code:
    bind DPAD_UP "vstr tggle"
    set tggle "vstr ctrl1"
    Now we set "ctrl1"

    Code:
    bind DPAD_UP "vstr tggle"
    set tggle "vstr ctrl1"
    set ctrl1 "bind BUTTON_RSHLDR noclip;bind BUTTON_LSHLDR godmode;set tggle vstr ctrl2"
    This sets tggle to ctrl1. Ctrl1 sets tggle to ctrl2. I'll set ctrl2 now.

    Code:
    bind DPAD_UP "vstr tggle"
    set tggle "vstr ctrl1"
    set ctrl1 "bind BUTTON_RSHLDR noclip;bind BUTTON_LSHLDR godmode;set tggle vstr ctrl2"
    set ctrl2 "bind BUTTON_RSHLDR god;bind BUTTON_LSHLDR toggle r_fulbright;set tggle vstr ctrl1"
    I'll walk you through the code now:
    Code:
    bind DPAD_UP "vstr tggle"            //Dpad up is now set to variable string "tggle"
    set tggle "vstr ctrl1"                  //"tggle" is now set to ctrl1, so pressing up on the dpad will activate "ctrl1"
    set ctrl1 "bind BUTTON_RSHLDR noclip;bind BUTTON_LSHLDR godmode;set tggle vstr ctrl2"           		//These are the primary controls that are binded when you first press up on the dpad. Once you press up on the dpad, "tggle" is set to variable string "ctrl2"
    set ctrl2 "bind BUTTON_RSHLDR god;bind BUTTON_LSHLDR toggle r_fulbright;set tggle vstr ctrl1"                //Dpad up is set to "ctrl2", so pressing it will activate the secondary binds. It will also set "tggle" back to "ctrl1"
    If you look at the code I used in v3.0 of my zombie gpd, I had two extra lines setting variable strings. Ignore those, I was completely new to all of this and I just copied the model of bind toggling in the link I gave you. In my next version, I will implement the way I've shown here.

    The top half of my version 1.0 looked like this:
    Code:
    set gpad_buttonsConfig "null" 
    set zombietron_discovered "1" 
    set zombiefive_discovered "1" 
    set clanName "WALK"
    bind DPAD_UP "vstr axc;vstr mods"
    bind BUTTON_RTRIG "+attack;give ammo"
    bind DPAD_RIGHT "ai axis delete"
    bind DPAD_LEFT "vstr c"
    bind DPAD_DOWN "dropweapon"
    When someone posted the bypass for the pu, I changed it to this:
    Code:
    set gpad_buttonsConfig "buttons_default" 
    set gpad_sticksConfig "null"
    set zombietron_discovered "1" 
    set zombiefive_discovered "1" 
    set clanName "WALK"
    bind APAD_DOWN "vstr www;vstr www1;vstr www2;vstr www3;vstr www4"
    set www "bind DPAD_UP vstr axc;vstr mods"
    set www1 "bind BUTTON_RTRIG +attack;give ammo"
    set www2 "bind DPAD_RIGHT ai axis delete"
    set www3 "bind DPAD_LEFT vstr c"
    set www4 "bind DPAD_DOWN dropweapon"

    As you can see, it was EXTREMELY easy for me to get my gpd to work with the latest playlsit update by binding variable strings to the working bind and then setting binds to those variable strings. The variables are "www" because I was working fast and just typed in a random name, there is no function of their name in the code.

    Also, if you noticed, I used: set www1 "bind BUTTON_RTRIG +attack;give ammo". I couldn't figure out a way around it, and for some reason the following wouldn't work either:
    Code:
    set www1 "bind BUTTON_RTRIG vstr www5"
    
    
    set www5 "+attack;give ammo"
    I still don't understand why setting the right trigger to a variable string and setting the variable string to "+attack;give ammo" doesn't work. If you figure this out, definite props to you.



    All the being said, I have never had any formal training in the matter of scripting. I learned all I know from reading other people's scripts (namely lost4468) and searching online (vstr).

    If you need help, pm me and I will do my best.

    **A couple things to note:
    • As I said, I have had no formal training and I don't know if the way I write the scripts isn't formal or the way it is supposed to be.
    • In most scripts I found online, the binds came after the variable strings were set. I'm not sure what purpose this serves, as it has always worked for me the way I do it.
    [/size][/font]
     

Share This Page

Close