User Tools

Site Tools


lua:scripting:examples:runequestorig

Rune Quest (original version)

runevnum=31470
homevnum=31404
maxrune=50
checktime=nil
checkdelay=300 -- 5 mins
 
 
function runereward()
  local runes=getobjworld(runevnum)
  for _,rune in pairs(runes) do
    char=rune.carriedby
    if char then
      goto(char.room.vnum)
      if char:ispc() then
        echo(string.format("%s glows brightly and evaporates into the air!", rune.shortdescr))
        reward(string.format("%s qp 5", char.name) )
      end
    end
    rune:destroy()
  end
 
  goto(homevnum)
  mdo("chirp")
end
 
function place()
  local runes=getobjworld(runevnum)
  local count=table.getn(runes)
  if count >= maxrune then
    return
  end
 
  for i=1,maxrune-count do
    goto("wrandom")
    oload(runevnum)
    mdo("drop rune")
  end
 
  goto(homevnum)
end
 
function checkrunes()
  local currtime=os.time()
  if checktime==nil then
    checktime=currtime+checkdelay
    return
  elseif currtime<checktime then
    return
  end
 
  runereward()
  place()
 
  checktime=currtime+checkdelay
end
 
runeloaded=true
MOBPrograms for [31425]:
 Number Vnum Trigger Phrase
 ------ ---- ------- ------
[    0] 31404  RANDOM 100

Vnum:       [31404]
Lua:        True
Code:

if not runeloaded then
  loadscript("vodur", "rune1")
end

checkrunes()
lua/scripting/examples/runequestorig.txt · Last modified: 2014/12/24 05:39 by vodur