William Sezo
Rookie but passionate
Hi, i want to copy a part of this script so that the mined stones also "grow back" like the trees do in this other script.
here's the working woodcutting script i'm using:
and this is my mining.lua script
I'm currently getting this error and can't figure it out...
Thanks.
here's the working woodcutting script i'm using:
Code:
local config = {
trees = {2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2712,2717,2718,2720,2722},
t = {
[{1, 100}] = {tree = 2701},
[{101, 200}] = {tree = 2702},
[{201, 300}] = {tree = 2703},
[{301, 400}] = {tree = 2704},
[{401, 500}] = {tree = 2705},
[{501, 600}] = {tree = 2706},
[{601, 700}] = {tree = 2707},
[{701, 800}] = {tree = 2708},
[{801, 900}] = {tree = 2709},
[{901, 1000}] = {tree = 2710},
[{1001, 1100}] = {tree = 2712},
[{1101, 1200}] = {tree = 2717},
[{1201, 1300}] = {tree = 2718},
[{1301, 1400}] = {tree = 2720},
[{1401, 1500}] = {tree = 2722}
},
level = 15,
skill = SKILL_AXE,
skillReq = 10,
effect = CONST_ME_BLOCKHIT,
addTries = 100,
branches = 6432,
msgType = MESSAGE_EVENT_ADVANCE,
soul = 3,
minutes = 5
}
local t = {
[{1, 500}] = {msg = "You chopped the tree and got some wood.", item = 5901, amountmax = 2},
[{501, 750}] = {msg = "You have damaged your axe and it broke!", destroy = true},
[{751, 1550}] = {msg = "You chopped the tree down, but the the wood was not good."},
[{1551, 1650}] = {msg = "oh no the tree had a Wasps nest in it!", summon = "Wasp"},
[{1651, 1750}] = {msg = "You hurt yourself while choping the tree down.", damage = {1, 100}},
[{1751, 2000}] = {msg = "You choped the tree and got some wood", item = 5901, amountmax = 5},
[{2001, 2250}] = {msg = "A cat that was stuck jumped from the choped tree", summon = "Cat"},
[{2251, 2500}] = {msg = "There was a bird's nest in the tree and you took some eggs from the nest.", item = 2695, amountmax = 5},
[{2501, 2750}] = {msg = "You got some wood for building!!!", item = 12969, amountmax = 5},
[{2751, 3000}] = {msg = "A rat jumped at you!", summon = "Rat"}
}
-- config.soul <= getPlayerSoul(cid)--
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(config.trees, itemEx.itemid) and config.level <= getPlayerLevel(cid) and config.skillReq <= getPlayerSkill(cid, config.skill) then
local v, amount, damage = math.random(3000), 1, nil
for i, k in pairs(t) do
if v >= i[1] and v <= i[2] then
if k.destroy then
doRemoveItem(item.uid)
end
if k.summon then
doSummonCreature(k.summon, toPosition)
end
if k.damage then
damage = math.random(k.damage[1], k.damage[2])
doCreatureAddHealth(cid, - damage)
doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD)
-- doSendAnimatedText(getThingPos(cid), damage, TEXTCOLOR_RED) not working on 1.2 --
doPlayerSendTextMessage(cid, config.msgType, msg)
end
if k.item then
if k.amountmax then
amount = math.random(k.amountmax)
end
doPlayerAddItem(cid, k.item, amount)
end
if k.msg then
local msg = k.msg
doPlayerSendTextMessage(cid, config.msgType, msg)
end
local function newTrees(parameter)
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
for i2, k2 in pairs(config.t) do
local v2 = math.random(1500), 1, nil
if v2 >= i2[1] and v2 <= i2[2] then
if k2.tree then
if (tree.itemid == config.branches) then
doTransformItem(tree.uid, k2.tree)
end
end
end
end
end
addEvent(newTrees, config.minutes*60*1000, {position = toPosition, cid = cid})
doTransformItem(itemEx.uid, config.branches)
-- doPlayerAddSoul(cid, -config.soul) --
doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect)
return doPlayerAddSkillTry(cid, config.skill, config.addTries)
end
end
end
return doPlayerSendCancel(cid, "Either this tree can't be choped or you don't have enough experience or skill to chop this tree.")
end
and this is my mining.lua script
Code:local config = { stones = {1285, 1356, 1357, 1358, 1359, 3608, 3615, 3607, 3609, 3616, 3666, 3667, 3668, 3670, 1295, 1290}, t = { [{1, 100}] = {stone = 1285}, [{101, 200}] = {stone = 1356}, [{201, 300}] = {stone = 1357}, [{301, 400}] = {stone = 1358}, [{401, 500}] = {stone = 1359}, [{501, 600}] = {stone = 3608}, [{601, 700}] = {stone = 3615}, [{701, 800}] = {stone = 3607}, [{801, 900}] = {stone = 3609}, [{901, 1000}] = {stone = 3616}, [{1001, 1100}] = {stone = 3666}, [{1101, 1200}] = {stone = 3667}, [{1201, 1300}] = {stone = 3668}, [{1301, 1400}] = {stone = 3670}, [{1401, 1500}] = {stone = 1295} }, level = 15, skill = SKILL_CLUB, skillReq = 10, effect = CONST_ME_BLOCKHIT, addTries = 100, debris = 1336, msgType = MESSAGE_EVENT_ADVANCE, soul = 5 } local groundIds = {354, 355} local t = { [{1, 100}] = {msg = "Oh no, you missed and picked a hole in the ground and a rat came out of it!", summon = "Rat"}, [{101, 200}] = {msg = "You found %A %N.", item = 18427, amountmax = 3}, -- pulverized ores -- [{201, 300}] = {msg = "You found %A %N.", item = 2145, amountmax = 1}, -- diamonds [{301, 400}] = {msg = "You found %A %N.", item = 2225}, --piece of iron [{401, 500}] = {msg = "You found %A %N.", item = 18429, amountmax = 5}, --iron ore vein-- [{501, 600}] = {msg = "You found %A %N.", item = 2146, amountmax = 1}, --saphires [{601, 700}] = {msg = "You found %A %N.", item = 2149, amountmax = 1}, --emeralds [{701, 800}] = {msg = "You found %A %N.", item = 2150, amountmax = 1}, --amethist [{801, 900}] = {msg = "You found %A %N.", item = 5880, amountmax = 3}, --iron ore [{901, 1000}] = {msg = "You lost %D hitpoints due to exhaustion of mining.", damage = {1, 150}}, [{1001, 1100}] = {msg = "You found %A %N.", item = 2147, amountmax = 1}, --ruby [{1101, 1200}] = {msg = "You found %A %N.", item = 2143, amountmax = 1}, --white pearl [{1201, 1300}] = {msg = "You found %A %N.", item = 2144, amountmax = 1}, --black pearl [{1301, 1400}] = {msg = "WTH? An angry dwarf came out of the rock piles!", summon = "Dwarf Guard"}, [{1401, 1500}] = {msg = "A badger got unstuck and it looks angry!", summon = "Badger"}, [{1501, 1600}] = {msg = "A rotworm came from a hole you made on the ground!", summon = "Rotworm"}, [{1601, 1700}] = {msg = "You suffered %D hitpoints due to an earthquake!", damage = {1, 250}}, [{1701, 1800}] = {msg = "A furious troll has appeared from the pile of rocks!", summon = "Furious Troll"}, [{1801, 1900}] = {msg = "Woah! A skeleton just appeared from the pile of rocks!", summon = "Skeleton"}, [{1901, 2000}] = {msg = "Your pick has been heavily damaged and it broke...", destroy = true}, [{2001, 2400}] = {msg = "You found %A %N.", item = 18429, amountmax = 3}, -- iron ore vein [{2401, 2600}] = {msg = "You found %A %N.", item = 6547, amountmax = 1}, -- gold ore [{2601, 2900}] = {msg = "You found %A %N.", item = 18427, amountmax = 1}, -- pulverized ores } function onUse(cid, item, fromPosition, itemEx, toPosition) if isInArray(config.stones, itemEx.itemid) and config.level <= getPlayerLevel(cid) and config.skillReq <= getPlayerSkill(cid, config.skill) then local v, amount, damage = math.random(3000), 1, nil for i, k in pairs(t) do if v >= i[1] and v <= i[2] then if k.destroy then doRemoveItem(item.uid) end if k.summon then doSummonCreature(k.summon, toPosition) end if k.damage then damage = math.random(k.damage[1], k.damage[2]) doCreatureAddHealth(cid, - damage) doSendMagicEffect(getThingPos(cid), CONST_ME_DRAWBLOOD) doCreatureSay(getThingPos(cid), damage, TEXTCOLOR_RED) end if k.item then if k.amountmax then amount = math.random(k.amountmax) end doPlayerAddItem(cid, k.item, amount) end if k.msg then local msg = k.msg if msg:find("%%") then if msg:find("%%A") and k.item then msg = msg:gsub("%%A", amount > 1 and amount or getItemDescriptions(k.item).article) end if msg:find("%%N") and k.item then msg = msg:gsub("%%N", amount > 1 and getItemDescriptions(k.item).plural or getItemName(k.item)) end if msg:find("%%D") and damage then msg = msg:gsub("%%D", damage) end end doPlayerSendTextMessage(cid, config.msgType, msg) end local function newStones(parameter) local stone = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1} for i2, k2 in pairs(config.t) do local v2 = math.random(1500), 1, nil if v2 >= i2[1] and v2 <= i2[2] then if k2.stone then if (stone.itemid == config.debris) then doTransformItem(stone.uid, k2.stone) end end end end end addEvent(newStones, config.minutes*60*1000, {position = toPosition, cid = cid}) doTransformItem(itemEx.uid, config.debris) -- doPlayerAddSoul(cid, -config.soul) -- doSendMagicEffect(toPosition, k.destroy and CONST_ME_HITAREA or config.effect) return doPlayerAddSkillTry(cid, config.skill, config.addTries) end end end return doPlayerSendCancel(cid, "You either aren't experienced, skilled or don't have enough soul, or this isn't a breakable rock.") end
I'm currently getting this error and can't figure it out...
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/farming/mining.lua:onUse
data/actions/scripts/farming/mining.lua:113: attempt to perform arithmetic on fi
eld 'minutes' (a nil value)
stack traceback:
[C]: in function '__mul'
data/actions/scripts/farming/mining.lua:113: in function <data/actions/s
cripts/farming/mining.lua:58>
Thanks.