lua:scripting:examples:qtimerluavals
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lua:scripting:examples:qtimerluavals [2014/12/31 19:22] – vodur | lua:scripting:examples:qtimerluavals [2015/01/01 00:53] (current) – vodur | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code lua>-- Kain GRALL code for sack of rice | + | ====== Original ====== |
- | say(" | + | <code lua> |
+ | -- Kain GRALL code for sack of rice | ||
+ | say(" | ||
+ | emote(" | ||
-- Kain greet code to start quest | -- Kain greet code to start quest | ||
local ricevnum=7326 | local ricevnum=7326 | ||
Line 19: | Line 22: | ||
</ | </ | ||
- | <code lua> | + | <code lua>-- Kain give code |
- | -- Kain give code | + | |
local ricevnum=7326 | local ricevnum=7326 | ||
local qvnum=14800 | local qvnum=14800 | ||
+ | |||
-- Does he want it? | -- Does he want it? | ||
if not(obj1.vnum==ricevnum) then | if not(obj1.vnum==ricevnum) then | ||
Line 31: | Line 33: | ||
return | return | ||
end | end | ||
+ | |||
-- check if their timer is still running | -- check if their timer is still running | ||
if ch: | if ch: | ||
Line 39: | Line 41: | ||
return | return | ||
end | end | ||
+ | |||
-- check if already gave that one | -- check if already gave that one | ||
tracker=tracker or {} | tracker=tracker or {} | ||
Line 48: | Line 50: | ||
return | return | ||
end | end | ||
+ | |||
-- He really wants it! | -- He really wants it! | ||
if tracker[ch.name]==nil then | if tracker[ch.name]==nil then | ||
Line 55: | Line 57: | ||
tracker[ch.name][obj1.vnum]=true | tracker[ch.name][obj1.vnum]=true | ||
say(" | say(" | ||
+ | |||
-- Now see if finished | -- Now see if finished | ||
if tracker[ch.name][ricevnum] then -- Has the rice | if tracker[ch.name][ricevnum] then -- Has the rice | ||
- | qset(ch, qvnum, 1, 23) | + | qset(ch, qvnum, 1, 24) |
say(" | say(" | ||
mdo(" | mdo(" | ||
Line 66: | Line 68: | ||
say("I still need a %s", getobjproto( (not(tracker[ch.name][ricevnum]))).shortdescr) | say("I still need a %s", getobjproto( (not(tracker[ch.name][ricevnum]))).shortdescr) | ||
end | end | ||
+ | |||
-- End Kain give code | -- End Kain give code | ||
+ | </ | ||
- | NEWLINE | + | ===== With luavals ===== |
+ | <code lua> | ||
+ | -- Kain GRALL code for sack of rice | ||
+ | say(" | ||
+ | emote(" | ||
+ | -- Kain greet code to start quest | ||
+ | local ricevnum=7326 | ||
+ | -- Don't give quest if timer is still running | ||
+ | local time_current=os.time() | ||
+ | local time_quest=ch: | ||
+ | if time_quest> | ||
+ | say(" | ||
+ | return | ||
+ | end | ||
+ | -- Don't talk them if already gave something | ||
+ | tracker=tracker or {} | ||
+ | if tracker[ch.name] then return end | ||
+ | |||
+ | say(" | ||
+ | ch.name, | ||
+ | getobjproto(ricevnum).shortdescr) | ||
+ | -- End Kain greet code | ||
+ | </ | ||
+ | |||
+ | <code lua> | ||
+ | -- Kain give code | ||
+ | local ricevnum=7326 | ||
+ | local qvnum=14800 | ||
+ | |||
+ | -- Does he want it? | ||
+ | if not(obj1.vnum==ricevnum) then | ||
+ | say("I don't want this." | ||
+ | mdo(" | ||
+ | mdo(" | ||
+ | return | ||
+ | end | ||
+ | |||
+ | -- check if their timer is still running | ||
+ | local time_current=os.time() | ||
+ | local time_quest=ch: | ||
+ | if time_quest> | ||
+ | say(" | ||
+ | mdo(" | ||
+ | mdo(" | ||
+ | return | ||
+ | end | ||
+ | |||
+ | -- check if already gave that one | ||
+ | tracker=tracker or {} | ||
+ | if tracker[ch.name] and tracker[ch.name][obj1.vnum] then | ||
+ | say(" | ||
+ | mdo(" | ||
+ | mdo(" | ||
+ | return | ||
+ | end | ||
+ | |||
+ | -- He really wants it! | ||
+ | if tracker[ch.name]==nil then | ||
+ | tracker[ch.name]={} | ||
+ | end | ||
+ | tracker[ch.name][obj1.vnum]=true | ||
+ | say(" | ||
+ | |||
+ | -- Now see if finished | ||
+ | if tracker[ch.name][ricevnum] then -- Has the rice | ||
+ | qset(ch, qvnum, 1, 24) | ||
+ | ch: | ||
+ | say(" | ||
+ | mdo(" | ||
+ | reward(ch, " | ||
+ | tracker[ch.name]=nil | ||
+ | else | ||
+ | say("I still need a %s", getobjproto( (not(tracker[ch.name][ricevnum]))).shortdescr) | ||
+ | end | ||
+ | |||
+ | -- End Kain give code | ||
</ | </ | ||
lua/scripting/examples/qtimerluavals.1420053756.txt.gz · Last modified: 2014/12/31 19:22 by vodur