• 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!

Solved Could use some help making a wateringcan.lua

Goo Goo

Member
Joined
Apr 20, 2010
Messages
42
Reaction score
10
Since I couldn't find a watering can that works like Tibia I thought I would try and make a script for it.But I've run into a problem. When it gets to my third dotransformitem line it just goes back to the second one so it ends up just making pot id 7670 and 7678 over and over again. There are no errors in console. I'm using mystic spirit v0.2.14.

This is hopefully how it's suppose to look.
Code:
local firstBloom = {
[1] = {7680},
[2] = {7682},
[3] = {7684},
[4] = {7686}
}

local dryadBloom = {
[1] = {7683},
[2] = {7690},
[3] = {7691},
[4] = {15446}
}

local lizardBloom = {
[1] = {7681},
[2] = {7688},
[3] = {7689},
[4] = {15445}
}

local midnightBloom = {
[1] = {7685},
[2] = {7692},
[3] = {7693},
[4] = {15448}
}

local emberBloom = {
[1] = {7687},
[2] = {7694},
[3] = {7695},
[4] = {15447}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if itemEx.itemid == 7655 or 7665 or 7673 then
    doTransformItem(getThingfromPos(toPosition).uid, 7670)
    end
    if itemEx.itemid == 7670 then
        doTransformItem(getThingfromPos(toPosition).uid, 7678)
    end
    if item.itemid == 7678 then
        doTransformItem(getThingfromPos(toPosition).uid, firstBloom[math.random(4)])
    end
    if isInArray(firstBloom, 1) then
        doTransformItem(uid, dryadBloom[1])
    end
    if isInArray(firstBloom, 2) then
        doTransformItem(uid, lizardBloom[1])
    end
    if isInArray(firstBloom, 3) then
        doTransformItem(uid, midnightBloom[1])
    end
    if isInArray(firstBloom, 4) then
        doTransformItem(uid, emberBloom[1])
    end
        return TRUE
end

Here's the spot where just repeats itself. Makes 7678 then instead of getting an ID from firstBloom it just makes 7670 again.
Code:
if itemEx.itemid == 7670 then
        doTransformItem(getThingfromPos(toPosition).uid, 7678)
    end
    if item.itemid == 7678 then
        doTransformItem(getThingfromPos(toPosition).uid, firstBloom[math.random(4)])

I'm pretty sure it's this line
Code:
doTransformItem(getThingfromPos(toPosition).uid, firstBloom[math.random(4)])

I'm not sure i have my brackets and things in the right spots. I can't script to save my life it seems.

And it needs to pick one of the id's from firstBloom randomly since those are the beginning bloom of a flower (i.e. Dryad's Heart, Ember Queen, etc.)

The rest I'm still working out. pretty sure the isinarray things aren't gonna work either. But I tested the script with those lines removed and all but the firstBloom and it was the same thing so they are not my problem right now.

Any tips or advice would be great thanks.
 
Last edited by a moderator:
What should it do exactly?

I want this
Code:
doTransformItem(getThingfromPos(toPosition).uid, firstBloom[math.random(4)])
to pick a random ID from here
Code:
local firstBloom = {
[1] = {7680},
[2] = {7682},
[3] = {7684},
[4] = {7686}
}
But instead of doing that it just changes from 7670 to 7678 to 7670 to 7678...... on every use.

Then the rest are the id's for the flower's after they have "bloomed". Really just there for the id's for now. you can ignore those. I just don't understand why it just changes from 7678 back to 7670. Seems like it would give an errror first.

umm, but it's an action for a watering can. just changes a pot to a pot with sprouts, then to a flower then full grown flower. It's not exactly tibia I don't think but I had to keep it simple for my feeble mind and I still failed.

So .. any idea why it keeps repeating? That's the part I'm needing help with as of now. :)
 
Code:
local transform = {
   [7655] = 7670,
   [7665] = 7670,
   [7673] = 7670,
   [7670] = 7678
}

local firstBloom = {7680, 7682, 7684, 7686}


if transform[itemEx.itemid] then
   doTransformItem(itemEx.uid, transform[itemEx.itemid])
elseif itemEx.itemid == 7678 then
   doTransformItem(itemEx.uid, firstBloom[math.random(4)])
end
 
