Re: [SCRIPT] DG Scripts

From: Torgny Bjers (tb@sbbs.se)
Date: 07/30/00


Peter Ajamian wrote:
>Torgny Bjers wrote:
>>
>> Hello Peter,
>>
>> There's one slight problem.  How can I target a player with a random
>> trigger?  It doesn't have any variables that can target players, has it?
Or
>> if it does, please explain how I would write a script that somehow loops
>> through ALL the characters in a specific room and then use like REWARD on
>> them or something like that.
>
>From the DG Scripts web site documentation, variable fields...
>
>Characters
>
>...
>
>next_in_room
>The next character in the room, or an empty return.
>
>...
>
>Rooms
>
>...
>
>people
>The first character in the room, or an empty return.
>
>So given a room trigger you would do something like this...
>
>set nextplr %self.people%
>while ("%nextplr%" != "")
>  *
>  * Do stuff with %nextplr% here.
>  *
>  set nextplr %nextplr.next_in_room%
>done
>
>Note, these are both fairly new fields for DG Scripts, if you have an
>older version of DG Scripts you'll have to add them to the source, you
>can download the latest patch, then just open up the file and pull the
>two fields right from the patch itself and add them to your source
>(hint, search the patch for "next_in_room" and "people" with the
>quotes).
>


Well, my version of DG Scripts support the next_in_room field, but there's
still one slight glitch in this script, I have included the script I wrote
myself, and there's some little error checkers in there, like check that
terminates if it loops beyond the last char in the room...


* MANA LOADER SCRIPT
* BY ARTOVIL, ARCANE REALMS
* arcane-realms.dyndns.org:3011
set nextplr %self.people%
  while (%nextplr% != "")
  * MAKE SURE THEY ARE STILL IN THE ROOM
  * if %nextplr.room% = %self.vnum%
    * IF SO, REWARD!
    wreward %nextplr% mana 5
    wsend %nextplr% Your mana increases!
    wsend %nextplr% %nextplr.next_in_room%
  * end
  * GO TO NEXT PLAYER
  if %nextplr.name% = "The Void"
    halt
  else
    set nextplr %nextplr.next_in_room%
  end
done
* end of script


It works, but... It only takes the LAST character, not the FIRST, so it
doesn't loop, it terminates right away, and you can see that it prints out a
carriage return if you run the script, and that means its reached the end of
the list, right?

So, how do I go about changing this?  I mean, this is a pretty important
function, IMHO, looping through the characters in a room when random
fires...  You can do so many cool things with it, so it would be nice if I
got it to work... :)

Kind Regards,
Torgny Bjers (Artovil)


     +------------------------------------------------------------+
     | 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