|  | 
	
	
		| Aleron Wanderer
 
 
 Joined: 01 Aug 2005
 Posts: 76
 
 
 | 
			
			  |  Posted: Fri Mar 16, 2007 2:21 am 
 Package Scope
 
 |  
				| I'm trying to understand the scope rules for the new package feature, and I need some help.  I've created a new session called TEST, so it gets a package called TEST.  I then created another package called YAP (yet another package) that got added to the session.  I then created another package called YAP2.  Now, I then created a variable in TEST named testVariable.  In the YAP package, I created an alias named test that attempts to print the value of testVariable with the #ECHO command.  Even if I enable the TEST package as visible for the YAP package/module, I cannot access testVariable from inside YAP.  I cannot get access to testVariable until I move it into YAP2 and make YAP2 visible to YAP. 
 If this description of the packages/settings isn't clear, here's a picture of the 'All Packages' view in the package/settings editor.
 
 What is going on?  If I enable it making is visible/usable, should I not be able to see/use it, even if it's in the default session package?
 |  | 
	
	  |  | 
	
		|  | 
	
		| Fang Xianfu GURU
 
  
 Joined: 26 Jan 2004
 Posts: 5155
 Location: United Kingdom
 
 | 
			
			  |  Posted: Fri Mar 16, 2007 2:36 am 
 |  
				| The variable's inside a window. Settings inside windows aren't ever visible to any settings outside that window. In order to make the setting visible outside the window, you need to put it in a module. In order to make the setting visible outside the package, you need to set that module either to Global or External publication. 
 So to make the variable accesible to the YAP alias, create a module inside the TEST package and set it to Global. Move testVariable inside it and you're done.
 |  | 
	
	  |  | 
	
		|  | 
	
		| Aleron Wanderer
 
 
 Joined: 01 Aug 2005
 Posts: 76
 
 
 | 
			
			  |  Posted: Fri Mar 16, 2007 2:52 am 
 |  
				| Ah, interesting. Thank you very much for clearing that up. 
 |  | 
	
	  |  | 
	
		|  | 
	
		| hogarius Adept
 
 
 Joined: 29 Jan 2003
 Posts: 221
 Location: islands.genesismuds.org
 
 | 
			
			  |  Posted: Fri Mar 16, 2007 11:07 am 
 |  
				| Fang, that simple explanation was wonderful.  I've not really needed or tried to mess with packages and modules and such, but your short reply "clicked" and helps me understand them and their relationships better than everything I've seen, even if I still don't need to use them. 
 Sometimes concise is very cool.  Well done!
 |  | 
	
	  |  | 
	
		|  | 
	
		| Aleron Wanderer
 
 
 Joined: 01 Aug 2005
 Posts: 76
 
 
 | 
			
			  |  Posted: Fri Mar 16, 2007 11:41 am 
 |  
				| 
 
	  | hogarius wrote: |  
	  | Fang, that simple explanation was wonderful. I've not really needed or tried to mess with packages and modules and such, but your short reply "clicked" and helps me understand them and their relationships better than everything I've seen, even if I still don't need to use them. |  
 Agreed.  That piece helped me realize how to structure all my scripts in CMUD.  I figured if anything in another package couldn't see my settings in the main package (that were under the main window), I'd just put everything in external packages.  That's not the way I wanted to go. :)
 |  | 
	
	  |  | 
	
		|  | 
	
		| bishopnenar Beginner
 
 
 Joined: 20 Mar 2007
 Posts: 27
 
 
 | 
			
			  |  Posted: Tue Mar 20, 2007 5:39 pm 
 |  
				| I have been having a similar problem. 
 I have this:
 
 - [Main Window]
 |          |
 |          |_ [Main Module] (set to global)
 |
 |
 |
 |
 -[New Package] (set to global)
 
 In "Main Module" I have the HEALTH variable.
 In "New Package" I have the following alias;
 #ALIAS autosip {#IF (@health<@htd) {drink health} {#ECHO Nothing}}
 
 Very basic, but every time I autosip, I drink health no matter what my health is. HTD is a set number that is figured with triggers in "New Package".
 Thought I set everything as mentioned in this topic, but doesn't seem to work for me.
 
 Any advice?
 
 
 Later I tried just moving everything need to the "New Package" and for some reason my #IF is reading backwards?! My Health is GREATER THEN the htd number and it tries to drink health?!
 |  | 
	
	  |  | 
	
		|  | 
	
		| Tech GURU
 
  
 Joined: 18 Oct 2000
 Posts: 2733
 Location: Atlanta, USA
 
 | 
			
			  |  Posted: Tue Mar 20, 2007 6:37 pm 
 |  
				| Well for starters, you have you module under your window.  This should not be.  They are not designed to work like that (it's an outstanding to-do for Zugg to disable the capability to do so.). 
 Try this organization.
 
 
 - [Main Window]
 |
 - [Main Module]
 |
 |
 - [New Package]
 
 
 If that still doesn't work try putting a space in the command like so.  I'm not are of any parsing issues in this scenario but it's possible you uncovered a parsing error.  i can't test this since I'm not able to access CMUD at work.
 
 #ALIAS autosip {#IF (@health < @htd) {drink health} {#ECHO Nothing}}
 |  | 
	
	  | 
		    
			  | _________________ Asati di tempari!
 |   |  | 
	
		|  | 
	
		| Fang Xianfu GURU
 
  
 Joined: 26 Jan 2004
 Posts: 5155
 Location: United Kingdom
 
 | 
			
			  |  Posted: Wed Mar 21, 2007 1:34 am 
 |  
				| Also, my advice would be that if you don't intend to give out your packages, you probably don't need to use them. Packages overcomplicate things in most situations. That said, there's definitely something weird going on here. 
 I recreated the scenario you describe (minus the improper module placement) and had the alias print the value of @health that it was seeing - it always printed null. Since null's interpreted as 0 by expression evaluation, that's why it's always coming out as true.
 
 This shouldn't be happening, because the alias will look in global modules after it's looked in the current package, won't it? Can anyone else confirm this happening.
 
 If it does turn out to be a bug you should start another thread too.
 |  | 
	
	  |  | 
	
		|  | 
	
		| bishopnenar Beginner
 
 
 Joined: 20 Mar 2007
 Posts: 27
 
 
 | 
			
			  |  Posted: Thu Mar 22, 2007 12:01 am 
 |  
				| 
 
	  | Fang Xianfu wrote: |  
	  | This shouldn't be happening, because the alias will look in global modules after it's looked in the current package, won't it? Can anyone else confirm this happening.
 
 If it does turn out to be a bug you should start another thread too.
 |  
 Got the modules right, seems to work.
 
 BUT, I have everything under one main module now (for the chuck of my coding) I was writting a VERY basic #IF
 
 #IF (@flame) {belch;morph jaguar} {morph jaguar}
 
 @flame was TRUE, the alias kept firing the false statement. I tried #If (@flame = 1) and #IF (@flame=1).
 
 Is there something simply wrong with my Cmud? This should be the most basic #IF, correct? Again the alias and variable are in different class folders but the same module.
 
 Please any advice. Here is the compiled code too if that helps:
 0000	LINE	0	; #IF (@flame) {belch;morph jaguar} {morph jaguar}
 0012	PUSHEXP	0028
 0020	JUMP	0064
 0028	VARREF	@flame <flame>	(class Aetolia)
 0052	SETEXP	0	0
 0064	ARGSTR	@flame
 0080	PUSHLOC	0096
 0088	JUMP	0168
 0096	ALIAS	belch (-1) <?>	(class Aetolia)
 0124	STR	'jaguar'
 0140	ALIAS	morph (1) <?>	(class Aetolia)
 0168	ARGSTR	belch;morph jaguar
 0196	PUSHLOC	0212
 0204	JUMP	0256
 0212	STR	'jaguar'
 0228	ALIAS	morph (1) <?>	(class Aetolia)
 0256	ARGSTR	morph jaguar
 0276	CMD	if	(3)
 |  | 
	
	  |  | 
	
		|  | 
	
		| Fang Xianfu GURU
 
  
 Joined: 26 Jan 2004
 Posts: 5155
 Location: United Kingdom
 
 | 
			
			  |  Posted: Thu Mar 22, 2007 1:04 am 
 |  
				| Post a new thread about this bug and Zugg will take a look at it. I can't get the different classes thing to fail, which would suggest that your package is corrupt, but the different packages thing still fails even with totally new packages. They'll probably suggest that you mail the package to support@zuggsoft.com, but post the thread to make sure. 
 |  | 
	
	  |  | 
	
		|  | 
	
		| Tech GURU
 
  
 Joined: 18 Oct 2000
 Posts: 2733
 Location: Atlanta, USA
 
 | 
			
			  |  Posted: Thu Mar 22, 2007 7:48 am 
 |  
				| I agree with Fang... I just tested your #if statement and it works perfectly fine here.  So I suspect your package maybe messed up from earlier versions. 
 |  | 
	
	  | 
		    
			  | _________________ Asati di tempari!
 |   |  | 
	
		|  | 
	
		|  | 
	
		|  |