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
pptnj
Newbie


Joined: 07 Dec 2011
Posts: 1

PostPosted: Wed Dec 07, 2011 5:20 am   

about cmud 3.34 pro alias
 
hi guys, i have a question about cmud pro 3.34
that's when i creat an alias such as suma,and i set the scripting language is lua
the content of suma is:
function mysum(a,b)
return a+b
end
print(mysum(3,15))
however when i type suma in cmd window, i can't get the result of 18
but if i delete last print statement, use alias wizard ,and choose Execute alias or send command to the MUD,then choose add new step
and next input print(mysum(3,15)), the alias will work.
however, when i edit my alias, such as print(mysum(5,20)),the alias will error too. i have to repeat the previous step to make the alias work
is that sth i do wrong?
why the alias so trouble?
thanks for ur reply
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Thu Dec 08, 2011 2:45 am   
 
Put the Lua function inside a CMUD function:
Code:

<func name="suma" language="Lua" id="1055">
  <value>do
--
return zs.param(1) + zs.param(2)
--
end</value>
</func>

Then there is no problem calling it from the alias:
Code:

<alias name="mysum" id="1056">
  <value>$value = @suma(%1,%2)
;;
#PRINT $value</value>
</alias>

Now, if you type mysum 5 6 on the command line, 11 will show.
_________________
Sic itur ad astra.
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