| Blockland Forums > Modification Help |
| Variable Questions |
| (1/4) > >> |
| jes00:
Could someone please answer the following questions about variables(no not the eventing kind, the scripting kind)? * How to add and subtract variables * How to save and load variables * How to set variables * How to check variables * How to display variables in a bottom print Thats all for now. |
| Nexus:
%var += 5; %var -= 5; %var *= 5; %var /= 5; %var = 5; if(%var == 5) { //do stuff } messageclient(%client, 'bottomprint', %var, 10); To save and load I prefer export("$var*", "config/var.cs"); exec("config/var.cs"); |
| jes00:
--- Quote from: Nexus on August 28, 2011, 07:24:46 PM ---%var += 5; So this one is higher then or equal to? %var -= 5; And this one is lower then or equal to? %var *= 5; What is this one? %var /= 5; No idea what this one is. %var = 5; And this one is equal to if(%var == 5) { //do stuff } messageclient(%client, 'bottomprint', %var, 10); To save and load I prefer export("$var*", "config/var.cs"); Does this create a .txt file in config? exec("config/var.cs"); --- End quote --- I'm guessing you replace %var with the variable? |
| Headcrab Zombie:
--- Quote ---%var += 5; So this one is higher then or equal to? This adds 5 to %var. Its a shorthand way of type '%var = %var + 5' If%var is equal to 15, after this, %var will be equal to 20 %var -= 5; And this one is lower then or equal to? Same as above, but subtracting 5 %var *= 5; What is this one? Same as above, but multiplying by 5 %var /= 5; No idea what this one is. Dividing by 5 %var = 5; And this one is equal to Setting %var to be equal to 5 if(%var == 5) { //do stuff } messageclient(%client, 'bottomprint', %var, 10); To save and load I prefer export("$var*", "config/var.cs"); Does this create a .txt file in config? It creates a text file names var.cs, inside config folder. Inside, will be every variable whose name begins with $var. For an example, type export("$Pref*","config/prefs.cs"); exec("config/var.cs"); --- End quote --- |
| Nexus:
For the tests if(%var < 5) if the variable is 4.99999 or less if(%var > 5) if the variable is 5.00001 or more if(%var >= 5) if the variable is 5 or greater if(%var $= "some string"); if the variable matches the string |
| Navigation |
| Message Index |
| Next page |