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
TGH
Beginner


Joined: 22 Nov 2025
Posts: 18

PostPosted: Mon Mar 30, 2026 9:08 am   

Adding path to variable
 
What am I doing wrong that I cannot get a variable path added to a local variable?

Code:
// fmob $MOB $area
// Find a MOB in an area. If no area given use current area.
#LOCAL $zone
$MOB=%1

#SWITCH (%numparam())
  (0) {
    #WIN MobLocation "MOB is mandatory."
    #WIN MobLocation " "
    #WIN MobLocation "USAGE:  fmob MOB [zone]"
    #WIN MobLocation "Current zone used if not specified."
    #EXIT
    }
  (1) {
    $zone=%gmcp.room.info.zone
    }
  (2) {
    $zone=%2
    }

$roomNums=%dbkeys(@MOBDB_VARS/$zone)

#FORALL $roomNums {
  #IF (%isvalue(%i,$MOB)) {
    #WIN MobLocation " "
    #WIN MobLocation $MOB "is in room" %i
    #EXIT
    }
  }


I have tried

@MOBDB_VARS/$zone
@{MOBDB_VARS/$zone}
@MOBDB_VARS/{$zone}
@MOBDB_VARS/${zone}
%concat(classpath,"/",$zone)

but nothing produces a working result.

Any suggestions?
Reply with quote
shalimar
GURU


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

PostPosted: Tue Mar 31, 2026 10:28 pm   
 
Have you tested that any of your local variables have a value, much less the correct one, with #ECHO #SAY or #PRINT?
if $zone itself is null you will get a false negative result even with correct syntax.
_________________
Discord server
Reply with quote
shalimar
GURU


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

PostPosted: Tue Mar 31, 2026 10:31 pm   
 
and try: %db(@mobdb_vars, $zone)
_________________
Discord server
Reply with quote
TGH
Beginner


Joined: 22 Nov 2025
Posts: 18

PostPosted: Thu Apr 02, 2026 6:38 pm   
 
MOBDB_VARS is a class note a variable and $zone will reference either current zone or a supplied zone.

Eg.

MOBDB_VARS/aardington
MOBDB_VARS/siege

each zone var will consist of room numbers (keys) and each room will have mobs I encountered (stringlist)
Reply with quote
shalimar
GURU


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

PostPosted: Tue Apr 07, 2026 1:49 pm   
 
Its not a matter of what the value should be.
In an ideal world things are always what they should be.
Testing is to verify that it is what it should be.
_________________
Discord server
Reply with quote
shalimar
GURU


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

PostPosted: Tue Apr 07, 2026 1:52 pm   
 
as to the pathing issue, local variables dont have a path, they are stored in memory and only exisit within the code block they are called from, as soon as the relevant } is parsed, they are thrown away.

so trying to use a path at all is improper
_________________
Discord server
Reply with quote
TGH
Beginner


Joined: 22 Nov 2025
Posts: 18

PostPosted: Thu Apr 23, 2026 7:07 pm   
 
Maybe you got it wrong as I may have worded it badly.

I have a variable ($zone) made from %gmcp.room.info.zone which I want to add to the classpath zoneX to make zoneX/$zone. Then search each dbvar in the classpath (zoneX/$zone/dbvar) to locate a mob value in one of the vars.
Reply with quote
shalimar
GURU


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

PostPosted: Sun Apr 26, 2026 5:19 pm   
 
If it is a standalone variable, then your issue is syntax
$ = local variable, required for referencing and declaring
@ = normal variable, only used to reference, not to define

to define it in a zone you can do:

#VAR zone {%gmcp.room.info.zone} {} {zoneX}

then you can reference it with: @zoneX/zone
_________________
Discord server
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