|
aslanthekat Novice
Joined: 17 Sep 2007 Posts: 44 Location: Missouri
|
Posted: 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. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
|
|