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
hadar
Apprentice


Joined: 30 Aug 2009
Posts: 198
Location: my apt, in california

PostPosted: Tue May 22, 2012 5:34 am   

Function Help
 
so im using this code

[code]<func name="lrename" id="3559">
<value>#call %match($names,"(%w),(%w)", $oldname, $newname)
#VA %proper($newname)_DB %null {_nodef} promo_%left(%lower($newname),1)
#loopdb @{%proper($oldname)_DB} {$line=%proper($newname)_DB %key %val;#addkey $line;#echo $line}
#DELITEM boot_clanlist %proper($oldname)
#ADDITEM boot_clanlist %proper($newname)
#unvar ${oldname}_DB</value>
<arglist>$leader,$names</arglist>
</func>


what it is susposta do is in the event of a rename of someone in my clan on my mud, it is susposta create/copy over then information from the old VAR then delete the old VAR, what is happening, is that its creating the new VAR for me, but its not fiiling in the information on the #loopdb, and the #unvar does not work, any suggestions? and i have my #loopdb the way it is for debugging purposes
_________________
if you build it they will come, assuming that they have not already come to build it
Aardwolf Bootcamp
My youtube channel
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue May 22, 2012 12:47 pm   
 
This isn't part of your problem, but can you give an example of how you are using this function? I'm confused by your %match(). It implies that the second argument is two names separated by a comma. Are you actually doing that?
Code:
@lrename(leader, "oldname,newname")

Why not code it to so that you don't need to put quote around "oldname,newname"?
Code:
@lrename(leader, oldname, newname)


You have an awfully clunky way of copying the information from the old variable to the new variable. Why not just do
Code:
#VAR %proper($newname)_DB @{%proper(oldname)}_DB


To solve the problem with the #UNVAR:
Code:
#UNVAR %proper($oldname)_DB
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue May 22, 2012 12:52 pm   
 
In answer to why the #LOOPDB is not filling in the information, it is because in the command
Code:
#ADDKEY $line

$line is treated as a single object, which means it is the first parameter of the command. What you would need is:
Code:
#ADDKEY %proper($newname)_DB %key %val


But as I said before, there's no reason to add each key/value pair separately to the new variable. You can simply copy the entire old variable to the new variable.
Reply with quote
hadar
Apprentice


Joined: 30 Aug 2009
Posts: 198
Location: my apt, in california

PostPosted: Wed May 23, 2012 6:09 am   
 
i have changed it all thanks Rehab, actually i forgot that vars could be set with vars this is what i use now

Code:
#call %match( $names, "(%w),(%w)", $oldname, $newname)
#VA %proper( $newname)_DB %null {_nodef} promo_%left( %lower( $newname), 1)
#var %proper($newname)_DB @{%proper($oldname)_DB}
#DELITEM boot_clanlist %proper( $oldname)
#ADDITEM boot_clanlist %proper( $newname)
#unvar %concat(%proper($oldname),"_DB")


as for the whole %match thing its because i use a trigger and i pass %-3 to the function for the %match insted of making the trigger more of a pain then it is
_________________
if you build it they will come, assuming that they have not already come to build it
Aardwolf Bootcamp
My youtube channel
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed May 23, 2012 12:41 pm   
 
Well, since you have to do it either in the %match or in the trigger, you may as well do it in the trigger. %match does essentially the same parsing as the trigger, and perhaps not quite as efficiently. It would make your function much more logical, too, and easier to reuse in other situations. For instance, what if you wanted to make an alias to manually change a name?
Reply with quote
hadar
Apprentice


Joined: 30 Aug 2009
Posts: 198
Location: my apt, in california

PostPosted: Wed May 23, 2012 10:11 pm   
 
no need :P

Code:
<trigger priority="30920" id="3092">
  <pattern>^(%w) tells you '{alice|Alice},{| }(%w){| (*)}'$</pattern>
  <value>#local $local $foo
$local = %proper( %2)
$foo = %proper( %1)
#if ($local="Lhelp") {#call @lhelp( %1)}
#if ($local="Rename") {#call @lrename(%1,%-3)}
#if (%ismember( $local, @boot_clanlist)) {@ljoined( $foo, $local)}
#if (%ismember( $local, @hourlist)) {#call @alicedbl( %1)}</value>
</trigger>


i end up envoking my own triggers when i need to change something
_________________
if you build it they will come, assuming that they have not already come to build it
Aardwolf Bootcamp
My youtube channel
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu May 24, 2012 3:56 am   
 
You shouldn't be using {@ljoined($foo, $local)} like you are. You need to #EXEC, or #CALL it.
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