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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
aslanthekat
Novice


Joined: 17 Sep 2007
Posts: 44
Location: Missouri

PostPosted: Tue Sep 25, 2012 8:27 pm   

multiple sessions, same variable names
 
I have an OnTick Event that picks a random item from a list at random times.

Code:
#exe  %item(  @afk,  %random( 1, 3))
#ts %random( 30, 40)


It works perfectly. The only problem is when I have multiple sessions open. All sessions have their own onTick event and afk variable, filled with different values. The event still fires but all the sessions pick items from the afk var of the active session and not their own afk var.

I'm not quite sure why this happens or how to fix it.

As always, I appreciate your help.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Sep 25, 2012 8:44 pm   
 
Use explicit pathing to refer to variables. This prevents CMud from using its internal logic (which involves order of session loaded and window context) to figure out where to look for a variable or whatever. The explicit path makes that location the ONLY place it'll look.

@//window or module name/class/.../class/afk
_________________
EDIT: I didn't like my old signature
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Tue Sep 25, 2012 8:46 pm   
 
well, you can use focus to send the command to the main window of the session it should be done for.. not sure if that will fix all the scoping issues though

:char1:#SEND %item( @afk, %random( 1, 3))
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion 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