|
brys0005 Newbie
Joined: 22 Sep 2005 Posts: 9
|
Posted: Sat Nov 05, 2005 2:30 am
Help with parsing multiple lines and storing to a list |
I need to parse multiple lines from the mud and store them to a list so I can use them at a later time. The lines are each on a new line, like:
A big guard
A small guard
A ugly girl
Ideally I want to capture each thing to a list, and then loop through the list to see if it is not empty...
something like while(list != NULL) {do something}
man, I wish I could use C/C++/Java code within zmud...wouldn't that be nice? ;) |
|
|
|
Kiasyn Apprentice
Joined: 05 Dec 2004 Posts: 196 Location: New Zealand
|
Posted: Sat Nov 05, 2005 2:59 am |
#WHILE (!%null(@list)) ?
|
|
|
|
Pseudo Wanderer
Joined: 25 Oct 2005 Posts: 99
|
Posted: Sat Nov 05, 2005 5:41 pm |
#while (%numitems(@list)>0) {do something}
The problem you are going to run into will be distinguishing what is listed. Most muds list items and mobs after the exits. We'd need a sample of the actual room with mobs and items to have a chance at writing such a specialized script. Are you trying to store both or just the mobs and what can be used to differentiate them? |
|
|
|
brys0005 Newbie
Joined: 22 Sep 2005 Posts: 9
|
Posted: Sat Nov 05, 2005 7:59 pm |
Ok, here is a sample of the mud:
A dirt road in Karin(n, w, e)
The skeleton of a guard
A female town guard
A big muscular town guard
A small scrawny town guard
HP:95 EP:73>
What I want to do is to trigger on "town guard", and then be able to count the number of guards in a room so when I am fighting, zmud will know if i have killed all of the guards/if any are still here...I was thinking of having a trigger that fires on "town guard" and then adds "guard" to a list...so then I can pop from the list and check to see if the list still has elements or not.... |
|
|
|
Pseudo Wanderer
Joined: 25 Oct 2005 Posts: 99
|
Posted: Sat Nov 05, 2005 8:19 pm |
#Class {RoomGuards}
#var guardcount 0
#Action {town guard} {#add guardcount 1}
#alias {onroomenter} {#var guardcount 0}
#Action {is dead} {#If (@guardcount>0) {do something}}
#Class 0
Something along these lines sounds like what you are looking for. You could also use #T+ RoomGuards and #T- RoomGuards to enable and disable the class from an alias (or manually) should you not want the onroomenter alias to fire while you walk around the entire mud. Also, anchoring "town guard" and "is dead" should be considered. For example, if there are only 2 or 3 words before town guard, using an action such as #Action {^%1 %2 %3 town guard} {#add guardcount}. Otherwise, it may match your room descriptions or worse. |
|
|
|
|
|