kessykins
Intermediate OT User
- Joined
- Mar 15, 2010
- Messages
- 297
- Reaction score
- 105
Ok so I'm trying to adjust this so 1 tool can be used on 3 seperate items to create different items..
The base of this lua was from a professions script however I screwed up trying to adjust it
This is the error it keeps giving me x.x
What did I do wrong?
The base of this lua was from a professions script however I screwed up trying to adjust it
This is the error it keeps giving me x.x
Code:
[23/08/2010 22:20:26] [Error - Action Interface]
[23/08/2010 22:20:26] data/actions/scripts/tools/slimy_common.lua:onUse
[23/08/2010 22:20:26] Description:
[23/08/2010 22:20:26] data/actions/scripts/tools/slimy_common.lua:49: attempt to index local 'item2' (a nil value)
[23/08/2010 22:20:26] stack traceback:
[23/08/2010 22:20:26] data/actions/scripts/tools/slimy_common.lua:49: in function <data/actions/scripts/tools/slimy_common.lua:48>
What did I do wrong?
Code:
local config = {
msgType = MESSAGE_INFO_DESCR,
cancel = "Your untrained hands broke the slimy object. Get a higher fist level to have a higher success rate!",
skill = SKILL_FIST,
skillReq = 10
}
local t = {
--items common slimy objects can turn into
[{1, 200}] = {skill = 15, commonitem = 1294, name = "small stone"},
[{201, 400}] = {skill = 15, commonitem = 4839, name = "bottle"},
[{401, 500}] = {skill = 15, commonitem = 2333, name = "stamped letter"},
[{501, 700}] = {skill = 15, commonitem = 5951, name = "fish tail"},
[{701, 1000}] = {skill = 1, destroyobj = "The slimy object was too delicate to clean off. It broke!"},
[{1001, 1500}] = {skill = 1, destroyvase = "You broke the fragile vase."}
}
local q = {
--items uncommon slimy objects can turn into
[{1, 100}] = {skill = 25, uncommonitem = 5917, name = "bandana"},
[{101, 400}] = {skill = 25, uncommonitem = 2050, name = "torch"},
[{401, 500}] = {skill = 25, uncommonitem = 5918, name = "pirate knee breeches"},
[{501, 600}] = {skill = 25, uncommonitem = 5462, name = "pirate boots"},
[{601, 700}] = {skill = 25, uncommonitem = 2670, name = "shrimp"},
[{701, 900}] = {skill = 25, uncommonitem = 2009, name = "green flask"},
[{901, 1100}] = {skill = 35, uncommonitem = 2260, name = "blank rune"},
[{1101, 1200}] = {skill = 35, uncommonitem = 2266, name = "antidote rune"},
[{1201, 1500}] = {skill = 1, destroyobj = "The slimy object was too delicate to clean off. It broke!"},
[{1501, 2000}] = {skill = 1, destroyvase = "You broke the fragile vase."}
}
local w = {
--items uncommon slimy objects can turn into
[{1, 200}] = {skill = 45, rareitem = 5899, name = "turtle shell"},
[{201, 400}] = {skill = 45, rareitem = 6097, name = "hook"},
[{401, 600}] = {skill = 55, rareitem = 5909, name = "white piece of cloth"},
[{601, 800}] = {skill = 55, rareitem = 5914, name = "yellow piece of cloth"},
[{801, 1000}] = {skill = 55, rareitem = 5912, name = "blue piece of cloth"},
[{1001,1300}] = {skill = 55, rareitem = 7364, name = "sniper arrow"},
[{1301, 1580}] = {skill = 60, rareitem = 10553, name = "uncommon slimy object"},
[{1581, 1700}] = {skill = 60, rareitem = 10557, name = "rare slimy object"},
[{1701, 1810}] = {skill = 60, rareitem = 11219, name = "gold compass"},
[{1811, 2111}] = {skill = 1, destroyobj = "The slimy object was too delicate to clean off. It broke!"},
[{2112, 2612}] = {skill = 1, destroyvase = "You broke the fragile vase."}
}
function onUse(cid, commonitem, uncommonitem, rareitem, fromposition, item2, toposition)
if isInArray(config.t, config.q, config.w, item2.itemid) and config.skillReq <= getPlayerSkill(cid, config.skill) then
if item2.itemid == 0 then
return 0
end
end
if item2.itemid == 10556 then
local r = math.random(1500), 1, nil
local skill = getPlayerSkill(cid, config.skill)
for i, k in pairs(t) do
if r >= i[1] and r <= i[2] then
if skill >= k.skill then
if k.commonitem then
doPlayerAddItem(cid, k.commonitem, 1)
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You cleaned off a "..k.name.."!")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
if k.destroyobj then
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, k.destroyobj)
doSendMagicEffect(getThingPos(cid), k.destroyobj and CONST_ME_BLOCKHIT)
end
if k.destroyvase then
doRemoveItem(item2.uid, 1)
doRemoveItem(commonitem.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, k.destroyvase)
doSendMagicEffect(getThingPos(cid), k.destroyvase and CONST_ME_WATERSPLASH)
doPlayerAddItem(cid, 2010, 1)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, config.cancel)
doSendMagicEffect(getThingPos(cid), CONST_ME_BLOCKHIT)
doRemoveItem(item2.uid, 1)
end
end
end
else
if item2.itemid == 10553 then
local r = math.random(2000), 1, nil
local skill = getPlayerSkill(cid, config.skill)
for j, l in pairs(q) do
if r >= j[1] and r <= j[2] then
if skill >= j.skill then
if j.uncommonitem then
doPlayerAddItem(cid, j.uncommonitem, 1)
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You cleaned off a "..j.name.."!")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
if j.destroyobj then
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, j.destroyobj)
doSendMagicEffect(getThingPos(cid), j.destroyobj and CONST_ME_BLOCKHIT)
end
if j.destroyvase then
doRemoveItem(item2.uid, 1)
doRemoveItem(uncommonitem.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, j.destroyvase)
doSendMagicEffect(getThingPos(cid), j.destroyvase and CONST_ME_WATERSPLASH)
doPlayerAddItem(cid, 2010, 1)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, config.cancel)
doSendMagicEffect(getThingPos(cid), CONST_ME_BLOCKHIT)
doRemoveItem(item2.uid, 1)
end
end
end
else
if item2.itemid == 10557 then
local r = math.random(2612), 1, nil
local skill = getPlayerSkill(cid, config.skill)
for l, m in pairs(w) do
if r >= l[1] and r <= l[2] then
if skill >= m.skill then
if m.commonitem then
doPlayerAddItem(cid, m.commonitem, 1)
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You cleaned off a "..m.name.."!")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
end
if m.destroyobj then
doRemoveItem(item2.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, m.destroyobj)
doSendMagicEffect(getThingPos(cid), m.destroyobj and CONST_ME_BLOCKHIT)
end
if m.destroyvase then
doRemoveItem(item2.uid, 1)
doRemoveItem(commonitem.uid, 1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, m.destroyvase)
doSendMagicEffect(getThingPos(cid), m.destroyvase and CONST_ME_WATERSPLASH)
doPlayerAddItem(cid, 2010, 1)
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, config.cancel)
doSendMagicEffect(getThingPos(cid), CONST_ME_BLOCKHIT)
doRemoveItem(item2.uid, 1)
end
end
end
else
end
return 0
end
return 1
end
end
Last edited: