How to use IF commands to put act commands on command line 04/08/2013 04:00 PM CDT
I'm trying to write a script that will put act commands on the command line. Right now I have 5 actions and instead of writing a simple script for each one I figured that using the IF_ command would let me combine all the actions into one script but I can't decipher how to do it by reading http://www.play.net/playdotnet/play/stormfront_scripting.asp

Anyone have an idea how to do this?

Lets say it was a script named bird and I wanted to use this script to imitate a bird. Some of the actions would be flaps his wings like a bird; caws like a bird; and waddles in a circle like a bird.

I'm trying to set it up like this

IF_%1 goto %1:
Flaps:
put act flaps his wings like a bird
Caws:
put act caws like a bird
Waddles:
put act waddles in a circle like a bird

What I want to do is type .bird flaps and hit enter the script goes to the correct label, inputs the line then exits.

I just have no idea how to write this stuff.





Reply
Re: How to use IF commands to put act commands on command line 04/08/2013 04:33 PM CDT
IF_1 goto %1
Flaps:
put act flaps his wings like a bird
EXIT
Caws:
put act caws like a bird
EXIT
Waddles:
put act waddles in a circle like a bird
EXIT

That will do what you wanted it to do.

~James
Player of Septimius
Reply
Re: How to use IF commands to put act commands on command line 04/08/2013 05:56 PM CDT

Thanks, that worked great!
Reply
Re: How to use IF commands to put act commands on command line 04/08/2013 08:40 PM CDT
Well, yeah, okay...you could do it that way if you wanted to. Or you might try something like this:

#

#Super-Duper Bird Script of Doom v1.01 rev. A
#

if_1 goto BIRD%1

labelError:
echo Syntax: .bird [flaps|caws|waddles|destroys] <bow>
goto END

BIRDflaps:
put act flaps his wings like a bird.
goto END

BIRDcaws:
put act caws like a bird.
goto END

BIRDwaddles:
put act waddles in a circle like a bird.
goto END

BIRDdestroys:
put act unleashes merciless, unholy devastation like a bird. A bird of DOOM.
goto END

END:
if_2 pause 2
if_2 put bow
exit
Reply
Re: How to use IF commands to put act commands on command line 04/11/2013 11:39 AM CDT
That looks cool Heather. I'll try it.

How do you make those straight up and down lines. I don't have it on my keyboard and I bet there's a shortcut that will bring up other symbols but I'm not too savvy at this stuff.

Why did you put the labelerror: line?

to use this script would you type .birdflaps as one word? That's what the %1 connected to the word BIRD does right?
Reply
Re: How to use IF commands to put act commands on command line 04/11/2013 12:34 PM CDT
The up/down line (or the piping symbol) "|" should be on your keyboard. On mine it's shift-\ (backslash). It's not doing anything special here, that's just a common way of showing either/or options in syntax. Basically, parameters in brackets [] are required. If several options are separated by | it means you must pick one (and only one). Parameters in wedges <> are optional. So you can type ".bird flaps" or ".bird flaps bow". These were once commonly used, but probably not very well known these days. I mainly use them for my own benefit.

The errorLevel: line is a special label that catches any bad parameters given to the script. Ordinarily, if you mistyped ".bird flab" (for example) the script would immediately crash with an error. But if there's an errorLevel: label in the script, it will instead jump to that routine and continue from there. That's where I usually put an "echo" command to remind me how the script works. It's not necessary, but it helps quite a bit when you have scripts like this that can accept several different commands. If you forget the options, just type ".bird" and it will tell you what to do. Handy. :)

The reason I use BIRDflaps: and BIRDcaws: instead of simply Flaps: or Caws: isn't obvious in this simple script. It's a habit I developed because sometimes you'll want to use multiple branches with the same variable. For instance, if your script had another option to flap like a bat, you could use the same variable but send it to BATflaps: instead. It's inconsequential in this script, but sometimes simple scripts have a way of exploding into complicated one, so I like to hedge my bets. :)

In the end, though, my script doesn't do anything different than yours. It works just the same. If you type ".bird flaps" you still flap like a bird. I was just showing off. :)

~ Heathyr and friends
Reply
Re: How to use IF commands to put act commands on command line 04/11/2013 12:44 PM CDT
to use this script would you type .birdflaps as one word? That's what the %1 connected to the word BIRD does right?


No. You put a space like normal .bird flaps.

The %1 is combined with the label name. It is more dynamic that way.

The vertical lines should be SHIFT+BACKSLASH on your keyboard, assuming a regular old keyboard setup.

I do not see anything preset for labelError: but I am going to guess that is a default label for an error in your script attempting to go to a label that doesn't exist. So if you type .BIRD WHAT, there is an error and the echo will spell out the acceptable parameters for %1. %1 means simply the first parameter after the command.

--Zizzle
Reply
Re: How to use IF commands to put act commands on command line 04/27/2013 05:00 PM CDT
Ok guys, I've put this info to use and set it up the way Heather wrote it. The label error is great and I even added an < > option so that you can either CAW or CAW then BOW. Made some errors, but got it straightened out.

What I need to add is a more detailed help command so that if someone wants to get an explanation of what caws means they can type .BIRD CAWS HELP and this will display information on what a bird caw is. Right now I have a HELP variable and it provides a description of all the bird movements so if you do .bird help you get a lot of screen roll.

I'd like to have a single line description for each bird movement so you could type .bird caws help and it'll input THIS IS HOW A BIRD TALKS.

I am thinking you integrate this with the end label IF_2 and IF_3. but the way I have it right now it CAWS then displays the long explanation of all the actions in an endless loop.

I need to figure out how to do a third variable that will not perform any actions. Do you see what I mean? I can't figure this out by reading the webpage on Play.net. Not sure it this an or function or a counter or what.
Reply
Re: How to use IF commands to put act commands on command line 04/27/2013 05:28 PM CDT
Check out the SHIFT command, and see if it does what you want it to.

Doug
Reply