Welcome to the Builder Academy

Question room.people and Curly Braces

More
24 Jul 2015 15:53 #5454 by thomas
Replied by thomas on topic room.people and Curly Braces
oh, I am obviously struggling with getting my point across. %actor.id% (and by extension, %actor.room.people.id% when the actor is the only person, or the latest arrival in the room) returns the internal id without the preceding }.

that is, %}1234.id% == 1234. (I am certain this won't work literally, but means that "you get the ID without special chars when you ask for the id subfield of a variable").

You can also, since the people-var is a general character-type variable, get the vnum by using %room.people.vnum%. But, you should be looping as in that other question - the latest arrival (typically the player) will be the first in line, and players have an empty vnum field.

Please Log in or Create an account to join the conversation.

More
24 Jul 2015 16:42 #5455 by krell
Replied by krell on topic room.people and Curly Braces
Thanks Thomas, I think I understand now.

Please Log in or Create an account to join the conversation.

More
25 Jul 2015 13:44 - 25 Jul 2015 16:25 #5458 by krell
Replied by krell on topic room.people and Curly Braces
Okay, I'm checking my understanding here. If I have a script with the following code

Code:
set next_char room.people.vnum . . while %next_char% set tmp_char %next_char.next_in_room% * Count the number of people in the room. eval num %num% + 1 * now STUFF all of the people into a list, 1 to n! set victim[%num%] %next_char% set next_char %tmp_char% done

next_char will always be IDs because of tmp_char.next_in_room. If I modify my code thusly though.

Code:
set next_char room.people.vnum . . while %next_char% set tmp_char %next_char.next_in_room% set next_vnum tmp_char.vnum * Count the number of people in the room. eval num %num% + 1 * now STUFF all of the people into a list, 1 to n! set victim[%num%] %next_char% set next_char %next_vnum% done

I could fill my list with VNUMs instead of IDs? Sorry if I seem a bit thick, but I want to make sure I have a handle on this. Thanks.
Last edit: 25 Jul 2015 16:25 by krell.

Please Log in or Create an account to join the conversation.

More
26 Jul 2015 15:55 #5459 by Parnassus
For some reason I thought that you were talking about different instances of the same mob. For instance, there are a lot of fidos running around TBA. There are two different vnums but 40 instances. If you were trying to distinguish between two of the same vnum of fidos, vnum wouldn't do it but id would.

Please Log in or Create an account to join the conversation.

More
26 Jul 2015 20:05 #5461 by thomas
Replied by thomas on topic room.people and Curly Braces
"set next_char room.people.vnum" does not do what you expect. This means, literally, "give me the vnum of the first char in the room", as a text string (1234). This is, generally - as I stated earlier - not what you want to store.

Instead, you will want to use this formula:
Code:
* it doesn't matter what the variable is called. We use iterator here to make it obvious. set people_iterator %room.people% * check that there is actually a person in the variable at this point while %people_iterator% * since we are not purging the current person (or killing them in the loop), just work with the var * otherwise, store a "next_in_room" variable here. * increase our counter (why are you adding the people to a list? this seems overly complicated) eval num %num% + 1 * now STUFF all of the people into a list, 1 to n! * this stores a fully-fledged character variable at victim[X]. * This is useful for dg commands like %force%, %kill%, etc. set victim[%num%] %people_iterator% * if you just want their ID (not that I see that as useful), use this: set victim[%num%] %people_iterator.id% * if the vnum is what you want to store, you could do it like this: set victim[%num%] %people_iterator.vnum% * now, we move our iterator to the next character in the room set people_iterator %people_iterator.next_in_room% * and complete the loop end

But, will you PLEASE enlighten me about what you need the victim-array for? The only reason I can see would be to store the list for later use. And that seems, as I mention in the code above, somewhat convoluted and complicating. I mean, you'll have too loop over the array afterwards to make any use of it. I'd have gone with the more tried and tested solution here:
Code:
* obtain first char in room - adjust to %actor.room.people%, %self.room.people%, etc. set person %room.people% * as before, check if the loop is done while %person% * because this loop is generic, we might destroy the character and thus move it out of the room. Save the next-value. set next %person.next_in_room% * do bad, bad stuff to the person if they are not fidos if %person.vnum% != 3001 %echo% %person.name% is KILLED! %kill% %person% end * now, go to next person. Use the stored value from above. Perhaps the person no longer exist at this point. set person %next% * and loop end

Please Log in or Create an account to join the conversation.

More
26 Jul 2015 21:29 #5462 by krell
Replied by krell on topic room.people and Curly Braces
Well Parna, I was talking about two different MOBs in the same zone. I was having trouble automatically deriving their VNUMs and thought finding the IDs would work better for what I had in mind. Seems I might have been wrong.

Please Log in or Create an account to join the conversation.

Time to create page: 0.204 seconds