Re: [SCRIPT] DG Scripts

From: Thomas Arp (t_arp@mail1.stofanet.dk)
Date: 07/31/00


From: "Torgny Bjers" <tb@sbbs.se>
Subject: Re: [CIRCLE] [SCRIPT] DG Scripts

<snip of script>

> The reason to why the while.. doesn't work like it should in this case is
> because %nextplr.next_in_room% doesn't return "" when it is done, does it?
> It returns a carriage return, eh? So it will NEVER be "" will it?
> Therefore, infinite loop (my oh my, does it eat CPU when writing errors to
> the logfile! :])

Actully %nextplr.next_in_room% DOES return "" if there aren't any more people in the room, as you can see here (from dg_scripts.c):

      else if (!str_cmp(field, "next_in_room")) {
        if (c->next_in_room)
          sprintf(str,"%c%ld",UID_CHAR, GET_ID(c->next_in_room));
        else strcpy(str,"");
      }
Your problems might be caused by the use of 'set' instead of 'eval'. Set only assigns the text, whereas eval substitutes (or calulates or whatever you want to call it) right away , ie. :
set %test% %self.name% actually puts the text "%self.name%" into the var %test%
eval %test2% %self.name% puts the name referred to by the field into the var %test2%
Your problems with while() comes from an assignment:

> set nextplr %nextplr.next_in_room%

this will then be checked in the next loop:
%nextplr% (= "%nextplr.next_in_room%") =! ""
which is always true.
I'm just surprised you got it to work on more than one player in a room..
If you use

eval nextplr %nextplr.next_in_room%

instead, no problems should arise, and you should be able to skip the check for "The void"
>
> I hope I didn't bother anybody by sending this email to the list.  Maybe it
> should have gone to Peter personally, but I thought that some other people
> might want the version that works too.
>
No problem  ;)

The following script works too.
* init the loop
eval person %self.people%

while (%person%)
* Do whatever necessary - this could be wreward, too..
  %echoaround% %person% The medics see to %person.name%s wounds.
  %send% %person% You are cared for by the medics.
  dg_cast 'cure light' %person.name%
  wait 1
  eval person %person.next_in_room%
done

Welcor
Cruel World MUD
midnightrealm.org 4000


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT