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


Joined: 27 Apr 2021
Posts: 4
Location: USA

PostPosted: Mon May 03, 2021 12:30 pm   

using #WA in an alias
 
trying to learn how to write an alias script using lua in the package editor with a function like #WA

#WA 2000 is suppose to send a command to wait for 2 seconds. I understand you can type these directly into the command line box, but
when putting them into a script using the package editor, I cannot make it work.

so if I have the following, where I want to pause for 2 seconds in between to commands:

1 send("put lockpick in pack ")
2
3 send("put strongbox in pack ")

how would I type in ' wait for 2 seconds' on line 2.
Reply with quote
shalimar
GURU


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

PostPosted: Mon May 03, 2021 8:10 pm   
 
Sounds like you have the language set to other than zScript.

P.S. You can have a block of lua code in your script with the #LUA command.
_________________
Discord: Shalimarwildcat
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Mon May 03, 2021 8:13 pm   
 
I'm no LUA expert, I have imported some settings that use a mix of normal zscript and LUA.

Example:
Code:
#if (%1 = "reset") {
  xpstats.xpgained=0
  killlist=""
  xrounds=0
  #lua {zs.var.combatsecondsreset=os.time(t)}
  totalgold=0
  } {
  #show "             Kill Listings                   "
  #show "         Mob Name          Xp"
  #show ""
  killlist2=(@killlist)
  #loop %eval( %numitems( @killlist)/2) {#show %format( "&20s &1s &7.0f", %pop( killlist2), ":", %pop( killlist2))}
  #show ""
  #show "              Xp Summary                        "
  #show "  Xp Gained          : "@xpstats.xpgained"                      "
  #show "  Xp per Mob         : "%eval( @xpstats.xpgained/%eval( %numitems( @killlist)/2))"    "
  #show "  Xp per Round       : "%eval( @xpstats.xpgained/@xrounds)" "
  #show "  Xp per Hour        : "%eval(@xpstats.xpgained/(@xrounds*2)*1800)" "
  #show "  Mobs Killed        : "%eval(%numitems(@killlist)/2)""
  #show "  Rounds per Mob     : "%eval(@xrounds/%numitems(@killlist/2))""
  #lua {zs.var.currenttime=os.time(t);zs.var.cefficiency=(((zs.var.xrounds*2)/(zs.var.currenttime-zs.var.combatsecondsreset))*100)}
  #show "  Combat Efficiency  : "%format(2.0,@cefficiency)%""
  #lua {zs.var.goldperhour=(zs.var.totalgold/(zs.var.currenttime-zs.var.combatsecondsreset))*3600}
  #show "  Gold / (per hr)    : "@totalgold "/" %int(@goldperhour)
  #show ""
  }


with a trigger to count rounds of combat, and another trigger to add 'mob killed' and 'exp gained' to the killlist var.

Just a stab in the dark but maybe creating a function like
Code:
function sleep(s)
  local ntime = os.time() + s
  repeat until os.time() > ntime
end


again no expert...
Reply with quote
knucklehead
Newbie


Joined: 27 Apr 2021
Posts: 4
Location: USA

PostPosted: Tue May 04, 2021 8:43 am   
 
Thanks for the quick responses.

Creating that function sleep.....where would I put it? Would it become a separate script somewhere
like a variable or something? A trigger?

I tried something simular in the alias I was referencing that I was trying to write and CMUD broke my
little code into 3 subsections and well, it still didnt work.
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 168

PostPosted: Tue May 04, 2021 11:30 am   
 
the function code I used was just a copy paste from a google search I found on creating a sleep/wait/pause in LUA. I personally know jack about LUA code or it's core functions so I really doubt that my sample as posted would work, but I could be wrong...
Someone with way more experience would have to chime in on that particular stuff to clarify... I was just mainly trying to show that you can use a mix of zScript and LUA in an alias script like in my main code box.
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