PDA

View Full Version : Quick scripting assistance



Maerit
05-01-2009, 12:14 AM
Is it possible to write a counter loop using stormfront scirpting? To elaborate, I need something that can count down from whatever the counter is at to zero and when it gets to zero it ends the loop.

Also, is there a way to hide "setvariable" displays when executing a script? I would love if the setvariable is hidden to simplify the display of some scripts I'm attempting to create.

Thanks in advance.

phantasm
05-01-2009, 12:36 AM
counter set 10

10:
9:
8:
7:
6:
5:
4:
3:
2:
1:
counter subtract 1
goto %c
0:
exit

Maerit
05-01-2009, 12:49 AM
counter set 10

10:
9:
8:
7:
6:
5:
4:
3:
2:
1:
counter subtract 1
goto %c
0:
exit

Ahh, if only it were that simple. The value of the counter is not static, it is dynamic. The script I was trying to create checks to see if I have herbs, and it stores variables that are referenced by the counter value. So, I might be missing 5 herbs one use of the script, or 3 herbs the next use... the counter will be the number of herbs I'm missing.

So, what I was trying to do was something like:

Display:
counter subtract
setvariable Echo %%Herb%c%
Echo %Echo
* If %c > 0 goto Display

How do I simulate that if statement? I could not figure it out after a long brain storming session. I guess the only thing I can think of would be to actually have my character - put say %c and do a matchwait until he says zero... Hrmm.

Is there anyway to match off Echo, so the text can be hidden?

BigWorm
05-01-2009, 02:05 AM
This is the helper script I used for value comparison in SF. It basically abuses the LabelError feature to compare two numerical values by repeatedly halving the difference until its reduced positive or negative one.


# Compares two numerical values
# If the first value is larger than the second one, returns 1
# If the two values are equal, returns 0
# If the first value is smaller than the second, returns -1

####### o3s header #######
GOTO Begin

Begin:
COUNTER SET %1%
COUNTER SUBTRACT %2%
GOTO %c%

0:
SETVARIABLE returnValue 0
GOTO End

1:
SETVARIABLE returnValue 1
GOTO End

-1:
SETVARIABLE returnValue -1
GOTO End

LabelError:
COUNTER DIVIDE 2
GOTO %c%

####### o3s footer #######
End:
SAVE %compareOnTerminate%
SETVARIABLE compareOnTerminate
put %s%
EXIT

Maerit
05-01-2009, 02:16 AM
Hrmm, that looks a lot smarter than what I did. Still trying to decipher the logic since SETVARIABLE compareOnTerminate has no value for the variable? Not sure I follow it entirely.

I just had my character say the counter value and matched on . or 1. If 1 shows up, then it terminates, otherwise it sees the ".", and continues to process.

Big problem with that is the mega waste of space and a virtual countdown that would baffle anyone standing nearby... Since my character is a warrior, I did a complicated math thingy so that he tries to juggle 1 or 0 weapons until the number is one, then he juggles 2... and at least no one else sees anything odd.

I'll see if I can figure out what you're doing later on tomorrow maybe. The script I wrote actually does work to check my container and figure out what herbs I am missing, then spits them out in on a single line for me. I just have to write in alternative herbs from various parts since it's only setup right now to test for landing herbs. That is more just tedius entry, not so much complicated logic with a very limited set of commands. Thanks for the help!

Oh, and I figured out how to turn off the setvariable display thingy... debug off.

Lord Orbstar
05-01-2009, 05:14 AM
My God you guys hurt my head. I wish I could decipher scripts. The only way I can use them is if I find them on the internet then cut and paste.

Maerit
05-01-2009, 10:10 AM
Hrmm, while I appreciate all the insight, it looks like my use of a in-game function works a little more like an actual dynamic loop

counter set 1

##Skipping herb functions (looks for herbs in your container then stores the
# name of the variable if the herb is not found in Herb%c (Herb1, Herb2,
# Herb3... ect ect)
##

BeginLoop:
counter subtract
setvariable Herb %%Herb%c%
setvariable Echo %Herb #Initializes the "array" which stores all missing herbs
Goto Loop

Loop:
counter subtract
match Loop You must specify
match End Please visit #can't exactly remember the term here
setvariable count %c #stores the current position in your herb list
setvariable Herb %%Herb%c% #updates to the current herb
setvariable Store %Echo, %Herb #needed to compile the text since you can't overwrite a variable with itself (i.e. setvariable Echo %Echo, Herb).
setvariable Echo %Store #Stores the complete string of missing herbs

