Welcome to the Builder Academy

Question room.people and Curly Braces

More
18 Jul 2015 04:23 #5441 by Parnassus
It might be something to do with charat:
Code:
charat - set new variable %text/var.charat(index)% i.e. set phrase testing, set var1 %phrase.charat(2)% now %var1% == e

I wonder if you could subtract %phrase.charat(1)% from %phrase% somehow?

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

More
18 Jul 2015 04:26 #5442 by krell
Replied by krell on topic room.people and Curly Braces
Or possibly contains(). Hrm, this will require more thought and research. Thanks.

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

More
18 Jul 2015 13:06 #5443 by Parnassus
How crazy is this? You take the strlen, and charat for strnlen, strlen-1 and strlen-2. Then you put them all together backwards for the two ids and subtract one from the other.

I figure there has to be an easier way but I'm something of a trigger cobbler.

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

More
18 Jul 2015 16:28 - 20 Jul 2015 17:55 #5444 by krell
Replied by krell on topic room.people and Curly Braces
I actually hit on a similar solution for stripping the lead character, except I hadn't figured our how to put the string back together before I hit the hay. I spent much of the morning working on it until I realized I was trying to hard. This what I came up with that would allow me to math on MUD ID's, with proper refining of course. It's probably still a bit over complicated. :-)

Code:
if 1 < 2 %echo% Krell's ID is %self.room.people% *set actor_id %self.room.people% set actor_id }1343 %echo% actor_id is %actor_id% set slen %actor_id.strlen% %echo% slen is %slen%! set num 1 set nnum 2 set actor_iid while %num% <= %slen% %echo% actor_id at %num% is %actor_id.charat(%num%) %echo% actor_id at %nnum% is %actor_id.charat(%nnum%) eval actor_iid %actor_iid%%actor_id.charat(%nnum%)% eval nnum %nnum% + 1 eval num %num% + 1 done %echo% actor_iid at 1st element is %actor_iid.charat(1)% %echo% actor_iid is %actor_iid% set slen %actor_iid.strlen% %echo% length of actor_iid is %slen% end

Addendum

More generally then:
Code:
set slen %<variable>.strlen% set num 2 while %num% <= %slen% eval <variable2> %<variable2>%%<variable>.charat(%num%)% eval num %num% + 1 done
Last edit: 20 Jul 2015 17:55 by krell. Reason: First chance to add generalized code for script since travelling

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

More
24 Jul 2015 11:44 #5451 by thomas
Replied by thomas on topic room.people and Curly Braces
%room.people% is a metavariable. It holds a "characterinfo" variable for the first char in the room.
When echo'ed, it shows the internal ID of the character, prepended by a character unlikely to be the first in a string ('}'). It is not part of the dg API and can be changed without any notice.

As for creating character pointers by doing "set actor_id }1234", you are running into all kinds of potential problems in the long run.

If you need the the id, just extract it directly with %room.people.id%. Using it for calculations seems rather strange to me, as this is an internal id, which may change to another representation in the future (a hash comes to mind, for instance).

As a side note - using %room.people% for anything other than getting the first character for looping, seems suspicious to me.

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

More
24 Jul 2015 13:09 #5453 by krell
Replied by krell on topic room.people and Curly Braces

thomas wrote: %room.people% is a metavariable. It holds a "characterinfo" variable for the first char in the room.
When echo'ed, it shows the internal ID of the character, prepended by a character unlikely to be the first in a string ('}'). It is not part of the dg API and can be changed without any notice.


But I'm trying to remove the first non numeric character in the string. I don't want it.

As for creating character pointers by doing "set actor_id }1234", you are running into all kinds of potential problems in the long run.


Again, I don't want to use that first non numeric character. I was trying to figure out a general way of removing it so I don't have to depend on using }# if comparing IDs. Secondly, I only used }# in my test script for testing purposes, to see if the } was removed.

If you need the the id, just extract it directly with %room.people.id%. Using it for calculations seems rather strange to me, as this is an internal id, which may change to another representation in the future (a hash comes to mind, for instance).


See above. For reasons you state just above and prior are reasons why I'm trying to strip out the non numeric.

As a side note - using %room.people% for anything other than getting the first character for looping, seems suspicious to me.


Perhaps it is, in your post to Parnassus's thread you seem to indicate that the character's VNUM can be directly derived from the ID. If that's true then I can readily modify the scripts I'm working on to take advantage of that.

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

Time to create page: 0.206 seconds