This shows you the differences between two versions of the page.
lua:scripting:examples:turninobjects [2014/12/24 05:44] vodur created |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <code lua> | + | |
- | -- Initializes the tracker variable with empty names if it doesn't exist | + | |
- | tracker = tracker or { | + | |
- | [18405] = "", | + | |
- | [18406] = "", | + | |
- | [18407] = "", | + | |
- | [18408] = "", | + | |
- | [18409] = "", | + | |
- | [18410] = "", | + | |
- | [18411] = "", | + | |
- | [18412] = "", | + | |
- | [18413] = "", | + | |
- | [18425] = "", | + | |
- | [18430] = "", | + | |
- | } | + | |
- | + | ||
- | if tracker[obj1.vnum] == nil then -- We don't want this thing | + | |
- | say("I don't want that!") | + | |
- | mdo("drop %s", obj1.name) | + | |
- | return | + | |
- | end | + | |
- | + | ||
- | if tracker[obj1.vnum] == ch.name then -- Player was the last one to give it | + | |
- | say("You were the last one to give me that already!") | + | |
- | mdo("give '%s' %s", obj1.name, ch.name) | + | |
- | mdo("drop %s", obj1.name) | + | |
- | return | + | |
- | end | + | |
- | + | ||
- | -- If we got here then we need to reward and track the player | + | |
- | say("Thanks %s! Just what I was looking for!", ch.name) | + | |
- | obj1:destroy() | + | |
- | reward(ch, "qp", 5) | + | |
- | tracker[obj1.vnum]=ch.name | + | |
- | </code> | + |