Synthetic Reality Forums Post New Topic  New Poll  Post A Reply
my profile | directory login | register | search | faq | forum home

  next oldest topic   next newest topic
» Synthetic Reality Forums » Well of Souls » World Developers Forum » The basics of cookies (Page 2)

  This topic comprises 3 pages: 1  2  3   
Author Topic: The basics of cookies
Hal
Veteran Member
Member # 1426

Member Rated:
5
Icon 1 posted      Profile for Hal   Author's Homepage   Email Hal   Send New Private Message       Edit/Delete Post 
I should probally make up a little thing about arrays here, given the amout of times I've used Dan's name in vain concerning them..

Ehh, I'll get to it next week.

--------------------
Any and all velca will be added to your personal hahta in Angamando.

Posts: 711 | From: Chanhassen, Minnesota | Registered: Oct 2001  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
Yeah that'd be helpful..

I was thinking of adding them myself but I figured that'd be more advanced for cookies and I only wanted to explain the basics at that time. [Smile]

If I had time myself I'd do it myself, but feel free to add your 2 cents of thoughts. [Wink]

Silver

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 1 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
If you are going to use that post on the MOD command I'd also mention how handy the MOD function is when playing with the COUNTDOWN , and determining minutes and seconds. If you like I can throw in an easy example which shows how MOD can be used to great effect.

--------------------
Come ride with me through the veins of history,
I'll show you how god falls asleep on the job.

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
Avelon Hellfyre
Healthy Member
Member # 3600

Member Rated:
2
Icon 1 posted      Profile for Avelon Hellfyre   Author's Homepage   Email Avelon Hellfyre   Send New Private Message       Edit/Delete Post 
That'd be great. =D I couldn't think of an example where MOD actually serves a real purpose without giving away some of the things I'm using it for myself. [Wink]

--------------------
"I'm afraid you cannot enter with your weapons," the gate guard said. Avelon looked deep into the guard's eyes, was silent for a moment. He softly replied, "My blade? It is no weapon. It is a tool. I am the weapon."

Posts: 106 | From: the second star on the right and straight on 'til morning | Registered: Mar 2003  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 1 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
This is coming directly for the "Finishline" Scene of the P.U. obstacle course mini-game.
(cookie names changed for example purposes)

code:
IF XP @timeup
SET timeleft, "#<num.countDown>"
COUNTDOWN 0
SET timetaken , "600"
; The actual value set above should be the INITIAL countdown value set
SUB timetaken , "#<timeleft>"
SET minutes , "#<timetaken>"
DIV minutes , "60"
SET seconds , "#<timetaken>"
MOD seconds , "60"
N: You took #<minutes> minutes and #<seconds> seconds to finish.

Scripters could do some comparing to allow for better grammar in case of a 1 minute, or 1 second result, but hey, I promised to keep it simple. [Razz]

[ 05-11-2004, 07:03 PM: Message edited by: Sir Mj ]

--------------------
Come ride with me through the veins of history,
I'll show you how god falls asleep on the job.

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
Mysterious One
Veteran Member
Member # 5161

Member Rated:
2
Icon 1 posted      Profile for Mysterious One         Edit/Delete Post 
I thought this was supposed to be BASIC .

--------------------
Staring at a brick wall is like watching paint dry, only even more boring.

Posts: 549 | From: the depths of time | Registered: May 2004  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
You can't, you need to trigger @eventActorSpell1 for that. [Smile]

For other other questions about the @events check the script + mapping faq, most likely it got answered there already. [Wink]

Silver

[edit]
Use Control + F to search for trouble with actor events. It's on the 1st page.

[ 07-26-2004, 03:15 AM: Message edited by: IceFox/ Silver ]

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
How on earth can I make easily adaptable shop scenes?

Well, one way is this:

code:
 
ACTOR 1, "#<actorname>", #<actorskin>, 1, 5, 90
SET itemnumber, "1"
SET offsetID, "0"
SET offsetGP, "0"
GOTO @firstread
@loop
COMPARE itemnumber, totalitems
IF= @done
ADD offsetID, "3"
ADD offsetGP, "7"
ADD itemnumber, "1"
@firstread
SET_SUBSTR currentID, #<offsetID>, 3, #<items>
SET_SUBSTR currentGP, #<offsetGP>, 7, #<costs>
1: Item #<itemnumber> is %I#<currentID>.
1: Item costs #<currentGP>.
1: Would you like %I#<currentID>?
ASK 240
IF YES @attemptbuy
IF NO @loop
END
@attemptbuy
N: Attempting to buy item.
IF G#<currentGP> @continuebuy
1: You seem to be low on funds.
1: Try that item again later.
1: How about the next item?
GOTO @loop
END
@continuebuy
SET token, 0
COMPARE #<token>, "0"
IF= @continuetest
GOTO @error
@continuetest
ADD token, "1"
IF= @continuetest2
GOTO @error
@continuetest2
TAKE G#<currentGP>
GIVE I#<currentID>
1: Thank you for your business.
1: Would you like to continue shopping?
ASK 240
IF YES @loop
1: Thank you for your business.
WAIT 4
GOTO EXIT
END
@done
1: I have no further items.
1: Would you like me to repeat the list?
ASK 240
IF YES @repeat
1: Thank you for your business.
WAIT 4
GOTO EXIT
END

Then, you have a link leading to a scene. Inside that scene, it sets five cookies; "actorname", "actorskin", "total", "items", and "costs". The cookie "total" should contain the total number of items in the list (3, 4, more?), "items" contains item IDs for the items sold, in 3-digit numbers (include zero placeholders if the item number is less than one hundred!), and "costs" contains item prices, 7 digits long, for each item, in corresponding order with their item. The scene then includes shopscene.txt or whatever you called the file the above script is in. Anyway, let's explore how this script works, shall we?

The first part is this:

code:
	ACTOR 1, "#<actorname>", #<actorskin>, 1, 5, 90
SET itemnumber, "1"
SET offsetID, "0"
SET offsetGP, "0"
GOTO @firstread
@loop
COMPARE itemnumber, totalitems
IF= @done
ADD offsetID, "3"
ADD offsetGP, "7"
ADD itemnumber, "1"
@firstread

This section of code SETs some new variables, or resets them from a previous use. It then skips the looping part of the script where it readies itself to read cookies again. When the script loops around again, it will add certain values to read the next variable in the list. It also checks to see if we have gone through all the items, to prevent errors.

The second part, the heart of the script is this:

code:
	SET_SUBSTR currentID, #<offsetID>, 3, #<items>
SET_SUBSTR currentGP, #<offsetGP>, 7, #<costs>

