• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Table being in conflict with the script.

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
595
Solutions
2
Reaction score
66
Location
México
Hey bois, good morning. Im experiencing a weird issue on this script.
Its a farming script, if you place a strawberry and use a rake on it, you will plant a strawberry bush (in theory). But sometimes it grows another plant of the table. I dont know whats happening here and why that occurs. I get several messages in the game:
09:52 Your strawberry bush has fully grown! Harvest it before it withers!
09:52 Your grapes vine has fully grown! Harvest it before it withers!
LUA:
----------------Script Structure By Nirer/Kakashi~Sensei-----------------
-------------Enhancements and configurablility by 375311-------------
-----------Ask before you re-distribute to other sites-----------
local config = {
grounds = {804},
sMin = 1
}
--[{XXXX}] = {NFTree = XXXX, bloomInSec = XX, t_DthInSec = XX, FTree = XXXX, tname = ""},--
--Ref: NFTree = Non Fruit Tree, FTree = Fruit Tree, bloomInSec = time that it takes to bloom, t_DthInSec = time that it takes for plant to die,
--tname = tree name and [{XXXX}] = Seed(fruit) itemid, all XXXX are itemids--
--and paste it under:
local t = { --HERE--
[2675] = {level = 30, NFTree = 4008, bloomInSec = 60, t_DthInSec = 30, FTree = 4006, tname = "orange tree"},
[2676] = {level = 50, NFTree = 5093, bloomInSec = 45, t_DthInSec = 30, FTree = 5094, tname = "banana tree"},
[2678] = {level = 100, NFTree = 2726, bloomInSec = 70, t_DthInSec = 50, FTree = 5096, tname = "coconut tree"},
[2677] = {level = 10, NFTree = 2786, bloomInSec = 20, t_DthInSec = 45, FTree = 2785, tname = "blueberry bush"},
[2680] = {level = 1, NFTree = 2770, bloomInSec = 20, t_DthInSec = 50, FTree = 4011, tname = "strawberry bush"},
[2685] = {level = 20, NFTree = 6216, bloomInSec = 20, t_DthInSec = 45, FTree = 4018, tname = "tomatoe bush"},
[2681] = {level = 80, NFTree = 2770, bloomInSec = 40, t_DthInSec = 45, FTree = 5393, tname = "grapes vine"},
[5097] = {level = 80, NFTree = 5156, bloomInSec = 40, t_DthInSec = 20, FTree = 5157, tname = "mango tree"},
[2684] = {level = 1,NFTree = 4013, bloomInSec = 40, t_DthInSec = 20, FTree = 4012, tname = "carrot crop"}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(itemEx.type ~= 1) then
doPlayerSendCancel(cid, "Use a hoe, place one fruit on it and use rake.")
elseif(getPlayerSoul(cid) < config.sMin) then
doPlayerSendCancel(cid, "You do not have enough soul to farm.")
elseif(getPlayerStorageValue(cid, 1037) < t[itemEx.itemid].level) then
doPlayerSendCancel(cid, "You do not have enough skill to farm this [".. t[itemEx.itemid].level .."].")
end
local professionSkill = getPlayerStorageValue(cid, 1037)
local chance = math.ceil(professionSkill/20)
if professionSkill < 1 then
professionSkill = 1
end
if getPlayerStorageValue(cid, 30173) < 1 then
    setPlayerStorageValue(cid, 30173, 2)
end
if getPlayerStorageValue(cid, 9885) < 1 then
doPlayerPopupFYI(cid, "[Tutorial]: Growing plants!\
\
1-.Cultivate a plant on a fertile ground with hoe and rake.\
2-.Wait few seconds to plant grow.\
3-.Wait a little more until plant get mature.\
\
You can buy hoe and rake at equipment stores.\
")
setPlayerStorageValue(cid, 9885, 1)
end
local soul = getPlayerSoul(cid)
local lvl = getPlayerStorageValue(cid, 1037)

    -- if math.random(1, professionSkill*1.15) >= professionSkill then
    -- if professionSkill < 500 then
    -- setPlayerStorageValue(cid, 1037, professionSkill + 1)
    -- doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You advanced in farming ["..professionSkill.."].")
    -- end
    -- end


for i, k in pairs(t) do
if (isInArray(i, itemEx.itemid) == true) and itemEx.type == 1 and (soul >= config.sMin) and (lvl >= k.level) then
local ground_position = {x = toPosition.x, y = toPosition.y, z = toPosition.z, stackpos = 0}
local ground_information = getThingfromPos(ground_position)
if(isInArray(config.grounds, ground_information.itemid) == TRUE) then
doPlayerAddSoul(cid, -config.sMin)
doTransformItem(itemEx.uid, k.NFTree)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your "..k.tname.." has been cultivated!")
addEvent(Bloom, k.bloomInSec*1000, {position = toPosition, cid = cid, t_Dth = k.t_DthInSec})
local exp = 30173
local professionSkill = getPlayerStorageValue(cid, 1037)
local R = math.random(professionSkill,500)
local experience_formula = math.ceil(25 + ((((professionSkill - 1)/100) * 10) * 25))
if professionSkill < 500 then
    setPlayerStorageValue(cid, exp, math.ceil(getPlayerStorageValue(cid, exp) + k.bloomInSec))
    doPlayerSendTextMessage(cid, 19,"[Gameplay]: "..getPlayerStorageValue(cid, exp).."/"..experience_formula.." experience to reach farming level ".. professionSkill ..". (".. math.ceil((getPlayerStorageValue(cid, exp)/math.ceil(experience_formula))*100) .."%)")
    if getPlayerStorageValue(cid, exp) >= experience_formula then
        setPlayerStorageValue(cid, exp, getPlayerStorageValue(cid, exp) - experience_formula)
        setPlayerStorageValue(cid, 1037, professionSkill + 1)
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You advanced in farming ["..professionSkill.."].")
    end
end

else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "This is not the proper ground for farming.")
end
end
end
return TRUE
end

function Bloom(parameter)
    local proskill = (getPlayerStorageValue(parameter.cid, 1037))/10
    local rand = math.random(proskill, 100)
    if rand < 50 then    
        addEvent(t_Die, parameter.t_Dth*1000, {position = {x = parameter.position.x, y = parameter.position.y, z = parameter.position.z }, cid = parameter.cid})
    end
if rand >= 50 then
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
for i, k in pairs(t) do
if (tree.itemid == k.NFTree) then
doTransformItem(tree.uid, k.FTree)
doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your "..k.tname.." has fully grown! Harvest it before it withers!")
--addEvent(t_Die, parameter.t_Dth*1000, {position = {x = parameter.position.x, y = parameter.position.y, z = parameter.position.z }, cid = parameter.cid})
end
end
addEvent(t_Die, parameter.t_Dth*1000, {position = {x = parameter.position.x, y = parameter.position.y, z = parameter.position.z }, cid = parameter.cid})
end
end
function t_Die(parameter)
local tree = getThingfromPos{x = parameter.position.x, y = parameter.position.y, z = parameter.position.z, stackpos = 1}
doRemoveItem(tree.uid)
doPlayerSendTextMessage(parameter.cid, MESSAGE_INFO_DESCR, "Your crop has withered.")
end
 
Back
Top