Synthetic Reality Forums   
my profile | directory login | register | search | faq | forum home

  next oldest topic   next newest topic
» Synthetic Reality Forums » Our Archives » WoS World Developer Tips » * NEW QUEST LANGUAGE COOKIE MATH FUNCTIONS: ADD, SUB, MUL, DIV, MOD

   
Author Topic: * NEW QUEST LANGUAGE COOKIE MATH FUNCTIONS: ADD, SUB, MUL, DIV, MOD
samsyn
Administrator
Member # 162

Member Rated:
4
Icon 10 posted      Profile for samsyn   Author's Homepage   Email samsyn   Send New Private Message       Edit/Delete Post 
* NEW QUEST LANGUAGE COOKIE MATH FUNCTIONS.

There are now several cookieMath commands which modify an existing cookie in some way:

ADD cookieName, "3" <-- add 3 to cookie
SUB cookieName, "5" <-- subtract 5 from cookie
MUL cookieName, "6" <-- multiply cookie by 6
DIV cookieName, "11" <-- divide cookie by 11
MOD cookieName, "10" <-- modulus operator (remainder from integer division)

And, oh heck, I will have these set the IFc result, as if you had followed each by a COMPARE #<cookieName>, "0"

So

SET A, "5"
SUB "5"
IF= @AisNowZero
IF> @AisNow>Zero
IF< @AisNow<Zero

---------

You can say either MOD or MODULUS in your scripts, by the way.

The modulus operator may give unexpected results for negative numbers as that is not what it is intended for. So it is really only the 'division remainder' for positive numbers, as in:

11/10 = 1 with remainder 1

-11/10 = who knows.
11/-10 = equally cryptic.

I am just passing your wishes along to the c compiler's implementation of the "%" operator (except for mod 0, that I am ignoring).

-----------

Now, just because you CAN do basic calculator math in WoS now, doesn't mean your world SHOULD do calculator math...

The main justification for these functions is for looping, as in:

SET loop, "10000"
@repeat
1: I know a song that gets on everybody's nerves!
SUB loop, "1"
IF> @repeat



Posts: 10643 | From: California | Registered: Dec 1998  |  IP: Logged
Jacius
Veteran Member
Member # 265

Member Rated:
4
Icon 1 posted      Profile for Jacius   Email Jacius   Send New Private Message       Edit/Delete Post 
OOOOOOOH I love you Dan!

Hugs for everyone! I love math functions! Yipeee!

There are so many possibilities! Oh, my head cannot hold them all!

What about adding/sub-ing/etc cookies by other cookies?

SUB cookieName, otherCookieName

-Jacius

[ no problem...

SET A "4"
SET B "7"
SUB A, #<B>
1: I sure hope that #<A> is -3!

Be careful with your #<...> though. You need the wrapper to 'read' a cookie, but if you use it when 'writing' a cookie, it will do something other than you expect..

For example

SET A "3"
SET B "4"
SUB #<A>, #<B>

The SUB line will first get 'expressed' to:

SUB "3", "4"

Which will then look for a cookie named "3" and subtract four from its contents.

[This message has been edited by samsyn (edited 06-25-2001).]


Posts: 508 | From: Illinois | Registered: Apr 2000  |  IP: Logged
Merlin
Compulsive Member
Member # 181

Member Rated:
5
Icon 1 posted      Profile for Merlin   Author's Homepage   Email Merlin   Send New Private Message       Edit/Delete Post 
I dont think I've properly THANK YOU! said THANK YOU! yet!

THANK YOU!

I promise you won't regret it :-)

-Merlin


Posts: 2797 | From: Atlanta, Georgia | Registered: Nov 1999  |  IP: Logged
samsyn
Administrator
Member # 162

Member Rated:
4
Icon 1 posted      Profile for samsyn   Author's Homepage   Email samsyn   Send New Private Message       Edit/Delete Post 
I just hope it doesn't take too many releases to shake out all the inevitable bugs in all this new stuff...
Posts: 10643 | From: California | Registered: Dec 1998  |  IP: Logged
   

   Close Topic   Feature 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