|
chloeizzy Newbie
Joined: 14 Mar 2021 Posts: 5
|
Posted: Fri Nov 19, 2021 9:31 pm
Number iterations of string list |
I'm trying to create a string list of mobiles in a room, it works with this for just up to 2.mobile..
Code: |
#if (%ismember(%subregex(%1,"(?:^A |^An |of an|of a |with a |The | and|to the |of |to |of the |from |,|')"),@consider_list)) {consider_list = %additem(2.%subregex(%1,"(?:^A |^An |of an|of a |with a |The | and|to the |of |to |of the |from |,|')"),@consider_list)} {#var consider_list %additem(%subregex(%1,"(?:^A |^An |of an|of a |of the |with a |The |some | and|to the|of |to | the|to the |from |,|')"),@consider_list)} |
Though - I want to add up to 8 occurrences. I tried a bunch of #if with increments but when a room has 2 of one mobile, and maybe 3 of another it just adds 8 of each or a huge mess of each, instead of each occurrence.
Does anyone have an idea how to do what I have in mind? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: Fri Nov 19, 2021 9:47 pm |
Perhaps show us the raw display from the game?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
chloeizzy Newbie
Joined: 14 Mar 2021 Posts: 5
|
Posted: Fri Nov 19, 2021 10:09 pm |
(R) You would stomp A lich into the ground.
(R) You would stomp Creeping death into the ground.
(R) You would stomp A lich into the ground.
Though I have the trigger portion down to capture the mobs, I thought the rest would be put onto me to figure how cMud would add 1. 2. 3. and so on in front of the mob names.
So if there are 4 A lich, I would want to populate 1.lich through 4.lich - but only one occurrence of creeping death. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: Sun Nov 21, 2021 2:37 pm |
I would suggest a mini dbVar to handle this:
Code: |
#TR {~(R~) You would stomp (*) into the ground.} {
$mob=%1
$count=(%int(%db(@roomMobs, $mob))+1)
#ADDKEY roomMobs $mob $count
#ALARM "populater" +.5 {#RAISE countThemAll}
} |
This will capture all the mobs, and count anything that repeats.
Code: |
#EVENT countThemAll {
#FORALL %dbkeys(@roomMobs) {
$count=%db(@roomMobs, %i)
#LOOP $count {#ADDITEM mobList %concat(%j, ".", %i)}
}
roomMobs=""
} |
This populates a new variable @mobList
#EVENT onRoomEnter {mobList=""}
And this resets the variable when you move, assuming you make use of the mapper. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
chloeizzy Newbie
Joined: 14 Mar 2021 Posts: 5
|
Posted: Sun Nov 21, 2021 11:30 pm |
shalimar wrote: |
I would suggest a mini dbVar to handle this:
Code: |
#TR {~(R~) You would stomp (*) into the ground.} {
$mob=%1
$count=(%int(%db(@roomMobs, $mob))+1)
#ADDKEY roomMobs $mob $count
#ALARM "populater" +.5 {#RAISE countThemAll}
} |
This will capture all the mobs, and count anything that repeats.
Code: |
#EVENT countThemAll {
#FORALL %dbkeys(@roomMobs) {
$count=%db(@roomMobs, %i)
#LOOP $count {#ADDITEM mobList %concat(%j, ".", %i)}
}
roomMobs=""
} |
This populates a new variable @mobList
#EVENT onRoomEnter {mobList=""}
And this resets the variable when you move, assuming you make use of the mapper. |
Wow thank you!
Didn't know I could use %int in that way. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|