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

Item storage

Tormented

Member
Joined
Jan 13, 2024
Messages
14
Reaction score
6
Is it possible to create an item that would have a storage and the value of that storage of the item would increment? so for example the item would increment storage by 1 every 60 seconds and would have some limit of value or do I have to make it via ActionID ? so say the value of storage would be 10 max so in 10 minutes u could claim 10 fruits off a tree and then it would reset. is it possible to do it via storagevalue of some storage not related to player? or should I juts increment the items ActionID ?
 
Is it possible to create an item that would have a storage and the value of that storage of the item would increment? so for example the item would increment storage by 1 every 60 seconds and would have some limit of value or do I have to make it via ActionID ? so say the value of storage would be 10 max so in 10 minutes u could claim 10 fruits off a tree and then it would reset. is it possible to do it via storagevalue of some storage not related to player? or should I juts increment the items ActionID ?

Lua:
item:setCustomAttribute(key, value)
item:getCustomAttribute(key)
 
Lua:
item:setCustomAttribute(key, value)
item:getCustomAttribute(key)
interesting I guess I could use this as follows
player waters his plant
it has addevent that will add storage to the plant every X seconds for 5-10 repetitions. player is free to pick fruits off the tree whenever he wants.
for strawberries i think im just gonna dd them onto the item for example not sure yet I was thinking I could use the method of Quantity display for sprites but wondering if it will work if item is unmoveable e.g pear tree that i will put pears on top of sprite :p
 
interesting I guess I could use this as follows
player waters his plant
it has addevent that will add storage to the plant every X seconds for 5-10 repetitions. player is free to pick fruits off the tree whenever he wants.
for strawberries i think im just gonna dd them onto the item for example not sure yet I was thinking I could use the method of Quantity display for sprites but wondering if it will work if item is unmoveable e.g pear tree that i will put pears on top of sprite :p

Can add these to data/lib/core/filename.lua as some custom functions.
Should do the trick.

Lua:
local itemValue = item:getIncrementValue()
print(itemValue) -- default of 0

item:changeIncrementValue() -- defaults to adding +1
item:changeIncrementValue(5) -- addition
item:changeIncrementValue(-10) -- subtract

item:setIncrementValue(4) -- sets it to a direct value

item::removeIncrementValue() -- removes / resets to 0

Lua:
function Item:getIncrementValue()
    if not self:isItem() then
        print("Error: Item:getValue -> Item is not an item.")
        return 0
    end
    local currentValue = self:getCustomAttribute("ITEM_INCREMENT_VALUE")
    return ccurrentValue or 0
end

function Item:changeIncrementValue(amount)
    if not self:isItem() then
        print("Error: Item:changeValue -> Item is not an item.")
        return false
    end
    local currentValue = self:getValue()
    self:setCustomAttribute("ITEM_INCREMENT_VALUE", currentValue + (amount or 1))
    return true 
end

function Item:setIncrementValue(value)
    if not self:isItem() then
        print("Error: Item:setValue -> Item is not an item.")
        return false
    end
    self:setCustomAttribute("ITEM_INCREMENT_VALUE", value)
    return true
end

function Item:removeIncrementValue()
    if not self:isItem() then
        print("Error: Item:setValue -> Item is not an item.")
        return false
    end
    self:removeCustomAttribute("ITEM_INCREMENT_VALUE")
    return true
end
 
Can add these to data/lib/core/filename.lua as some custom functions.
Should do the trick.

Lua:
local itemValue = item:getIncrementValue()
print(itemValue) -- default of 0

item:changeIncrementValue() -- defaults to adding +1
item:changeIncrementValue(5) -- addition
item:changeIncrementValue(-10) -- subtract

item:setIncrementValue(4) -- sets it to a direct value

item::removeIncrementValue() -- removes / resets to 0

Lua:
function Item:getIncrementValue()
    if not self:isItem() then
        print("Error: Item:getValue -> Item is not an item.")
        return 0
    end
    local currentValue = self:getCustomAttribute("ITEM_INCREMENT_VALUE")
    return ccurrentValue or 0
end

function Item:changeIncrementValue(amount)
    if not self:isItem() then
        print("Error: Item:changeValue -> Item is not an item.")
        return false
    end
    local currentValue = self:getValue()
    self:setCustomAttribute("ITEM_INCREMENT_VALUE", currentValue + (amount or 1))
    return true
end

function Item:setIncrementValue(value)
    if not self:isItem() then
        print("Error: Item:setValue -> Item is not an item.")
        return false
    end
    self:setCustomAttribute("ITEM_INCREMENT_VALUE", value)
    return true
end

function Item:removeIncrementValue()
    if not self:isItem() then
        print("Error: Item:setValue -> Item is not an item.")
        return false
    end
    self:removeCustomAttribute("ITEM_INCREMENT_VALUE")
    return true
end
I like that a lot I am thinking about adding some small format of farming and making food a bit more expensive on server in general because it would ideally be used for crafting more delicious snacks.
I wanna do something that like once you have fully grown plant you just gotta water it and it will spruce fruits every X seconds so im thinking of triggering it with watercan player using on the tree and then there is an AddEvent that would loop for 5 - 10 times eventually needing another water treatment along with the idea of limiting it so the plant doesnt just keep growing infinitely.
 
Back
Top