#this basically does an if %c > 0 goto End; else goto Loop
counter set 2
counter subtract %count
put en %c #EN is a function in the game that works in front of a bank teller and requires a positive non-zero number.
matchwait

End:
Echo You are missing:
Echo %Echo

While the user sees a long scroll of text, no one else sees anything and it does successfully output a string of herbs. After this, I'll probably write a "restock" script which uses the saved variables and buys them from the store depending on the town you're in. I also plan to make the script town oriented so it will always check for landing herbs, then depending on your town entered into the argument, it will check for those healing items, and restock if you're missing anything.

Maerit
05-01-2009, 12:43 PM
I was sitting at work and just had a eureka moment on my simple counter loop...

Assuming %c is some number greater than 1, goto 0:

1:
Goto 0:

0:
counter subtract
setvariable count %c%
counter set 2
counter divide %count
setvariable goto %c
Echo %c
counter set %count%
Goto %goto%

2:
Echo Loop Complete

So, lets look at a case where you're missing 10 herbs in total.

Counter = 11 (because the function adds to the counter after every find), so you subtract to start and set the correct number of missing herbs. Now, count becomes 10, counter gets set to 2. Then counter does a division of 2/10, which equals .2, and is rounded 0. It stores 0 in %goto, and sets counter back to 10. Then goes back to 0, and repeats for 9-5. Once it gets to 5 herbs, the division value starts rounding to 1. No problem, 1 sends the script back to 0. Once it gets to 1 (the end) the value of the division will 2 (2/1), thus ending the loop!

Hurray, so simple... and yet my brain stewed on this way too long.

Lord Orbstar
05-03-2009, 05:57 AM
awesome!

Can you cut and paste the actual script you are putting into the Stormfront FE so i can shamelessly use your work?

Maerit
05-06-2009, 01:17 AM
awesome!

Can you cut and paste the actual script you are putting into the Stormfront FE so i can shamelessly use your work?

Here it is. Be sure any containers with herbs in them are open. You need to enter a town when calling this script so it can determine which herbs to tell you to buy.

If you enter Landing, it will look for only Landing herbs. If you enter Icemule, it will first check to see if you have the Icemule herb, if not, it will check to see if you have the Landing herb (since those are so common), and if not it will tell you which Icemule herb you need to buy.

EN, Solhaven, and River's Rest are all based on Landing herbs. Teras, Icemule, and Pinefar have their own set of herbs. I did not program in Zul Logoth.

I use this in conjunction with an herb healdown script I wrote. That script picks landing herbs first, then goes through the list for heal location of alternative herbs. It's nice to restock the stuff you're missing when you aren't keeping track of it all manually.

Just remember, when you run the script you have to type .<scriptname> then Landing, EN, Teras, Icemule, Pinefar, RR or Sol. I tried to put it in the comments, but it made the file .1 KB too big to upload...

Bobmuhthol
05-06-2009, 03:38 AM
Stop using StormFront. I wrote countless scripts that do what you're looking for with Jamus' engine + Wizard. It was essential to automating warrior guild partner tasks.

Drunken Durfin
05-06-2009, 12:47 PM
And where does one find the elusive JSE? I have looked/asked for it several times and still have no idea where to get a copy.

BigWorm
05-06-2009, 01:04 PM
And where does one find the elusive JSE? I have looked/asked for it several times and still have no idea where to get a copy.

Don't you already use lich? It's about infinity times better than JSE.

Drunken Durfin
05-06-2009, 01:11 PM
Yes, I use Lich.

However, if you are going to tell someone that they should use "Jamus' engine + Wizard" then they should either make sure it is readily available or point them in the right direction. If you can't get JSE, then telling someone that they should use it is pretty worthless advice.

Bobmuhthol
05-06-2009, 01:55 PM
I didn't tell anyone to use JSE; I said to stop using SF. Any engine that isn't made by Simutronics is good.


If you want JSE, toss me a couple hundred dollars to fix my hard drive. It's been sitting in my freezer since early 2007.

Drunken Durfin
05-06-2009, 02:42 PM
"I wrote countless scripts that do what you're looking for with Jamus' engine + Wizard" infers a solution to the OP's problem is available via such.

JSE is not readily available, and apparently neither are your scripts, so why even bother putting that out there? It is like showing a starving child a picture of a food and saying "bet you would like this, wouldn't you? Too bad it doesn't exist."

Try offering a solution to the problem rather than just screaming "Simutronics BAD!"

http://drunkendurfin.webs.com/bad.jpg

Renian
05-07-2009, 03:15 AM
http://drunkendurfin.webs.com/bad.jpg

Holy shit, that flash video is so fucking old. Silly Metallica.