Works. Thank you very much.
EDIT: Thanks for the help Limos, if you're wondering how it turned out here it is :) pretty massive but works great.
Code:
local transform = {
  [7655] = 7670,
  [7665] = 7670,
  [7673] = 7670,
  [7670] = 7678
}

local firstBloom = {7680, 7682, 7684, 7686, 9982, 9986}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if transform[itemEx.itemid] then
        doTransformItem(itemEx.uid, transform[itemEx.itemid])
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7678 then
        doTransformItem(itemEx.uid, firstBloom[math.random(6)])
        doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
----------------------start lizard bloom-----------------------------   
    elseif itemEx.itemid == 7680 then
        doTransformItem(itemEx.uid, 7681)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7681 then
      doTransformItem(itemEx.uid, 7688)
      doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7688 then
        doTransformItem(itemEx.uid, 7689)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7674 then
      doTransformItem(itemEx.uid, 7689)
      doCreatureSay(cid, "You finally remembered to water your plant and it recovered.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7689 then
        doCreatureSay(cid, "Your plant doesn't need water.", TALKTYPE_ORANGE_1)
----------------------start dryad bloom-------------------------------   
    elseif itemEx.itemid == 7682 then
        doTransformItem(itemEx.uid, 7683)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7683 then
        doTransformItem(itemEx.uid, 7690)
        doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7690 then
        doTransformItem(itemEx.uid, 7691)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7675 then
        doTransformItem(itemEx.uid, 7691)
        doCreatureSay(cid, "You finally remembered to water your plant and it recovered.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7691 then
        doCreatureSay(cid, "Your plant doesn't need water.", TALKTYPE_ORANGE_1)
----------------------start midnight bloom----------------------------
    elseif itemEx.itemid == 7684 then
        doTransformItem(itemEx.uid, 7685)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7685 then
        doTransformItem(itemEx.uid, 7692)
        doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7692 then
        doTransformItem(itemEx.uid, 7693)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7676 then
        doTransformItem(itemEx.uid, 7693)
        doCreatureSay(cid, "You finally remembered to water your plant and it recovered.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7693 then
        doCreatureSay(cid, "Your plant doesn't need water.", TALKTYPE_ORANGE_1)
----------------------start ember bloom------------------------------
    elseif itemEx.itemid == 7686 then
        doTransformItem(itemEx.uid, 7687)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7687 then
        doTransformItem(itemEx.uid, 7694)
        doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7694 then
        doTransformItem(itemEx.uid, 7695)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7677 then
        doTransformItem(itemEx.uid, 7695)
        doCreatureSay(cid, "You finally remembered to water your plant and it recovered.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 7695 then
        doCreatureSay(cid, "Your plant doesn't need water.", TALKTYPE_ORANGE_1)
----------------------start finger bloom----------------------------
    elseif itemEx.itemid == 9982 then
        doTransformItem(itemEx.uid, 9983)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9983 then
        doTransformItem(itemEx.uid, 9990)
        doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9990 then
        doTransformItem(itemEx.uid, 9991)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9984 then
        doTransformItem(itemEx.uid, 9991)
        doCreatureSay(cid, "You finally remembered to water your plant and it recovered.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9991 then
        doCreatureSay(cid, "Your plant doesn't need water.", TALKTYPE_ORANGE_1)
-----------------------start fairy bloom-----------------------------
    elseif itemEx.itemid == 9986 then
        doTransformItem(itemEx.uid, 9987)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9987 then
        doTransformItem(itemEx.uid, 9988)
        doCreatureSay(cid, "Your plant has grown to the next stage!", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9988 then
        doTransformItem(itemEx.uid, 9989)
        doCreatureSay(cid, "You watered your plant.", TALKTYPE_ORANGE_1)
    elseif itemEx.itemid == 9985 then
        doTransformItem(itemEx.uid, 9991)
        doCreatureSay(cid, "You finally remembered to water your plant and it recovered.", TALKTYPE_ORANGE_1)       
    elseif itemEx.itemid == 9989 then
        doCreatureSay(cid, "Your plant doesn't need water.", TALKTYPE_ORANGE_1)
-------------------------------------------------------------------------
    elseif itemEx.itemid == 7679 then
        doPlayerSendCancel(cid, "Sorry, but you have already let this plant die.")
    else doPlayerSendCancel(cid,"Why are you trying to water that?")
    end
        return TRUE
end
 
Last edited:
Back
Top