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:46] – vodur | lua:scripting:examples:qtimerluavals [2015/01/01 00:53] (current) – vodur | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | !!!Original | + | ====== |
<code lua> | <code lua> | ||
-- Kain GRALL code for sack of rice | -- Kain GRALL code for sack of rice | ||
Line 8: | Line 8: | ||
local qvnum=14800 | local qvnum=14800 | ||
-- Don't give quest if timer is still running | -- Don't give quest if timer is still running | ||
- | if ch: | + | if ch: |
say(" | say(" | ||
- | return | + | return |
end | end | ||
-- Don't talk them if already gave something | -- Don't talk them if already gave something | ||
tracker=tracker or {} | tracker=tracker or {} | ||
if tracker[ch.name] then return end | if tracker[ch.name] then return end | ||
- | + | ||
say(" | say(" | ||
ch.name, | ch.name, | ||
getobjproto(ricevnum).shortdescr) | getobjproto(ricevnum).shortdescr) | ||
-- End Kain greet code | -- End Kain greet code | ||
- | |||
</ | </ | ||
- | <code lua> | + | <code lua>-- Kain give code |
- | -- Kain give code | + | |
local ricevnum=7326 | local ricevnum=7326 | ||
local qvnum=14800 | local qvnum=14800 | ||
Line 62: | Line 60: | ||
-- 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 74: | Line 72: | ||
</ | </ | ||
- | !!!With luavals | + | ===== With luavals |
<code lua> | <code lua> | ||
-- Kain GRALL code for sack of rice | -- Kain GRALL code for sack of rice | ||
Line 81: | Line 79: | ||
-- Kain greet code to start quest | -- Kain greet code to start quest | ||
local ricevnum=7326 | local ricevnum=7326 | ||
+ | -- Don't give quest if timer is still running | ||
local time_current=os.time() | local time_current=os.time() | ||
- | local time_quest=ch: | + | local time_quest=ch: |
- | + | if time_quest> | |
- | -- Don't give quest if timer is still running | + | say(" |
- | if time_current< | + | |
- | say(" | + | |
- | | + | |
return | return | ||
end | end | ||
Line 98: | Line 94: | ||
getobjproto(ricevnum).shortdescr) | getobjproto(ricevnum).shortdescr) | ||
-- End Kain greet code | -- End Kain greet code | ||
- | |||
</ | </ | ||
Line 105: | Line 100: | ||
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 115: | Line 110: | ||
-- check if their timer is still running | -- check if their timer is still running | ||
- | if ch:qtimer(qvnum)>0 then | + | local time_current=os.time() |
- | say(" | + | local time_quest=ch:getval(" |
+ | if time_quest> | ||
+ | say(" | ||
mdo(" | mdo(" | ||
mdo(" | mdo(" | ||
Line 140: | Line 137: | ||
-- 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) |
+ | ch: | ||
say(" | say(" | ||
mdo(" | mdo(" | ||
Line 151: | Line 149: | ||
-- End Kain give code | -- End Kain give code | ||
</ | </ | ||
+ |
lua/scripting/examples/qtimerluavals.1420055202.txt.gz · Last modified: 2014/12/31 19:46 by vodur