This very small and important section of script does the hard work of the shop script. It reads the variables "items" and "costs" as set in the beginning of the scene. The SET_SUBSTR command SETs the first cookie (We'll use the first line of script as our example. It would set "currentID".), starting, in this case, #<offsetID> characters in, reading the first 3 characters it finds from #<items>, in this case, and setting the three characters it read to "current ID". This means if "items" contained this string: 012098134, and offsetID was 0, as it is the first time the scene runs, it would set "currentID" to 012.

This leads us to our next piece of script:

code:
	1: Item #<itemnumber> is %I#<currentID>.
1: Item costs #<currentGP>.
1: Would you like %I#<currentID>?
ASK 240
IF YES @attemptbuy
IF NO @loop
END
@attemptbuy
N: Attempting to buy item.
IF G#<currentGP> @continuebuy
1: You seem to be low on funds.
1: Try that item again later.
1: How about the next item?
GOTO @loop
END

In this piece of script, the actor we defined in the beginning asks the host if they want to buy the item after listing the item's name and cost. If they say Yes, it checks to see if they have enough money, then goes to the label @continuebuy. If they say No, it loops back to get the next item.

The next part of the script is this:

code:
@continuebuy
SET token, 0
COMPARE #<token>, "0"
IF= @continuetest
GOTO @error
@continuetest
ADD token, "1"
IF= @continuetest2
GOTO @error
@continuetest2
TAKE G#<currentGP>
GIVE I#<currentID>
1: Thank you for your business.
1: Would you like to continue shopping?
ASK 240
IF YES @loop
1: Thank you for your business.
WAIT 4
GOTO EXIT
END
@done
1: I have no further items.
1: Would you like me to repeat the list?
ASK 240
IF YES @repeat
1: Thank you for your business.
WAIT 4
GOTO EXIT

This tests to make sure that a player's files aren't read-only, which would allow them to get any item for no cost. It then takes the gold, gives the item, and returns to the rest of the item list. This is where the script goes to when all the items are asked about.

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 5 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
quote:
(include zero placeholders if the item number is less than one hundred!)
- Two questions my learned friend.

Why the need for placeholders?

Did you know that normal "cookies" let you use leading zeros? (If thinking otherwise is why you chose to use SET_SUBSTR for the workhorse variables of the script)

Happy New Year btw. [Smile]

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
Because it reads 3 numbers at a time out of the list of item IDs. So, if you have, say, 3 items; number 23, number 456, and number 128, and you didn't use placeholders (the string would then be "23456128"), it would read as: Item 234, 561, and 280. But, if you used the placeholders, as directed, you would set the string as "023456128" and it would read them correctly.

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
Is there a cookie that reads if a player is a pker or nonpker?

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
Not a cookie, but there is an IF command.

quote:
P0 true if player is a PLAYER KILLER (p-zero)
Pnn true if player is a PLAYER KILLER *and* has killed other players at least nn times.

Silver

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Mad
Verbose Member
Member # 5460

Member Rated:
3
Icon 1 posted      Profile for Mad   Author's Homepage   Email Mad   Send New Private Message       Edit/Delete Post 
How can I make sure that a player will not use some characters in his answer?

May seems silly but that may be usefull in some scripts for a personnal scene for exemple, like : 1: Hello dear world dev, what item do you want? / ask 30 / HOST_GIVE I#<lastAsk>

This is also a pretext to show how the SET_LEN and SET_SUBSTR commands work.

Here we go, here is the code :

code:
 ASK 300
SET numbers, "0123456789"
SET_LEN len, #<lastAsk>
@check
SUB len, 1
COMPARE #<len>, -1
IF= @next
SET_SUBSTR symbol, #<len>, 1, #<lastAsk>
STRSTR #<numbers>, #<symbol>
IF> @check
N: The answer is not valid.
END

@next
; blablabla

In this case we want to make sure that the answer only contains numbers (no letter nor space nor punctuation).

The idea is to extract every character contained in the answer, and to compare them one by one with the list of the characters that the player is allowed to use.

So we need first to set this list ; here it is the list of the numbers : SET numbers, "0123456789".

Then we need to loop the script x times, x being the number of characters that are in the answer, and every time it will check a new character (it will start with the last one, then the last but one, etc). Although, we need to know how many times to check, to determine when the script must stop.

We do that with the SET_LEN command : SET_LEN len, #<lastAsk> ; we set a new cookie, 'len', with the lengh aof the value of lastAsk as its own value (aka : the number of characters of the answer).

Now we need to extract every character from the answer one by one and to set a new cookie with this character as a value to check if it can be found in the list of the characters allowed. We will use the SET_SUBSTR command for that : SET_SUBSTR symbol, #<len>, 1, #<lastAsk> ; here we set a new cookie : symbol, with as a value the #<len>th letter of the cookie #<lastAsk> (actually #<len> there is the number of the character we start with, and '1' the number of characters copied).

BUT the first character is the character 0 for the SET_SUBSTR command, while he is the character 1 with #<len>, so we need to sub 1 to 'len' to make them match : SUB len, 1

Then all what we have to do is to use the STRSTR command to chack if the character extracted in in the list of the characters allowed : STRSTR #<numbers>, #<symbol> / IF> @check . If it is then we start again with the previous letter ; if not, the scripts stop : the answer was not valid.

When we check again, we SUB 1 to #<len> again so it will correspond to the previous letter ; we compare before checking again ; when the value = -1, then there is no symbol left and the script can continue.

NB: This script couldn't work if we used another cookie than lastAsk and if the value of this cookie was : "" (ie : nothing) ; but as the cookie is lastAsk, we are sure that this is not the value of the cookie.

[ 02-13-2005, 02:19 PM: Message edited by: Mad ]

--------------------
athelias.biz - Forums - Worlds' List

Posts: 1812 | From: Moe's | Registered: Jul 2004  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
I'm working on an "item sorter" script, where the purpose is to read each item as a cookie, and sort each item according to class. What I'm having trouble with is how to get the different item cookies to work. I don't want them to read an item that the hero is holding, but rather the item another cookie is telling it what to read.

Would it work like this, where #<number> is what number I'm up to in setting it

Set classitem#<number>, #<#<number>.class>

Now I need to figure out how to sort cookies according to class...

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
No, Hesacon, but this MIGHT work:

code:
 Set classitem#<number>, "#<#<number>.class>"  

By the way, that seems kind of convoluted. Any chance you're missing some way to simplify it?

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Mad
Verbose Member
Member # 5460

Member Rated:
3
Icon 1 posted      Profile for Mad   Author's Homepage   Email Mad   Send New Private Message       Edit/Delete Post 
You may need to use pointers, Hesa, when checking the value of the cookies as well :

Instead of COMPARE #<A#<B>>, x

Try,
SET C, #<A>#<B>
COMPARE *#<C>

Some good infos by Silver when answering my questions in an old topic called "Random Question". Maybe you want to check it out.

Posts: 1812 | From: Moe's | Registered: Jul 2004  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
I was talking to MJ last night about it and have something that works.

code:
SET item.id, "#<counter1>"
SET itemclass#<counter1>, "#<item.class>"

Now I need to come up with a way to combine all items of the same class onto a list, and seperate all the items that don't exist, since all those have class0 as do the potions...

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
quote:
Now I need to come up with a way to combine all items of the same class onto a list, and seperate all the items that don't exist, since all those have class0 as do the potions...

Ehm... I thought I already did exactly that with 1 of proxbeta item tracer scripts. Might be worth your while to check out how I did it there.
I'm fairly sure that I build in protections against potions and stuff and it could just spit out a list by pretty much any stat you want.

Just check out proxbeta's item tracer script, it's to late for me at the moment (3:24 am) to comment more on it then that. [Smile]

Silver

[ 07-16-2005, 06:27 PM: Message edited by: IceFox/ Silver ]

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Mad
Verbose Member
Member # 5460

Member Rated:
3
Icon 1 posted      Profile for Mad   Author's Homepage   Email Mad   Send New Private Message       Edit/Delete Post 
Cookie pointers

I have some time to spare and can't find a post about this here, so here we go.

What a cookie pointer is.

From a graphical point of view, pointers will use this symbol: *, put before the normal #<> to check the value of the cookie. You all know, I hope, that if A is the name of the cookie, #<A> will return its value (and if you don't I really suggest you to read the first post of this topic first). *#<A> will return the value of the cookie whose name is the value of A.

Let's be more concrete. We have 2 cookies:
code:
 SET gold, 2600
SET 2600, rich

#<gold> will be read by WoS as "2600", but if you write *#<gold>, then WoS will return the value of the value of gold, ie: the value of the cookie 2600, ie: "rich"

Not that hard up to know, but...

What the point of using pointers?

Pointers will be usefull in complex scripts. I will try to give you some examples to show you some of the great things you can do with them.

Example 1. I want to write a useful script for world devs to allow myself to set my own cookies on my char, and check the value of existing cookies. First, we pose an actor that asks the name of the cookie, and set it thanks to the lastAsk trick:

code:
 ACTOR 1, etc
1: name of the cookie you want to set?
ASK 30
; here I should compare if the player has said something or not
; but well... that's just an exercise
SET cookiename, #<lastAsk>
1: Value of the cookie?
ASK 30
SET #<cookiename>, #<lastAsk>

OK, now we want to check the value of a cookie:
code:
 1: Name of the cookie?
ASK 30
1: The value of the cookie #<lastAsk> is *#<lastAsk>

See how it works? But we can use cooke pointers for more complex scripts:

Example 2. I want to make a generic script for all the healing scenes of my world, that will allow the player to kill the healer and replace him by another actor if you do so. Weird, yes, but pretty complex. I will not write the whole script and post how to make a random name generators as I did in Athelias for example; I'll only focus on the basis.

To do this, we will need to set different cookies for every scene to determine the name of the current actor, his skin, his pose, etc. And the only thing that changes in ALL the scenes is the scene ID itself. Therefore, if we use it as a part of the name of those cookies, we can be sure to have different cookies. Let's do it. We will use the following cookies: name#<scene.id>, skin#<scene.id>, and pose#<scene.id>. Of course they will be read as name22, skin22 and pose22 for example if the player is in scene 22. We will not change the coords x and y in this example.

First we need to check if the player has already had cookies set for the actor skins/pose/etc (ie if it's the first time he goes to this scene or not). Otherwise, no actor will show up. But here appears the first problem. We don't know the scene ID as it is a generic script, and STRCMP #<skin#<scene.id>> does not work. We can't write: *skin#<scene.id> either as the pointers have to be immediatly followed by "#<>". So we need to set a new cookie, let's call it "temp.skin", whose value will be skin#<scene.id>. Then we can compare:

code:
 SET temp.skin, skin#<scene.id>
STRCMP, *#<temp.skin>, ""
IF= @firsttime

..and we do the same with the other cooies. We have to use pointers here or WoS will check the value of temp.skin (ie: skin22 if we are in scene 22) instead of the value of the cookie scene22 itself.

OK we are done: we are sure that it is not the first time the player comes, so we can pose the actor:

code:
 ACTOR 1, *#<temp.name>, *#<temp.skin>, *#<temp.pose>, 25, 90  

We've just made a fully abstract actor.

Now, I said that we wanted to allow the player to kill the healer and replace him by another actor. Very easy now:

code:
 @eventActorAttack1
; The actor is dead, we have to replace his old attributes.
; To make the example easier, we will assume
; that all the actors skins name are "humanNN", 0>NN>100
; I'll only write the script for the skin name
; For some reasons (maybe I am wrong here), SET A, something%R100
; doesn't seem to work, while SET A, %R100 definitly does,
; so we have to do this:
SET temp.number, %R99
SET skin#scene.id>, human#<temp.number>

Easy, eh! Add a random name and determine the pose and you're done.

Example 3. We want to get infos about all the monsters fought by the player in the last fight. We'll have to use the cookies monster.lastFightIdNN, monster.lastFightCount, and monster.id. First we need to know how many monsters were present to know how many times we will have to loop the script: we will set a cookie with this value, and SUB 1 to it whenever the script will be looped, when its value will be 0, we'll be done:

code:
 @loop
SET monsters.number, #<monster.lastFightCount>
; monster.lastFightCount is read only so we have
; to use another cookie to do math with it
; Now we need to check if there were actually monsters in the last fight
; or if we haven't already checked all the monsters
; (remember that this script is looped)
COMPARE, #<monsters.number>, 0
IF= @done
; We are now aure that there are monsters left.
SET temp.ID, monster.lastFightId#<monsters.number>
; We are about to check the ID of the last monster fought
; (the #<monsters.number>th monster)
SET monster.id, *#<temp.ID>
N: The name of the #<monsters.number>th monster fought is #<monster.name>
N: Its level is #<monster.level>
; etc. etc.
; Now we SUB 1 to monsters.number and loop the script
; to check the stats of the last but 1 monster.
SUB monsters.number, 1
GOTO @loop

@done
N: No monster left.
END

That's all [Smile]

I hope this post helped a bit and that you're now going to love cookie pointers...

-------------------------------------------------

This post was originally posted on athelias.com BBs.

[ 08-08-2005, 04:13 AM: Message edited by: Mad ]

--------------------
athelias.biz - Forums - Worlds' List

Posts: 1812 | From: Moe's | Registered: Jul 2004  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
Mind if I add that to the HRC?

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
I don't think anybody would mind, you could always give credits to the original poster and then it'd definately be okay. [Smile]

Silver

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Mad
Verbose Member
Member # 5460

Member Rated:
3
Icon 1 posted      Profile for Mad   Author's Homepage   Email Mad   Send New Private Message       Edit/Delete Post 
I don't mind - and you know I wouldn't mind either if I was not credited [Wink]

NOTE: I may edit my last post sometimes - there are still many things to say on the subject.

[ 08-09-2005, 12:42 AM: Message edited by: Mad ]

--------------------
athelias.biz - Forums - Worlds' List

Posts: 1812 | From: Moe's | Registered: Jul 2004  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
You have the tutorial the way you like it, Mad? I'd like to add it to the site.

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
By the way, Hesacon, I edited one of my earlier posts, about the file extensions, to add a question mark. It was bugging me. Would you mind adding the same to your site?

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Mad
Verbose Member
Member # 5460

Member Rated:
3
Icon 1 posted      Profile for Mad   Author's Homepage   Email Mad   Send New Private Message       Edit/Delete Post 
Yeah, yeah, add it [Wink]

PS - I let you check for typos [Embarrassed]

[ 08-15-2005, 05:17 AM: Message edited by: Mad ]

--------------------
athelias.biz - Forums - Worlds' List

Posts: 1812 | From: Moe's | Registered: Jul 2004  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 1 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
Nice explaination there Mad. It's good to see practical examples to accompany the information being relayed.

If I were to make 1 suggestion though it would be to add a warning to new developers that using arrays and pointers is an advanced technique and has the ability to do just as much damage to a world as it has the ability to add functionality and dynamism. Personally I'd recommend a comprehensive knowledge of QUEST + intense experience with custom cookies and/or previous experience with arrays in an alternate scripting language before trying to create scripts of this nature.

Hesa, did we find the way to make that list? I know we cracked the first part of the problem but I was pretty certain that we found a method for the lists also. [Confused]

--------------------
Come ride with me through the veins of history,
I'll show you how god falls asleep on the job.

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
Eh.. yeah.. I always intended to write a thread called "Advanced usage of cookies" or something like that. That topic would deal with cookie arrays then and try to explain it as well as I can. I never seem to have any time for it thesedays though, but if any world developer is willing to make a great thread about it then I'll sticky it for him.

Basicly you use cookie arrays as a sort of macros. When you have to run the same script a lot but with small changes in it each time then cookie arrays are extremely useful. The small changes are handled by the cookie arrays.

I'd try to come up with some sort of example to clarify the previously said, but it's 3 am already and my brains aren't exactly working anymore.

Anyways, if anybody wants to make a good thread about it with lots of explaining and examples then in it will get stickied for everybody else to view. [Smile]

Silver

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
quote:
Hesa, did we find the way to make that list? I know we cracked the first part of the problem but I was pretty certain that we found a method for the lists also.
I think I had a start to it. I had no idea pointers existed since I never saw it mentioned in the FAQs of this forum. With a little experiment, I think they might prove able to able to do what we need to do with the sorter.

I also have a rough outline for a mutating encryption code with the pointers.

---

Whatever is NOT in the FAQ and can be done should be added, the whole idea of my site is for people to submit tutorials on how to do different things that aren't always common knowledge.

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
Like cookie search features? They aren't in the FAQ.

I have a script somewhere, the Terminal, that allows you to create text messages, store, display, and search through them. The search feature will search all ten potential stored messages for an inputed string. This is the code if you'd like to see it:

code:
 SCENE 278, blue, CUT
BKGND #<background>
N: Input Search Keyword Now.
SET letters, "0"
SET oldtext, ""
SET oldtext1, ""
ACTOR 1, "A", abc#<textcolor>, 1, 30, 85
ACTOR 2, "B", abc#<textcolor>, 2, 53, 90
ACTOR 3, "C", abc#<textcolor>, 3, 43, 90
ACTOR 4, "D", abc#<textcolor>, 4, 40, 85
ACTOR 5, "E", abc#<textcolor>, 5, 37, 80
ACTOR 6, "F", abc#<textcolor>, 6, 45, 85
ACTOR 7, "G", abc#<textcolor>, 7, 50, 85
ACTOR 8, "H", abc#<textcolor>, 8, 55, 85
ACTOR 9, "I", abc#<textcolor>, 9, 62, 80
ACTOR 10, "J", abc#<textcolor>, 10, 60, 85
ACTOR 11, "K", abc#<textcolor>, 11, 65, 85
ACTOR 12, "L", abc#<textcolor>, 12, 70, 85
ACTOR 13, "M", abc#<textcolor>, 13, 63, 90
ACTOR 14, "N", abc#<textcolor>, 14, 58, 90
ACTOR 15, "O", abc#<textcolor>, 15, 67, 80
ACTOR 16, "P", abc#<textcolor>, 16, 72, 80
ACTOR 17, "Q", abc#<textcolor>, 17, 27, 80
ACTOR 18, "R", abc#<textcolor>, 18, 42, 80
ACTOR 19, "S", abc#<textcolor>, 19, 35, 85
ACTOR 20, "T", abc#<textcolor>, 20, 47, 80
ACTOR 21, "U", abc#<textcolor>, 21, 57, 80
ACTOR 22, "V", abc#<textcolor>, 22, 48, 90
ACTOR 23, "W", abc#<textcolor>, 23, 32, 80
ACTOR 24, "X", abc#<textcolor>, 24, 38, 90
ACTOR 25, "Y", abc#<textcolor>, 25, 52, 80
ACTOR 26, "Z", abc#<textcolor>, 26, 33, 90
ACTOR 27, ".", abc#<textcolor>, 27, 68, 90
ACTOR 28, "!", abc#<textcolor>, 28, 73, 90
ACTOR 29, "Space", abc#<textcolor>, 30, 77, 80
ACTOR 30, "Backspace", abc#<textcolor>, 31, 80, 85
ACTOR 31, "View Text", abc#<textcolor>, 32, 75, 85
END
@eventActorClick1
SET currentletter, "01"
GOTO @addletter
END
@eventActorClick2
SET currentletter, "02"
GOTO @addletter
END
@eventActorClick3
SET currentletter, "03"
GOTO @addletter
END
@eventActorClick4
SET currentletter, "04"
GOTO @addletter
END
@eventActorClick5
SET currentletter, "05"
GOTO @addletter
END
@eventActorClick6
SET currentletter, "06"
GOTO @addletter
END
@eventActorClick7
SET currentletter, "07"
GOTO @addletter
END
@eventActorClick8
SET currentletter, "08"
GOTO @addletter
END
@eventActorClick9
SET currentletter, "09"
GOTO @addletter
END
@eventActorClick10
SET currentletter, "10"
GOTO @addletter
END
@eventActorClick11
SET currentletter, "11"
GOTO @addletter
END
@eventActorClick12
SET currentletter, "12"
GOTO @addletter
END
@eventActorClick13
SET currentletter, "13"
GOTO @addletter
END
@eventActorClick14
SET currentletter, "14"
GOTO @addletter
END
@eventActorClick15
SET currentletter, "15"
GOTO @addletter
END
@eventActorClick16
SET currentletter, "16"
GOTO @addletter
END
@eventActorClick17
SET currentletter, "17"
GOTO @addletter
END
@eventActorClick18
SET currentletter, "18"
GOTO @addletter
END
@eventActorClick19
SET currentletter, "19"
GOTO @addletter
END
@eventActorClick20
SET currentletter, "20"
GOTO @addletter
END
@eventActorClick21
SET currentletter, "21"
GOTO @addletter
END
@eventActorClick22
SET currentletter, "22"
GOTO @addletter
END
@eventActorClick23
SET currentletter, "23"
GOTO @addletter
END
@eventActorClick24
SET currentletter, "24"
GOTO @addletter
END
@eventActorClick25
SET currentletter, "25"
GOTO @addletter
END
@eventActorClick26
SET currentletter, "26"
GOTO @addletter
END
@eventActorClick27
SET currentletter, "27"
GOTO @addletter
END
@eventActorClick28
SET currentletter, "28"
GOTO @addletter
END
@eventActorClick29
SET currentletter, "30"
GOTO @addletter
END
@eventActorClick30
SET_LEN textlength, #<oldtext>
SUB textlength, "2"
SET midtext, "#<oldtext>"
SET_SUBSTR midtext, 0, #<textlength> #<oldtext>
SET oldtext, "#<midtext>"
SET newtext, "#<oldtext>"
END
@eventActorClick31
SET newtext, "#<oldtext>98"
SET oldtext, "#<newtext>"
SET message, "#<oldtext>"
GOTO SCENE 279
END
@addletter
COMPARE #<letters>, "0"
IF= @isfirstletter
IF> @continueletteradd
@isfirstletter
SET oldtext, "#<currentletter>"
ADD letters, "1"
END
@continueletteradd
SET newtext, "#<oldtext>#<currentletter>"
SET oldtext, "#<newtext>"
ADD letters, "1"
END

;xxxxxxxx--------xxxxxxxx <oxxxxx|==============> _.#*'*#._ <==============|xxxxxo>

SCENE 279, blue, CUT
BKGND #<background>
@reset
FX 0
WEATHER 0
SET letterID, "0"
SET page, "1"
SET offsetletter, "0"
SET actorx, "15"
SET actory, "15"
SET actorID, "1"
@loop
SET_SUBSTR letterID, #<offsetletter>, 2, #<message>
COMPARE #<letterID>, "98"
IF= @okbutton
ACTOR #<actorID>, "letter", abc#<textcolor>, #<letterID>, #<actorx>, #<actory>
WAIT 0.1
COMPARE #<actorID>, "30"
IF= @nextpage
ADD actorID, 1
ADD actorx, 5
COMPARE #<actorx>, 85
IF= @adjusty
@backadjust
ADD offsetletter, "2"
GOTO @loop
@end
END
@adjusty
SET actorx, "15"
ADD actory, "5"
GOTO @backadjust
@nextpage
SET_SUBSTR testletter, 64, 2, #<message>
COMPARE #<testletter>, "98"
IF= @okbutton
ACTOR 31, "Next Page", abc#<textcolor>, 33, 85, 20
END
@eventActorClick31
ACTOR 1, "Previous Page", abc#<textcolor>, 31, 15, 15
SET subactor, "2"
@subloop
ACTOR #<subactor>, mirror, 1, -100, -100
ADD subactor, "1"
COMPARE #<subactor>, "32"
IF= @breaksubloop
GOTO @subloop
@breaksubloop
ADD page, "1"
SET actorx, "20"
SET actory, "15"
SET letterID, "32"
SET actorID, "2"
ADD offsetletter, "2"
GOTO @loop
END
@eventActorClick1
COMPARE #<page>, "1"
IF> @pageback
END
@pageback
SUB page, "1"
COMPARE #<page>, "1"
IF= @ispage1now
SET actorx, "20"
SET actory, "15"
SUB letterID, "57"
SET actorID, "2"
SUB offsetletter, "114"
SET subactor2, "2"
@subloop2
ACTOR #<subactor2>, mirror, 1, -100, -100
ADD subactor2, "1"
COMPARE #<subactor2>, "32"
IF= @breaksubloop2
GOTO @subloop2
@breaksubloop2
GOTO @loop
END
@ispage1now
SET actorx, "15"
SET actory, "15"
SET letterID, "0"
SET actorID, "1"
SET offsetletter, "0"
SET subactor3, "1"
@subloop3
ACTOR #<subactor3>, mirror, 1, -100, -100
ADD subactor3, "1"
COMPARE #<subactor3>, "32"
IF= @breaksubloop3
GOTO @subloop3
@breaksubloop3
GOTO @loop
END

@okbutton
N: Done Displaying.
ACTOR 0, "OK" abc#<textcolor>, 34, 50, 50
END
@eventActorClick0
@returntomenu
N: Search now?/Back to Keyboard/Exit?
@askagain
N: Answer Search, Back, or Exit.
ASK #<asktime>
IF QSearch @finish
IF QBack @back
IF QExit @exit
N: Sorry, invalid option.
N: Remember to capitalize.
GOTO @askagain

@finish
SET_LEN textlength, #<message>
SUB textlength, "2"
SET midtext, "#<message>"
SET_SUBSTR midtext, 0, #<textlength> #<message>
SET message, "#<midtext>"
SET newtext, "#<message>"
SET searchitem, "#<newtext>"
N: Search Beginning now.
WAIT 0.1
GOTO SCENE 280
END

@back
GOTO SCENE 279
END

@exit
GOTO SCENE 271
END

;xxxxxxxx--------xxxxxxxx <oxxxxx|==============> _.#*'*#._ <==============|xxxxxo>

SCENE 280, blue, CUT
BKGND #<background>
N: Search Beginning.
SET results, "0"
SET searchoffset, "0"
SET slotnumber, "1"
SET findstring, "mslot#<slotnumber>"
SET currentstring, "*#<findstring>"
SET_LEN searchlength, #<searchitem>
@loop
WAIT 0.1
SET_SUBSTR searchtest, #<searchoffset>, #<searchlength>, #<currentstring>
COMPARE #<searchitem>, #<searchtest>
IF= @foundresult
SET findlast, #<searchoffset>
SET sublength, #<searchlength>
SUB sublength, "2"
ADD findlast, "#<sublength>"
SET_SUBSTR endtest, #<findlast>, 2, #<currentstring>
COMPARE #<endtest>, "99"
IF= @nextstring
ADD searchoffset, "2"
GOTO @loop
END
@foundresult
ADD results, "1"
SET cookiename, "result#<results>"
SET #<cookiename>, "#<slotnumber>"
N: Slot #<slotnumber> contains a match.
N: Keep Searching?
ASK #<asktime>
IF Qno @done
@nextstring
ADD slotnumber, "1"
COMPARE #<slotnumber>, "10"
IF= @done
SET searchoffset, 0
SET findstring, "mslot#<slotnumber>"
SET currentstring, "*#<findstring>"
GOTO @loop
END
@done
COMPARE #<results>, "0"
IF= @noresults
SET resultcount, "1"
@subloop
WAIT 0.1
COMPARE #<resultcount>, #<results>
IF> @end
SET currentresult, "result#<resultcount>"
N: Result #<resultcount> is in slot *#<currentresult>.
ADD resultcount, "1"
GOTO @subloop
END
@end
N: All Results stated.
GOTO @actordraw
END
@noresults
N: No matches found.
GOTO @actordraw
END
@actordraw
ACTOR 0, "OK" abc#<textcolor>, 34, 50, 50
END
@eventActorClick0
@returntomenu
N: View Stored Message/Exit?
@askagain
N: Answer View or Exit.
ASK #<asktime>
IF QView @view
IF QExit @exit
N: Sorry, invalid option.
N: Remember to capitalize.
GOTO @askagain
END

@view
GOTO SCENE 272
END

@exit
GOTO SCENE 271
END
END

It's quite long, three scenes. The stuff you really want is in the last scene. All three scenes are setup for the searching. The search is done by comparing the string (Numbers instead of letters, actually) to the current string being read. It then shifts a character onward, checks again, and continues until the end of the stored message. It's even functional!

Anyway...

What are these arrays I keep hearing about? I've never used one in my scripting to my knowledge, are they similar to a matrix in any way?

[ 08-16-2005, 11:09 PM: Message edited by: Flamelord ]

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 1 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
Name your scripting language of choice and I'll explain arrays in a non-wos sense for you....so long as your language of choice is either Javascript, VB or C. [Wink]

[EDIT] I'd add in a generic "Who is Arrays daddy and what does he do?" spiel but a language to script examples in would make the information that much more meaningful. [END EDIT]

[ 08-17-2005, 12:16 AM: Message edited by: Sir Mj ]

--------------------
Come ride with me through the veins of history,
I'll show you how god falls asleep on the job.

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
IceFox/ Silver
Moderator
Member # 2200

Icon 1 posted      Profile for IceFox/ Silver   Author's Homepage     Send New Private Message       Edit/Delete Post 
From the WoS cookie list:

quote:
Cookie Pointers
To implement arrays and other fun things, you need a cookie which "points to" another cookie. You can achieve this goal via the asterisk (*) character.

If:

#<cookieName>

gives you the contents of the cookie called cookieName, then:

*#<cookieName>

gives you the contentes of the cookie whose name is inside the cookie called cookieName.

More concretely:

SET dataCookie, "Bill"
SET labelCookie, "dataCookie"
1: hello, my name is *#<labelCookie>

I hope that made sense. I wrote it down better somewhere else, but for some reason I can't seem to find it. If you ever see any documentation that says to use @ instead of *, then let me know. It was a mistake to use @ (in A70) and I changed it to * for A71.

They go by different names, but in WoS they're called cookie pointers instead of arrays. Same thing other name. [Smile]

Silver

--------------------
Silver
RoT's Homepage - ProxBeta

Posts: 7098 | From: The Netherlands | Registered: May 2002  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 1 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
uhh Yes and No. While they share a close relation pointers and arrays are totally different things.

A pointer in any scripting language (QUEST included) is merely an indicator as to what type of data you are about to read in your code. In WoS terms they point to a "second level/ second generation/ second dimension/ floating/ yes geeks globally have that many names for it and more" cookie(variable) which is one of Uncky Dans kind way of letting us use simple scripting to 'tap into' arrays.
The pointer as its name suggests simply points to whatever specific data we seek to obtain where rather than looking at the value of a cookie, we are searching for the value of a cookie the name of which is the value of the cookie we are pointing to. Think of a pointer as the pick in the Opal mine, where the array is the stash of Opals.

An array is a group of variables (cookies in QUEST) that fit within the same general data type. I'm plucking this example of an array from one of my ramblings at the Hesacon Resource Center. Note that within the type of array I adapted to WoS script, no pointers are required as I use a few recycled cookies to swing the loop around... and also cut down on raw code. [Wink]
code:
; Football Team Picker
SET Num.PlayerWeAreUpTo , "1"
GOTO @picknextname
END
@picknextname
GOTO option%R20
; Remember we are picking from a list of 20 names.
END
@option1
COMPARE #<PickedOption1> , "1"
IF= @picknextname
; We don't want duplicates
SET Str.PlayerName , "Player1"
SET PickedOption1 , "1"
WAIT 0.1
GOTO @setupteam
END
...up to
@option20
COMPARE #<PickedOption20> , "1"
IF= @picknextname
; We don't want duplicates
SET Str.PlayerName , "Player20"
SET PickedOption20 , "1"
WAIT 0.1
GOTO @setupteam
END
@setupteam
SET Player#<Num.PlayerWeAreUpTo> , "#<Str.PlayerName>"
ADD Num.PlayerWeAreUpTo , "1"
COMPARE #<Num.PlayerWeAreUpTo> , "11"
IF>@Done
WAIT 0.1
; We only want 11 on a Soccer team!!
GOTO @picknextname
END
@Done
N: Your team is #<Player1>, #<Player2> ... up to #<Player11>.
WAIT 0.1
N: Nice team you have there.
END

In all reality, we have many avenues open by way of implementing arrays and multi-dimensional data into WoS (Thanks Dan [Smile] ) worlds. That's just one of them, and I won't say there is a best way to do it as it all depends on the goal of the script.

P.S. Hal, if you're out there you are only 14 months late on your 'next week' post. [Razz]

--------------------
Come ride with me through the veins of history,
I'll show you how god falls asleep on the job.

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
MJ... I think you can do that in one iteration of the 1-20 and just adapt it...

Any possibility I'm right?

And, VB. QB if you can.

[ 08-17-2005, 12:17 PM: Message edited by: Flamelord ]

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Hesacon
Obsessive Member
Member # 3724

Member Rated:
4
Icon 1 posted      Profile for Hesacon   Author's Homepage   Email Hesacon   Send New Private Message       Edit/Delete Post 
I just know the cookies section of the HRC is about to get a big boost. Give me so much information that I would have a big job adding it to the site. Hell, there are no adds on it, its just a growing tool for developers [Wink]

---

I found some new programs I need to add to the list...

--------------------
SoV: Exalted Devout Oracle | World Developer | The Black Guard
Outside is just a prank older kids tell younger kids at Internet Camp

Posts: 9479 | From: NY | Registered: Apr 2003  |  IP: Logged
Sir Mj
Obsessive Member
Member # 4642

Member Rated:
3
Icon 1 posted      Profile for Sir Mj     Send New Private Message       Edit/Delete Post 
If you mean what I think flamester then yes there is a way, however the long-winded post that example was plucked from extends to a 3rd level/dimension of data, and is laid out for ease of explaination.

Due to time constraints I can't pump out a tute right now but I did take a minute to find and skim through a tutorial for you here. The main thing I'd add to what that page and it's links tell you is that by declaring an array of objects, you can initialise, manipulate and sort through dynamic databases. The pen thing was a rather goofy example, kinda like demonstrating a lightsaber by using it to slice up some tomatoes for an intergalactic bolognase sauce.

--------------------
Come ride with me through the veins of history,
I'll show you how god falls asleep on the job.

Posts: 5438 | Registered: Dec 2003  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
Yeah, I meant so that the 8 or so lines of code for each player (1-20, 160 lines) would only have to be written once for them all (1-20, 8 lines (or more)) with just a few more cookies and some thinking. Anyway...

Ack. VB evil. Um, I'll just wait until you have enough time to pump out the tutorial in QUEST. In the meantime, I'll bask in the glory of my accessrights.qst. (That's right, biatches, the file can be called multiple times in a scene, reach the same result, and send you to a different location each time! An example:

code:
 @testSID
STRCMP #<primary>, "0"
IF= @setpri1
IF> @forpri1
IF< @forpri1
@pri1back
STRCMP #<secondary>, "0"
IF= @setsec1
IF> @forsec1
IF< @forsec1
@sec1back
STRCMP #<tertiary>, "0"
IF= @setter1
IF> @forter1
IF< @forter1
@ter1back
STRCMP #<return>, "0"
IF= @setret1
IF> @forret1
IF< @forret1
@ret1back
STRCMP #<str.soul>, "SOUL 2044"
IF= @#<primarygo>
STRCMP #<str.soul>, "SOUL 2231"
IF= @#<secondarygo>
STRCMP #<str.soul>, "40000810"
IF= @#<tertiarygo>
GOTO @#<returngo>
END
@setpri1
SET primarygo, "ismaster"
GOTO @pri1back
@forpri1
SET primarygo, "#<primary>"
SET primary, "0"
GOTO @pri1back

@setsec1
SET secondarygo, "isbeta"
GOTO @sec1back
@forsec1
SET secondarygo, "#<secondary>"
SET secondary, "0"
GOTO @sec1back

@setter1
SET tertiarygo, "ban"
GOTO @ter1back
@forter1
SET tertiarygo, "#<tertiary>"
SET tertiary, "0"
GOTO @ter1back

@setret1
SET returngo, "normal"
GOTO @ret1back
@forret1
SET returngo, "#<return>"
SET return, "0"
GOTO @ret1back

See? I dunno, if people can do things like that without arrays...

Besides, where would an array come in handy? Can you give a specific example or just the "Places where things change only a little between repetitions"?

--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Mad
Verbose Member
Member # 5460

Member Rated:
3
Icon 1 posted      Profile for Mad   Author's Homepage   Email Mad   Send New Private Message       Edit/Delete Post 
This tutorial was originally posted on athelias.biz forums. I have decided to post it in this sticky despite the fact that it's not all about cookies - let me invoke the arguments passed as a justification. [Wink]

Subroutines, or "CALL" in WoS QUEST language, are a function sending your script to a label of another scene (actually it also works with a label in the same scene), and returning to the next line of the script the new label(s) was/were CALLed from when it's done.

From a syntaxic point of view, subroutines in WoS look like this:

...script...
; First we CALL the new scene:
CALL #<scene.id>@#<label.name>
...script...

In the scene called, the command "RETURN" will send you back to the script of the 1st scene.

What's the point?

There are many applications. I will try to give you some examples of what you can do with subroutines. Of course, the list won't be exhautive. I'll try to post some generic scripts using subroutines that may be useful in your world to illustrate this tutorial.

1/ CALLs and #includes

A simple and very powerful use of the subroutine is to replace most of the files #included in the scenes of your worlds to speed up the loading time of the world.

Let's assume you have a generic script implanted in every scene of your world to configurate the weather of the scene. If you use an #include command fo that, the script will be loaded 1 time per scene, which means that if the script is 50 lines long and if there are 1000 scenes in the worlds, #including it is adding 50,000 lines to you world for WoS. No need to say that it will lag it down when WoS will have to load it (when you select it in the world list to play it). Now, if you CALL it, it will be loaded only one time for the whole world: isn't it brilliant?

To replace an #include by a CALL, you can just do this (we assume your script is in a file called weather.txt):

- First, open quests.txt, and add a line: #include weather.txt in the SCENES section.
- Then, open weather.txt, and turn it into a scene: add a line "SCENE <unused scene ID, let's say "1000"> at the beginning of the file. Add also a label at the beginning of the file - @start for example.
- Then, where the former #included script is over and supposed to return to the script in which it was #included, add a line: "RETURN"
- Finally, replace all the "#include weather.txt" of your world by the line: "CALL 1000@start", and you're done.

In this example, we had this:

SCENE nn
...script...
#include weather.txt
...script...

and this:

; in weather.txt
...script...
IF <something> @label1
IF <something> @label1
...etc...
GOTO @weather.txtOver

@label1
...script...
GOTO @weather.txtOver

@label2
...script...
GOTO @weather.txtOver

@weather.txtOver
; here it returns to the script appearing in SCENE nn

And we want to change it to this:

SCENE nn
...script...
CALL 1000@start
...script...

and this:

; in weather.txt
SCENE 1000
@start
...script...
IF <something> @label1
IF <something> @label1
...etc...
GOTO @weather.txtOver

@label1
...script...
GOTO @weather.txtOver

@label2
...script...
GOTO @weather.txtOver

@weather.txtOver
RETURN
; here it returns to the script where this scene is CALLed from.

Not hard to understand up to now. But there are many other fancy things we can do with subroutines.

2/ Arguments passed with the function

The CALL and RETURN commands let us pass arguments from a scene to another. Those arguments are volative cookies, that are not stored in the .INI file of your char, and that disappear at the end of the scene. To check the value of these arguments, we use cookies called #<arg0>, #<arg1>, etc. We can pass up to ten arguments via this function (from #<arg0> to #<arg9>.

To pass an argument, use this syntax:

- When you CALL a scene: CALL <sceneId>@<labelName> <arg0>, <arg1>, <arg2>, etc.
- When you RETURN to a scene: RETURN <arg0>, <arg1>, <arg2>, etc.

Note: the arguments are separated by a coma, but the label name and the first argument are not: check the syntax I've used.

What can this be used for? Let's give some examples. I'm sure you'll find many other ways to use them.

Example 1: Grammar checker script

This is just a small script I'm giving to you to fix the a/an grammatical issue when you don't know if the next word starts with a voyel or not (for ex: "a %L", or "a %Z123").

We want to build a generic script to check that. There is 1 variable in every case: the name we want to check (D'OH!). That's what we will have to pass as an argument. Before the line where the unknown word appears, we'll have to add the following line:

; We assume the unknown word is %C in this case.
; Whereever you'll implant this subroutine, you'll have to change the argument passed:
; that's the only thing to edit.
CALL sceneNN@start %C

And now we write the subroutine:

---------------------------------------------------------------------------------------------------

SCENE nn
@start
SET_SUBSTR temp.grammar, 0, 1, #<arg0>
; Here we extract the first letter of the unknown name and set a cookie with this value.
; Check my tutorial on the SET_SUBSTR and SET_LEN commands in the WD forums of WoS BBs.
STRSTR "aeiouy", #<temp.grammar>
; Here we check if the the first letter is included in the list of the voyels or not.
IF> @voyel
; If the script keeps going here, it means that it's not a voyel: "a" will remain "a" then.
; We can return to the original scene, with a blank value for arg0 (you'll see later how I'll use that).
RETURN ""

@voyel
; That's a voyel: "a" should be turned into "an".
; We're going to return to the orginal scene with "n" passed as arg0.
RETURN "n"

---------------------------------------------------------------------------------------------------

In the original scene, the line where the word we wanted to check was looked this this:

1: Eh! What a %C is doing here? ; (for ex)

Now we change it to:

CALL sceneNN@start %C
1: Eh! What a#<arg0> %C is doing here? ; (for ex)
; If it's a voyel, arg0 will be a "n", if it's not, it will have a blank value.
; We're done.
; To use this script anywhere, just replace "%C" here (in the CALL command)
; by the variable you want to check in the next line.
; I let you write the same kind of script that would allow us to check several variable in the next line:
; Just pass several arguments, and check'em all.
; That would be something like that:
; 1: A#<arg0> %L! So you're a#arg1> %C, right?


[I'm tired - I'll finish this tutorial and edit this post later. - Mad]

[ 02-03-2006, 08:08 AM: Message edited by: Mad ]

--------------------
athelias.biz - Forums - Worlds' List

Posts: 1812 | From: Moe's | Registered: Jul 2004  |  IP: Logged
NemesisOfChaotix
Member
Member # 7028

Member Rated:
1
Icon 1 posted      Profile for NemesisOfChaotix   Author's Homepage   Email NemesisOfChaotix   Send New Private Message       Edit/Delete Post 
Hey i'm making a wold and in one scene someone dies so you have to inform his family to get sumthin so how would i go about doing this?

--------------------
There is but a thin line between Life and Death. I am that line, do not cross me.

Posts: 33 | From: Australia | Registered: May 2006  |  IP: Logged
Flamelord
Compulsive Member
Member # 4491

Member Rated:
4
Icon 1 posted      Profile for Flamelord   Author's Homepage   Email Flamelord   Send New Private Message       Edit/Delete Post 
Ironically, my last post in this topic was still trying to find a use for arrays. I have. Here's the tut I asked for, though I still can't give a simple example of the practical uses of one.

Arrays
Written by: Flamelord

An array is a set of cookies that are used to arrange data. The simplest form of array is called a one-dimensional array. Each cookie in an one-dimension array has two parts to its name: an array name element, which is the same across all the cookies in the array, and an index element, which is unique to it. So, for instance, if our array was of the six objects that Bob owned, our array name element might be "bobObjects" and our index elements might range from 0 to 5 or 1 to 6. We'll use arrays starting at one for this exercise. So, we would have an array composed of the following cookies:

code:
bobObjects1
bobObjects2
bobObjects3
bobObjects4
bobObjects5
bobObjects6

So, with this array, we can write and read to each cookie easily. To write to a cookie in it, you'd simply do:

code:
SET bobObjects1, "Magical Lamp"

And to read, you would use the following:

code:
#<bobObjects1>

But what if you didn't know the index that you wanted to read, or you needed to set the index from some other bit of scripting? Perhaps you wanted to read out every one of the the things Bob owns. Instead of writing out six commands to do it and changing the index on each one (and the array may get larger anyway), you can use a loop, and set the index from a cookie. Let's assume that bobObjects0 contains the number of items in the array (in this case, 6):

code:
SET numBobObjects, #<bobObjects0> ;this grabs the number of objects to read.
SET readobject, 1 ;This is the index we'll use to read the cookies in the array one at a time.
@loop
SET cookiename, bobObjects#<readobject>; ;we need a pointer because you can't read from a cookie like this: #<arrayname#<index>>
N: bobObjects#<readobject> contains "*#<cookiename>" ;So: "bobObjects1 contains "Magical Lamp"
ADD readobject, 1 ;Get ready to read the next cookie in the array
COMPARE #<numBobObjects>, #<readobject> ;See if we're done. If readobject is larger than the number of objects, the loop will stop
IF&lt;= @loop ;If it wasn't larger (we didn't just read the last object), go back and loop.
END

So now we can read from an array. What about writing to it? Let's say we wanted six new objects to be set as the objects Bob owns, instead of the ones he owns now. Here's how we might do that. Much of this code chunk is similar or the same as it was in the previous example.

code:
SET numBobObjects, #<bobObjects0>
SET readobject, 1
@loop
SET cookiename, bobObjects#<readobject>
N: Value to write to bobObjects#<readobject>? (contains: "*#<cookiename>")
ASK 240 1
SET #<cookiename>, #<lastAsk> ;note that we don't need a cookie pointer here, as #<cookiename> has the name of the cookie to be written.
ADD readobject, 1
COMPARE #<numBobObjects>, #<readobject>
IF&lt;= @loop
END

That is the basic points of array creation and use. Practical implementations are up to you. [Smile]

Note that you can also use two-dimensional arrays through n-dimensional arrays. Remember that they tend to increase in size exponentially, at least when you keep all the dimensions equal.

Two-dimensional:

code:
arrayname-#<index1>-#<index2>

N-dimensional:

code:
arrayname-#<index1>-#<index2>- ... -#<indexN-1>-#<indexN>



--------------------
Constantinople! We shall never forget your zany barge poles!

Posts: 4232 | From: Gresham, OR | Registered: Nov 2003  |  IP: Logged
Injury
Healthy Member
Member # 8063

Member Rated:
5
Icon 1 posted      Profile for Injury   Author's Homepage   Email Injury   Send New Private Message       Edit/Delete Post 
just reading this helps me out a lot! thanks very much! it's like switches with variables in RM2K/XP or something along those lines...

--------------------
Visit http://fuller-dev.com/wos/ for guides, skins and worlds. Enjoy!

Posts: 198 | Registered: Feb 2008  |  IP: Logged
  This topic comprises 3 pages: 1  2  3   

Quick Reply
Message:

HTML is not enabled.
UBB Code™ is enabled.

Instant Graemlins
   


Post New Topic  New Poll  Post A Reply Close Topic   Unfeature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Synthetic Reality

Copyright 2003 (c) Synthetic Reality Co.

Powered by UBB.classic™ 6.7.3