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 22:04] – vodur | lua:scripting:examples:qtimerluavals [2015/01/01 00:53] (current) – vodur | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Original ====== | ====== Original ====== | ||
- | <code lua>-- Kain GRALL code for sack of rice | + | <code lua> |
- | say(" | + | -- 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 23: | Line 25: | ||
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 | ||
- | say("I don't want this." | + | say("I don't want this." |
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- check if their timer is still running | ||
+ | if ch: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- check if already gave that one | ||
+ | tracker=tracker or {} | ||
+ | if tracker[ch.name] and tracker[ch.name][obj1.vnum] then | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- He really wants it! | ||
+ | if tracker[ch.name]==nil then | ||
+ | | ||
+ | end | ||
+ | tracker[ch.name][obj1.vnum]=true | ||
+ | say(" | ||
+ | |||
+ | -- Now see if finished | ||
+ | if tracker[ch.name][ricevnum] then -- Has the rice | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | else | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- End Kain give code | ||
</ | </ | ||
===== With luavals ===== | ===== With luavals ===== | ||
- | <code lua>-- Kain GRALL code for sack of rice | + | <code lua> |
- | say(" | + | -- 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 | ||
+ | -- 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_quest> | + | return |
- | say(" | + | |
- | | + | |
- | 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, | ||
Line 53: | Line 96: | ||
</ | </ | ||
- | <code lua>-- Kain give code | + | <code lua> |
+ | -- Kain give code | ||
local ricevnum=7326 | local ricevnum=7326 | ||
+ | local qvnum=14800 | ||
-- Does he want it? | -- Does he want it? | ||
if not(obj1.vnum==ricevnum) then | if not(obj1.vnum==ricevnum) then | ||
- | say("I don't want this." | + | say("I don't want this." |
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- check if their timer is still running | ||
+ | local time_current=os.time() | ||
+ | local time_quest=ch: | ||
+ | if time_quest> | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- check if already gave that one | ||
+ | tracker=tracker or {} | ||
+ | if tracker[ch.name] and tracker[ch.name][obj1.vnum] then | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- He really wants it! | ||
+ | if tracker[ch.name]==nil then | ||
+ | | ||
+ | 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) | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | else | ||
+ | | ||
+ | end | ||
+ | |||
+ | -- End Kain give code | ||
</ | </ | ||
lua/scripting/examples/qtimerluavals.1420063483.txt.gz · Last modified: 2014/12/31 22:04 by vodur