|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Tue Mar 20, 2007 10:35 am
Possible bug with #pick...or is it just my alias? |
Alright, this is a long alias. So, only try if you've really got nothing better to do. I made this script a couple of years back, it's basically a zMud equivalent of an in-game redit menu. It's part of a more complete script including a virtual walkthrough of the zone you create. It utilizes zMapper, and a transfer script to the MUD via the in-game redit. But all that's fairly beside the point for this specific problem. Whenever I try to break this alias down into its constituent parts, ie new lines instead of ;'s, in both the command prompt AND the script editor, it fails. Instead of working, the alias only outputs "{#var". Now, I know this indicates a missing brace, but there isn't one. It works fine, until you delete a ; and replace it with a new line. Any help would be appreciated.
Code: |
#alias Redit {#var SectorType %null;#var Roomflags %null;#var OptionSelected %null;#var Exitflags %null;#var CurrentExit %null;#var CurrentRoom {%number(%1)};#if (%null(@{Room%1})) {#var Room@{CurrentRoom} "" "_nodef" "RoomVariables"};#while (@OptionSelected != -1) {;#var OptionSelected %null;#pick {p:"Editing Room #"@{CurrentRoom}} {o:1} {"(1) Exits: #var OptionSelected 0"} {"(2) Roomflags:#var OptionSelected 9"} {"(3) Sector Type:#Var OptionSelected 10"} {"(4) Edit Extra Descriptions:#var OptionSelected 11"} {"(5) Delete Extra Descriptions:#var OptionSelected 12"} {"(6) Done, exit menu:#var OptionSelected -1"};#if (@OptionSelected=0) {#while (@OptionSelected=0) {#pick {p:"Select a direction to edit:"} {o:1} {"(1) None, go back:#var OptionSelected -2"} {"(2) North:#var OptionSelected 1"} {"(3) East:#var OptionSelected 2"} {"(4) South:#var OptionSelected 3"} {"(5) West:#var OptionSelected 4"} {"(6) Up:#var OptionSelected 5"} {"(7) Down:#var OptionSelected 6"}}};#if ((@optionSelected < 7) AND (@OptionSelected > 0)) {#var CurrentExit %item("north|east|south|west|up|down",@OptionSelected)};#if ((@optionSelected < 7) AND (@OptionSelected > 0)) {#if (%iskey(@{Room@{CurrentRoom}},@{CurrentExit}ExitDsc)) {#pick {p:"Select:"} {o:1} {"(1) Cancel:#var OptionSelected -2"} {"(2) Door:#var OptionSelected 7;#var Door 1"} {"(3) No Door:#var OptionSelected 8;#var door 0"} {"(4) Delete Exit":#yesno "Are you POSITIVE you wish to delete this exit?" {#delkey Room@{CurrentRoom} @{CurrentDirection}Flags;#delkey Room@{CurrentRoom} @{CurrentExit}DoorKeyword;#delkey Room@{CurrentRoom} @{CurrentExit}KeyVnum;#delkey Room@{CurrentRoom} @{CurrentExit}ExitDsc;#delkey Room@{CurrentRoom} @{CurrentExit}CharDpt;#delkey Room@{CurrentRoom} @{CurrentExit}RoomDpt;#delkey Room@{CurrentRoom} @{CurrentExit}ArriveMsg;#delkey Room@{CurrentRoom} @{CurrentExit}Door;#delkey Room@{CurrentRoom} @{CurrentExit}Flags}}} {#pick {"p:Select:"} {o:1} {"(1) Cancel:#var OptionSelected -2"} {"(2) Door:#var OptionSelected 7"} {"(3) No Door:#var OptionSelected 8"}}};#if (@OptionSelected=7) {#pick {p:"Creating new exit @CurrentExit:"} {"PickProof:#additem ExitFlags 1"} {"Automatically Opening:#additem ExitFlags 2"} {"Automatically Closing:#additem ExitFlags 3"} {"Automatically Locking:#additem ExitFlags 4"} {"Indestructible:#additem ExitFlags 5"} {"Nowedge:#additem ExitFlags 6"};#addkey Room@{CurrentRoom} @{CurrentExit}Door 1;#addkey Room@{CurrentRoom} @{CurrentExit}Flags {@ExitFlags};#addkey Room@{CurrentRoom} @{CurrentExit}DoorKeyword %prompt(%db(@{room@CurrentRoom},@{CurrentExit}DoorKeyword),"Enter the keywords for the door or return for default.");#addkey Room@{CurrentRoom} @{CurrentExit}KeyVnum %prompt(%db(@{room@CurrentRoom},@{CurrentExit}KeyVnum),"Enter the Vnum of the key or -1 for none. Return for default.");#addkey Room@{CurrentRoom} @{CurrentExit}ExitDsc %prompt(%db(@{room@CurrentRoom},@{CurrentExit}ExitDsc),"Enter the exit-description. Return for default. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @{CurrentExit}CharDpt %prompt(%db(@{room@CurrentRoom},@{CurrentExit}CharDpt),"Enter the char-departure message. Return for default. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @{CurrentExit}RoomDpt %prompt(%db(@{room@CurrentRoom},@{CurrentExit}RoomDpt),"Enter the room-departure message. Return for default. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @{CurrentExit}ArriveMsg %prompt(%db(@{room@CurrentRoom},@{CurrentExit}ArriveMsg),"Enter the arrival message. Return for default. Separate each line with a semicolon.")};#if (@OptionSelected=8) {#delkey Room@{CurrentRoom} @{CurrentExit}Door;#delkey Room@{CurrentRoom} @{CurrentExit}DoorKeyword;#delkey Room@{CurrentRoom} @{CurrentExit}Flags;#delkey Room@{CurrentRoom} @{CurrentExit}KeyVnum;#addkey Room@{CurrentRoom} @{CurrentExit}Door 0;#addkey Room@{CurrentRoom} @{CurrentExit}ExitDsc %prompt(%db(@{room@CurrentRoom},@{CurrentExit}ExitDsc),"Enter the exit-description. Return for default. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @{CurrentExit}CharDpt %prompt(%db(@{room@CurrentRoom},@{CurrentExit}CharDpt),"Enter the char-departure message. Return for default. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @{CurrentExit}RoomDpt %prompt(%db(@{room@CurrentRoom},@{CurrentExit}RoomDpt),"Enter the room-departure message. Return for default. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @{CurrentExit}ArriveMsg %prompt(%db(@{room@CurrentRoom},@{CurrentExit}ArriveMsg),"Enter the arrival message. Return for default. Separate each line with a semicolon.")};#if (@OptionSelected=9) {#var Roomflags %null;#pick {p:"Set Room Flags:"} {"Dark:#additem RoomFlags 1"} {"Death:#additem RoomFlags 2"} {"No Mob:#additem RoomFlags 3"} {"Indoors:#additem RoomFlags 4"} {"Peaceful:#additem RoomFlags 5"} {"Soundproof:#additem RoomFlags 6"} {"Chaotic:#additem RoomFlags 7"} {"No Magic:#additem RoomFlags 8"} {"Tunnel:#additem RoomFlags 9"} {"Private:#additem RoomFlags 10"} {"Godroom:#additem RoomFlags 11"} {"(BGS-Mark):#additem RoomFlags 12"} {"P-Killing:#additem RoomFlags 13"} {"GrGodRoom:#additem RoomFlags 14"} {"Improom:#additem RoomFlags 15"} {"Track:#additem RoomFlags 16"} {"Sounddead:#additem RoomFlags 17"} {"Battlearena:#additem RoomFlags 18"} {"No Transport:#additem RoomFlags 19"} {"No RQE:#additem RoomFlags 20"} {"SKYLIGHT:#additem RoomFlags 21"} {"NIGHTDARK:#additem RoomFlags 22"} {"MAGICDARKNESS:#additem RoomFlags 23"};#addkey Room@{CurrentRoom} Roomflags @RoomFlags};#if (@OptionSelected=10) {#var SectorType %null;#pick {p:"Select Sector Type:"} {o:1} {"(1) Inside:#additem SectorType 1"} {"(2) City:#additem SectorType 2"} {"(3) Field:#additem SectorType 3"} {"(4) Forest:#additem SectorType 4"} {"(5) Hills:#additem SectorType 5"} {"(6) Mountains:#additem SectorType 6"} {"(7) Water:#additem SectorType 7"} {"(8) Water no swim:#additem SectorType 8"} {"(9) Air:#additem SectorType 9"} {"(10) Desert:#additem SectorType 10"} {"(11) Arctic:#additem SectorType 11"} {"(12) Underwater:#additem SectorType 12"} {"(13) Jungle:#additem SectorType 13"} {"(14) Jungle City:#additem SectorType 14"};#addkey Room@{CurrentRoom} SectorType @SectorType};#if (@OptionSelected=11) {#while (@OptionSelected != -3) {;#var CurrentKey %null;#var Newkey %null;#var NewDesc %null;#pick {p:"Select a field to edit:"} {o:1} {"(1) None, go back.:#Var OptionSelected -3"} {"(2) Edit an existing field:#var OptionSelected 13"} {"(3) Create a new Field:#var OptionSelected 14"};#if (@OptionSelected=13) {#var CurrentKey %pick("p:Select a key to edit","o:1",%db(@{Room@CurrentRoom},ExtraDescKeys));#if (!%null(@CurrentKey)) {#var NewKey %prompt(@CurrentKey,"Enter the new keyword for the field or return to keep current keywords.");#if (@NewKey != @CurrentKey) {#addkey Room@{CurrentRoom} ExtraDescKeys %additem(%lower(@NewKey),%delitem(@CurrentKey,%db(@{Room@{CurrentRoom}},ExtraDescKeys)));#var NewDesc %prompt(%db(@{room@{currentroom}},@CurrentKey),"Enter the new description or return to keep current description. Separate each line with a semicolon.");#delkey Room@{CurrentRoom} @CurrentKey;#addkey Room@{CurrentRoom} @NewKey @NewDesc} {#var NewDesc %prompt(%db(@{room@{currentroom}},@CurrentKey),"Enter the new description or return to keep current description. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} @CurrentKey @NewDesc};};};#if (@OptionSelected=14) {#Prompt NewKey "Enter the keyword for the field or return for default.";#var NewDesc %prompt(%db(@{room@currentroom},@CurrentKey),"Enter the new description or return to keep current description. Separate each line with a semicolon.");#addkey Room@{CurrentRoom} ExtraDescKeys %additem(%lower(@NewKey),%delitem(@NewKey,%db(@{Room@{CurrentRoom}},ExtraDescKeys)));#addkey Room@{CurrentRoom} @NewKey @NewDesc};};};#if (@OptionSelected=12) {#var CurrentKey %null;#var CurrentKey %pick("p:Select a key to Delete","o:1",%db(@{Room@CurrentRoom},ExtraDescKeys));#if (!%null(@CurrentKey)) {#yesno "Are you POSITIVE you wish to DELETE this Extra-Description?" {"Yes:#delkey Room@{CurrentRoom} @CurrentKey;#addkey Room@{CurrentRoom} ExtraDescKeys %delitem(@CurrentKey,%db(@{Room@{CurrentRoom}},ExtraDescKeys))"}};};}} |
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Mar 20, 2007 11:39 pm |
;#if ((@optionSelected < 7) AND (@OptionSelected > 0)) {#var CurrentExit %item("north|east|south|west|up|down",@OptionSelected)};#if ((@optionSelected < 7) AND (@OptionSelected > 0)) {
I think you've got some duplication going that might be throwing off your bracket count. Two nested #IFs checking the same variables in the exact same way (which might be leftovers from you spotting a duplication error and trying to fix it previously? That was a huge annoyance for me when dealing with large aliases and triggers)...
Personally, if you already know what the steps are it might just be better and easier all around to rebuild the alias and transfer small bits to the new alias. Eventually you will come across the problem, and by going in small steps you will be able to sort out where the problem is and how to fix it. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Josiah.Bruns Apprentice
Joined: 04 Mar 2007 Posts: 103
|
Posted: Wed Mar 21, 2007 5:28 am |
Is this an april fools joke?
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed Mar 21, 2007 4:31 pm |
I believe I know why this happened. When I first took a crack at this I did a global replace on all ';' to '\n'. That resulted in code bits like
Code: |
#if ((@optionSelected < 7) AND (@OptionSelected > 0)) {#if (%iskey(@{Room@{CurrentRoom}},@{CurrentExit}ExitDsc)) {#pick {p:"Select:"} {o:1} {"(1) Cancel:#var OptionSelected -2"} {"(2) Door:#var OptionSelected 7
#var Door 1"} {"(3) No Door:#var OptionSelected 8
#var door 0"} {"(4) Delete Exit":#yesno "Are you POSITIVE you wish to delete this exit?" {#delkey Room@{CurrentRoom} @{CurrentDirection}Flags
|
The root of the problem is that this line
Code: |
#pick {p:"Select:"} {o:1} {"(1) Cancel:#var OptionSelected -2"} {"(2) Door:#var OptionSelected 7;#var Door 1"} {"(3) No Door:#var OptionSelected 8;#var door 0"} {"(4) Delete Exit":#yesno "Are you POSITIVE you wish to delete this exit?" {#delkey Room@{CurrentRoom} @{CurrentDirection}Flags
|
You've got a couple funky things happening. Since you have a the semi-colon within quotes a global replace will throw off the bat. Second, it doesn't seem like you properly close the #PICK option for deleting the exit. You may be trying to embed the #delkey commands in there, but I don't know if that works or not.
I'm not in front of CMUD, but I thought I'd take a crack at it with manual edit and my zMUD highlighter.
I hope that helps. |
|
_________________ Asati di tempari! |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Thu Mar 22, 2007 3:18 am |
You're right Matt, there is an extra #IF check I do not need, but that is not what is causing the problem. If you notice, the first check sets a variable to the value of what you just chose. Indeed, it is something that can be placed into the subsequent #if check instead of doing it twice. But the #if check is called properly, and cannot, as I see it, be causing this problem.
It is closed off properly, Tech. You need to continue until all the data for that exit has been deleted from the dbvar:
Code: |
#pick {p:"Select:"} {o:1} {"(1) Cancel:#var OptionSelected -2"} {"(2) Door:#var OptionSelected 7;#var Door 1"} {"(3) No Door:#var OptionSelected 8;#var door 0"} {"(4) Delete Exit":#yesno "Are you POSITIVE you wish to delete this exit?" {#delkey Room@{CurrentRoom} @{CurrentDirection}Flags;#delkey Room@{CurrentRoom} @{CurrentExit}DoorKeyword;#delkey Room@{CurrentRoom} @{CurrentExit}KeyVnum;#delkey Room@{CurrentRoom} @{CurrentExit}ExitDsc;#delkey Room@{CurrentRoom} @{CurrentExit}CharDpt;#delkey Room@{CurrentRoom} @{CurrentExit}RoomDpt;#delkey Room@{CurrentRoom} @{CurrentExit}ArriveMsg;#delkey Room@{CurrentRoom} @{CurrentExit}Door;#delkey Room@{CurrentRoom} @{CurrentExit}Flags}}} |
As for enbedding #delkey commands in there, it does work. The whole alias works when you install the alias via the command line as one big chunk of code, with no newlines only colons. But the moment you replace a colon with a newline, zMUD does not read/execute it properly. |
|
|
|
|
|
|
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
|
|