|
thargy Beginner
Joined: 10 Aug 2004 Posts: 20 Location: UK, Uganda
|
Posted: Sun Sep 26, 2004 9:26 pm
Problem with %roomcol function |
Now I know there's hundreds of scripts that may seem similar to this, I you may think it's been answered before, but I've read through the forums, and apart from one unanswered one (http://www.emobius.com/phpbb/viewtopic.php?t=14146) which infurs a similar problem, this seems to have gone unnoticed.
I wrote the following code to color all the rooms in a zone yellow, should be real easy...
Code: |
#CALL %roommode(0)
#CALL %mapfilter( "")
#CALL %mapfilter(%concat("ZoneID = 50"))
#VAR Run_RoomList {}
#SHOW {Creating for %numrooms rooms...}
#CALL %maplocked(0)
#LOOP %numrooms {
#ADDITEM Run_RoomList {%mapvnum( %i)}
#CALL %roomcol(1031,yellow)
}
#SHOW Done
#SHOW @Run_RoomList |
Quote: |
Output:
Creating for 140 rooms...
Done
1031|-1 |
Notes:
The roommode is set correctly to use vnums.
The filter is first cleared before being set (note that failure to do this can cause the real filter to miss)
The map is unlocked before changing colours
A room list is created, for future use, but is also output at the end so that you can compare the results.
As you can see once you call %roomcol the %mapvnum returns -1 from then on. It doesn't matter what you but in the %roomcol function (eg I tried with %roomcol(1031,yellow) ). The loop does continue through all 140 iterations so %i is not being corrupted (tested this).
If we pull %roomcol into its own loop...not using the %mapvnum() function any more, (which doesn't work - I've not shown all the tests I've done for brevity) but using the roomvnums stored in our string list:
Code: |
#CALL %roommode(0)
#CALL %mapfilter( "")
#CALL %mapfilter(%concat("ZoneID = 50"))
#VAR Run_RoomList {}
#SHOW {Creating for %numrooms rooms...}
#CALL %maplocked(0)
#LOOP %numrooms {#ADDITEM Run_RoomList {%mapvnum( %i)}}
#SHOW @Run_RoomList
#FORALL @Run_RoomList {
#CALL %roomcol(%number(%i),yellow)
#SHOWPROMPT %concat( %number( %i), "|")
}
#SHOW {}
#SHOW Done |
Quote: |
Output:
Creating for 140 rooms...
1031|1032|1033|1034|1035|1036|1037|1038|1039|1040|1041|1042|1043|1044|1045|
1046|1047|1048|1049|1050|1051|1052|1053|1054|1055|1056|1057|1058|1059|1060|
1061|1062|1063|1064|1065|1066|1067|1068|1069|1070|1071|1072|1073|1074|1075|
...truncated for brevity
1031|1032|1033|1034|1035|1036|1037|1038|1039|1040|1041|1042|1043|1044|1045|
1046|1047|1048|1049|1050|1051|1052|1053|1054|1055|1056|1057|1058|1059|1060|
1061|1062|1063|1064|1065|1066|1067|1068|1069|1070|1071|1072|1073|1074|1075|
...truncated for brevity
Done
|
Please note I've tried with and without the %number function.
As you can see the correct room numbers are now being sent to the roomcol function, however it still doesn't work. Only the first room (1031) is colored, this is not necessarily the current room (tested).
Entering #CALL %roomcol(1070,yellow) in to the command line, immediately after executing the code, colors the relevant room correctly. I tried this for a number of rooms, without any problems.
Placing a number of calls to color specific rooms in an alias then running, also works fine. All the rest of the code shown above was tried in command line and alias.
This has driven me absolutely nuts trying to get my head around, please try any 'solutions' you get, the above solution is very similar to code that has been posted before, yet it doesn't work for me. Please actually try the code yourself to see if I'm the only one with this problem.
Thanks
Craig |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Mon Sep 27, 2004 4:15 am |
Ok I havn't tested your script as its late (will test when I have time) but I think the problem could lie in either %mapfilter or %mapvnum,
With the addition of %mapquery in the newer versions of zmud I have givin up on %mapfilter.
If your mud doesn't give you the actual vnum of the room (most muds don't) I recomend using %roommode(1) for all your map functions. Here is something like what I use (I use record number and not vnum so I will give examples of both):
#ALIAS Colorrooms {
#CALL %maplocked(0)
#FORALL %mapquery({[ZONEID] = 50}) {#CALL %roomcol(%i,yellow)} //with roommode(1) recordnumber
#FORALL %mapquery({[ZONEID] = 50}) {#CALL %roomcol(%roomnum(%i),yellow)} //with roommoed(0) vnum
} |
|
|
|
thargy Beginner
Joined: 10 Aug 2004 Posts: 20 Location: UK, Uganda
|
Posted: Mon Sep 27, 2004 3:29 pm |
Thanks so much, that fixed it, the trick was obviously to avoid mapfilter, which must now be buggy or something.
|
|
|
|
|
|
|
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
|
|