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


Joined: 03 Apr 2006
Posts: 29

PostPosted: Thu May 22, 2014 4:52 pm   

Ship locator in LUA
 
Hello,

I have found and interesting script written in LUA for mushclient and I am trying to figure out how to translate it in something that can work with CMUD w/LUA. Do you have any manuals online that can tutor, walk through a person in programming in Lua with in CMUD?

Thanks

<aliases>
<alias name="ships" match="ships" enabled="y" group="script-ships" send_to="12" sequence="100">
<send>http = require "socket.http"
page, retcode, header = http.request("http://iota.materiamagica.com/online/sysinfo.txt")
if (retcode == 200) then
wstart = string.find(page, "Merdraco", 0, true)
wend = string.find(page, "#END", 0, true)
where = string.sub(page, wstart, wend - 1)
Note(where)
else
Note("Sorry, couldn't read sysinfo page")
end</send>
</alias>
</aliases> Embarassed
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu May 22, 2014 6:59 pm   
 
There is, in the CMUD Manual. At a glance, the only change you should need to make to that script is that the MUSHclient Note() function is print() in CMUD. You'll also need the LuaSocket library installed - instuctions on that here.
Reply with quote
edb6377
Magician


Joined: 29 Nov 2005
Posts: 482

PostPosted: Sat Mar 21, 2015 10:54 pm   
 
Something like this?

Code:

iotaparam={}
iotaparam.iota = zs.param(1)
if not http then http = require("socket.http") end;
  local page, retcode, header = http.request("http://iota.materiamagica.com/online/sysinfo.txt")
if iotaparam.iota == "ship" then
  if (retcode == 200) then
    wstart = string.find(page, "Merdraco", 0, true)
    wend = string.find(page, "#END", 0, true)
    where = string.sub(page, wstart, wend - 1)
    zs.print("\n")
    zs.print("\027[1;37m<------------------------ Ship Locator -------------------------->")
    zs.print("\027[1;37m"..where)
  else
    zs.print("\027[1;37mSorry, couldn't read sysinfo page");
  end
elseif iotaparam.iota == "moon" then
 if (retcode == 200) then
    wstart = string.find(page, "Trigael", 0, true)
    wend = string.find(page, "Alyrian", 0, true)
    where = string.sub(page, wstart, wend - 1)
    zs.print("\n")
    zs.print("\027[1;37m<--------- MOON Locator -------->")
    zs.print("\027[1;37m"..where)
  else
    zs.print("\027[1;37mSorry, couldn't read sysinfo page");
  end
elseif iotaparam.iota == "worldgate" then
 if (retcode == 200) then
    wstart = string.find(page, "A worldgate", 0, true)
    wend = string.find(page, "Merdraco", 0, true)
    where = string.sub(page, wstart, wend - 1)
    zs.print("\n")
    zs.print("\027[1;37m<------------------------ WG Locator -------------------------->")
    zs.print("\027[1;37m"..where)
  else
    zs.print("\027[1;37mSorry, couldn't read sysinfo page");
  end
else
  zs.print("\027[1;37mValid Commands are ship, moons, worldgate")
end



Tamlin - Materiamagica
_________________
Confucious say "Bugs in Programs need Hammer"
Reply with quote
SBG
Novice


Joined: 05 Mar 2003
Posts: 44
Location: Australia

PostPosted: Wed Mar 25, 2015 5:06 pm   
 
Very cool edb6377, been looking into this sort of thing for a while now and could never get it working, I'm not flash on lua, so a very big thanks from me!
and all the great packagers for MM while I'm at it :-)
Zore - Materiamagica
_________________
Windows 7U x64 SP1
AMD Phenom X4 9650
8 Gig mem
CMUD Pro v3.34
Zmapper v1.30
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