|
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: 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 |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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 |
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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
$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. |
|
|
|
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: 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 |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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?
|
|
|
|
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: 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 |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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.
|
|
|
|
|
|
|
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
|
|