Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
atpeace
Novice


Joined: 26 Jan 2009
Posts: 32

PostPosted: Wed Jan 28, 2009 2:30 pm   

Mapper Room Scripts
 
I can not work out how to access Package variables via room scripts is there some additional syntax that needs to be applied?

Additionally Right clicking in the mapper and selecting execute room scripts only appears to work once.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Wed Jan 28, 2009 3:53 pm   
 
Looks bugged to me. Edit: Or more specifically, looks like a problem with scoping and having the mapper as its own object.

I can't verify the second part because now I can't get execute room scripts to work at all from the mapper, but I think I have a whole new post worth of problems.
Reply with quote
atpeace
Novice


Joined: 26 Jan 2009
Posts: 32

PostPosted: Wed Jan 28, 2009 11:37 pm   
 
Hmm well I seem to get some rather dubious and flaky success from using :

:Package:@Variable

So

#IF (:Achaea:@Personal.FoodLevel < 3) {#ECHO You're Hungry lets eat}

The variables are listed as undefined (red) in the editor in the room script though the above #if works for me as my package is called Achaea.mud and I have record variable Personal with a key Foodlevel.

#ECHO Level :Achaea:@Personal.FoodLevel

produces :
Level :Achaea:.FoodLevel

But interestingly :

:Achaea:_Debug {Your Food Level is @Personal.FoodLevel}

Successfully runs my _Debug alias which is a only a redirect alias to a window called debug and the text in that window is :

23:28:26 Your Food Level is 6

So partial success.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Jan 29, 2009 6:01 pm   
 
No, that is not the correct syntax. The :windowname: syntax is only intended to be used on the command line, or to send a command to another window. For example:

:Achaea:aliasname

*will* run your alias within the Achaea window. So that is correct. But you can only use this syntax at the beginning of a line with a command. It doesn't work within a #IF statement, etc.

The proper way to access a variable within a different window/module is with the syntax:

@//ModuleName/class/variable

For example:

#ECHO @//Achaea/Personal.FoodLevel

would be the correct syntax.
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Thu Jan 29, 2009 7:49 pm   
 
Zugg, I think there still is a bug with accessing variables in another PACKAGE from the map. (A simple test of creating a room script #echo @test and creating a variable @test in another package--that should be visible, and is visible from other modules in the same package as the map--fails for me.)

Variables in another module within the same package seem OK. Variables in windows aren't visible (because... variables in windows aren't published), and that's OK.
Reply with quote
atpeace
Novice


Joined: 26 Jan 2009
Posts: 32

PostPosted: Thu Jan 29, 2009 11:17 pm   
 
Ahh I see what's going on. There is an import complication with Zmud files. My stuff got imported as Achaea.mud

On renaming it as Achaea it all became a lot clearer. The syntax for referencing variables across packages doesn't like "."'s in the name, maybe they should be prohibited and the Zmud import ditch the .mud when creating the window?

Interestingly before making this change :Achaea: was working for the alias though the window was called Achaea.mud
Reply with quote
atpeace
Novice


Joined: 26 Jan 2009
Posts: 32

PostPosted: Thu Jan 29, 2009 11:33 pm   
 
But yeah then this doesn't even seem to compile, which is a guess as there is no reference to the compiler in the mapper scripts

#IF (@//Achaea/Personal.FoodLevel > 4) {#ECHO Fatty} {#ECHO Skinny}

doesn't do anything at all so I'm guessing failed a failed compile.

Ahhhhhhhhh

The cross package notation doesn't support the dot notation for record variables, leading to a failed compile which you're not notified about other than the non bold text in the script window for that room.

Now it is all clear to me.

The correct way to do this is :

#IF (%db(@//Achaea/Personal,FoodLevel) < 4) {eat} {go for a jog}
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Jan 30, 2009 12:22 am   
 
Another alternative is to do this
Code:
#IF ({@//Achaea/Personal.FoodLevel} > 4) {#ECHO Fatty} {#ECHO Skinny}


But using the the %db is much cleane and more legible code.

[Edit] You can also test your Room Script in alias to make sure it compiles, but I did submit a bug report/feature request that the compiled tab and syntax checker should be available for Room scripts as well.
_________________
Asati di tempari!
Reply with quote
atpeace
Novice


Joined: 26 Jan 2009
Posts: 32

PostPosted: Fri Jan 30, 2009 12:49 am   
 
Tech wrote:
Another alternative is to do this
Code:
#IF ({@//Achaea/Personal.FoodLevel} > 4) {#ECHO Fatty} {#ECHO Skinny}


But using the the %db is much cleane and more legible code.

[Edit] You can also test your Room Script in alias to make sure it compiles, but I did submit a bug report/feature request that the compiled tab and syntax checker should be available for Room scripts as well.


I wouldn't go suggesting that because it doesn't work.

It will compile within the package but in the mapper that syntax will not compile.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jan 30, 2009 5:44 pm   
 
I'll add the bug about the dot notation not working with the module/class syntax to the bug list.

gamma_ray: Yes, there is already a bug in the bug list from another post about accessing variables from within the map scripts

Quote:
Interestingly before making this change :Achaea: was working for the alias though the window was called Achaea.mud

That is because the :window: syntax matches any window name that *starts* with the specified string. You could have also just uses :A: and it would use the first window that it found that starts with the letter A. This was done because the : syntax is usually used on the command line when playing multiple characters in multiple windows and it gives you this shortcut to reduce command line typing.
Code:
#IF (%db(@//Achaea/Personal,FoodLevel) < 4) {eat} {go for a jog}

Yes, that is the correct way to do it.
Reply with quote
atpeace
Novice


Joined: 26 Jan 2009
Posts: 32

PostPosted: Fri Jan 30, 2009 6:12 pm   
 
I'll highlight my suggestion that package naming should prohibit names containing "."'s else using dots in syntax for record variables will require additional code for you Zugg with no perceivable benefit for the user. If you agree then maybe have a look at Zmud, Cmud import routine to lose the ".mud" naming on found Zmud packages.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Jan 30, 2009 11:42 pm   
 
I'll certainly change the zMUD import so that it doesn't add the ".mud" to the window name. Otherwise, there are a lot of cases where various non-alphanumeric characters are not allowed in various names (aliaes, variables, etc) and I have yet to design a good system for dealing with that.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net