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:18] – vodur | lua:scripting:examples:qtimerluavals [2015/01/01 00:53] (current) – vodur | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Original ====== | ====== Original ====== | ||
| - | + | <code lua> | |
| - | <code lua>-- Kain GRALL code for sack of rice | + | -- Kain GRALL code for sack of rice |
| - | say(" | + | say(" |
| emote(" | emote(" | ||
| -- Kain greet code to start quest | -- Kain greet code to start quest | ||
| Line 25: | 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> | |
| - | <code lua>-- Kain GRALL code for sack of rice | + | -- Kain GRALL code for sack of rice |
| - | say(" | + | say(" |
| + | emote(" | ||
| -- Kain greet code to start quest | -- Kain greet code to start quest | ||
| local ricevnum=7326 | local ricevnum=7326 | ||
| Line 40: | Line 82: | ||
| local time_current=os.time() | local time_current=os.time() | ||
| local time_quest=ch: | local time_quest=ch: | ||
| - | if time_quest> | + | if time_quest> |
| 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, | ||
| Line 54: | 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 | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | else | ||
| + | | ||
| + | end | ||
| + | |||
| + | -- End Kain give code | ||
| </ | </ | ||
lua/scripting/examples/qtimerluavals.1420064302.txt.gz · Last modified: 2014/12/31 22:18 by vodur