AvernumScript Ideosyncracies
Author | Topic: AvernumScript Ideosyncracies |
---|---|
Apprentice
Member # 4127
|
written Sunday, April 4 2004 12:28
Profile
As I continue to play with AvernumScript, I find issues that I lump into three categories: (1) Bugs that need to be fixed, (2) Calls that I wish existed because I cannot fake, and (3) Things that don't work like I thought and need to be better documented. There are formal channels for (1), and Kelandon has created a thread for (2). This thread is for (3), the type of things that appear on the tech support page. That page is a stopgap for the really extreme problems. This thread is for people to post things they do not legitimately understand about the system and may need to appear in later documentation. Here is something to get us started. Boolean expressions in AvernumScript do not seem to short circuit. To see what I mean by this, consider the line of code if (who_hit_me() >= 0 && dist_to_char(who_hit_me() <= 2) { This checks if we were hits and that the offender is close (not an archer). In most programming languages, if who_hit_me() is negative, the script will not bother with the dist_to_char() call. One part is false, so the whole thing must be false. Not true in AvernumScript. If will make both calls. So if no one hit you, you will get an error here (because dist_to_char(-1) is bad). It also means that long complicated boolean expressions are inefficient. Is this a bug for Jeff to fix? Absolutely not. It was a reasonable design decision on his behalf. But this is something we need to be aware when writing scripts. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Infiltrator
Member # 3040
|
written Tuesday, April 6 2004 08:14
Profile
Maybe the error is from a missing parenthesis? There should be a ")" before the "<=2". -------------------- 5.0.1.0.0.0.0.1.0... Posts: 508 | Registered: Thursday, May 29 2003 07:00 |
Apprentice
Member # 4127
|
written Tuesday, April 6 2004 08:21
Profile
quote:Oh. That's a typo in the post. It's okay in the actual script (which is actually more complicated. Compare if (who_hit_me() >= 0 && dist_to_char(who_hit_me() <= 2)) { which has problems with if (who_hit_me() >= 0) { if (dist_to_char(who_hit_me() <= 2)) { which works. I have tested the function. It's a short-circuit issue. Posts: 48 | Registered: Saturday, March 20 2004 08:00 |
Infiltrator
Member # 154
|
written Tuesday, April 6 2004 08:45
Profile
That is a bug IMO, and something that Jeff needs to fix. I'll be sorely dissapointed if I can't use long expressions in a single if() like that when BoA for win is out. -------------------- Apparently still annoying. Posts: 612 | Registered: Saturday, October 13 2001 07:00 |