Talk:How to Script
Match section
Matchre is actually very easy to explain, and I think it could be added into the section with the current example shown with MATCHRE so people can understand. They are incredibly useful for keeping the amount of lines your code is down to a minimum.
Simple explanation is that it functions exactly the same as a MATCH. The pipe |
separates each of the regular expressions, and that it must start and end with forward slashes /
in StormFront.
1 putAway: 2 MATCH putAway ...wait 3 MATCHRE cycle /Stow what?|You are already wearing that.|But that is already in your inventory.|You/ 4 PUT stow my pickle 5 MATCHWAIT
-- Tea 20:53, 21 April 2009 (UTC)
- Because it also plays into thinks like WAITFORRE, I'm going to add it to a separate section (when I get around to it :P ) -Moderator Caraamon Strugr-Makdasi(talk) 18:02, 22 April 2009 (UTC)
--Deke 22:18, 1 August 2009 (UTC)
I would advise you add "i" to the end of all matchre's to make them case insensative. Additionally the "?" would not actually match a question mark in your string, to do that it must be preceeded by an "\". The same applies to your periods. Here's how the expression could be changed...
/Stow what\?|You are already wearing that\.|But that is already in your inventory\.|You/i
Save
It would nice to see SAVE explained, even if it's deprecated. I'm still trying to figure out what it does exactly so I understand other people's scripts. --Ateles 16:45, 1 August 2010 (UTC)
- As I recall, it basically acted as a no option SETVARIABLE command, saving it to "%s". -Moderator Caraamon Makdasi(talk) 20:44, 1 August 2010 (UTC)
- This is correct. In addition, despite it being listed as obsolete, it will still work. The command is simply a hold-over from Wizard where you can't set variables from within the script. Redundant would be a better word to describe it, since obsolete implies that it no longer functions. I.e. everything SAVE can do, SETVARIABLE can do. The main differences from SETVARIABLE is that the variable %s created by the save command only exists as long as the script is running and you can only SAVE a single variable at a time, any successive SAVE commands replacing the previous value. For example:
- SAVE HELLO
- ECHO %S
- SAVE GOODBYE
- ECHO %S
- When run, this would output:
- HELLO
- GOODBYE
- Hope that helps answer your question. If you want, you can also download the Wizard from play.net and there's a help section on scripting that has details about the SAVE command as well.--Evran 20:55, 1 August 2010 (UTC)
- This is correct. In addition, despite it being listed as obsolete, it will still work. The command is simply a hold-over from Wizard where you can't set variables from within the script. Redundant would be a better word to describe it, since obsolete implies that it no longer functions. I.e. everything SAVE can do, SETVARIABLE can do. The main differences from SETVARIABLE is that the variable %s created by the save command only exists as long as the script is running and you can only SAVE a single variable at a time, any successive SAVE commands replacing the previous value. For example:
If Statements
I want an if statement to be run off of a variable that is set in the script. Is there any way to use If_ on other variables than 1-9?
-SEGGERING (talk) 13:19, 13 November 2014 (CST)
- I haven't scripted in StormFront for years, but I think I remember enough of it's quirks to help you out.
- Re: If_#. This only works off of the command line variables, and only then at the level of 'does this variable exist?' StormFront does not have a more robust if/then statement, so you will have to use matches to emulate that.
- Re: Command line variables set within script. You don't actually need to use the '=' in there, which might be why it is not working for you. Try instead:
setvariable 1 Hello
- I can't recall if you can directly override certain system variables such as %0-9, %t, %s, etc., but it is possible that the above might work. One way to change the command line variables is to call the script from within the script, essentially restarting it. E.g.:
.myscript new variables go here exit
- The script will start from the beginning using the new variables. This doesn't work for all situations, and I don't know what your situation is, but it's possible to get creative with it.
- Re: emptying a variable. To empty a global variable, simply use:
setvariable <variable>
- without putting a value. If you want to delete the variable entirely, so that the variable name doesn't even exist anymore then use:
deletevariable <variable>
- Be aware that this might cause errors if the variable doesn't actually exist. It's usually not necessary to do this in most cases anyway.--ABSOLON (talk) 13:42, 13 November 2014 (CST)
Done
I think that pretty much covers it. Anyone else see something that's missing? -Moderator Caraamon Makdasi(talk) 02:16, 12 August 2013 (UTC)
It would be nice if the page called "How to Script" actually included instructions on how to script and not just how to write a script. -JT 12/2016