Jump to content

AvernumScript Ideosyncracies

Recommended Posts

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.

Link to comment
Share on other sites

Originally written by wizardr6:
Maybe the error is from a missing parenthesis? There should be a ")" before the "<=2".
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.
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Create New...