• 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 that generate rune while have duration

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
Hello guys.
i trying to do something like that :


i can check the item inside the Box. but i cant do the item keep creating runes while have duration. someone have some ideia how i can do this ?


Lua:
function sdbox.onUse(player, item, fromPosition, target, toPosition, isHotkey)

     
if item:getItemCountById(2260) < 15 then --blank rune
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Insufficient materials.blank')
    fromPosition:sendMagicEffect(CONST_ME_POFF)
    return false
end

if item:getItemCountById(2152) < 20 then -- money/gold
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Insufficient materials.money')
    fromPosition:sendMagicEffect(CONST_ME_POFF)
    return false
end

if item:getItemCountById(2667) < 15 then --food/fish/ham/meat
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Insufficient materials.food')
    fromPosition:sendMagicEffect(CONST_ME_POFF)
    return false
end    

player:say('WORK WORK', TALKTYPE_MONSTER_SAY, false, player, fromPosition)
item:transform(41120)
return true

end

sdbox:id(41116)
sdbox:register()

at onThink dont find something to find all items with ID. and i dont want to use getSpectators at entire map.

Lua:
local sdbox = MoveEvent()


function runecreate()
tileitem:addItem(2268, 1)
addEvent(runecreate, 60 * 200)
end

function sdbox.onAddItem(moveitem, tileitem, position)

if moveitem.itemid ~= 2268 then
        return true
    end

-- tileitem:say('WORK WORK', TALKTYPE_MONSTER_SAY, false, player, fromPosition)
addEvent(runecreate, 60 * 200)
end
sdbox:type("additem")
sdbox:id(41120)
sdbox:register()
the code above was just a test.

At "onAddItem" dont work too and after sever save will stop to work =/

Thanks.

FLP
 
Last edited:
Solution
In my example above, there is only a single time-stamp.

It's the same idea as a chest that can only be used once per day.
You have a static number, and when the player looks at the item, the number never changes, only the current time changes.

Instead of giving the number to the player, in the form of a storage value, you give that number to the item.

so this would be the onUse function
Lua:
if theItemHasaTimeStamp then
    if currentTime < itemsTimeStamp then
        -- tell player the timer has not yet expired
        return true
    end
    -- give items.
    -- remove timeStamp
    return true
end
-- check for required items inside the box
-- remove items
-- set timeStamp on the item
and this would be the onLook function
Lua:
if...

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,729
It'd be too resource intensive to remember all of the locations and timers / decays of all of these boxes, so you'd have to use a trigger event of some kind to give the items to the player / into the container.

What I'd do for this kind of thing is tag the item with a time stamp using os.time(). (os.time() + timeToCreateRunes)

Then use that time stamp to show information to player when looking at it.
"Approx finish time: " .. (convertSecondsToReadableTime(itemsTimeStamp))

It doesn't show how the runes are given to the player, but same idea applies, only when the 'timer' elapses would the items be placed into the container / given to the player.

The trigger for that would be when a player 'uses' the item to check inside.
At that point, you erase the time stamp on the item, and put the items into the container / give directly to the player.

If multiple different types of runes can be made with the same container.. like food + runes + skulls = sudden death runes or something
Just make another custom attribute to store that information as well.
 
OP
OP
FeLiPe-Eduardo

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
38
Solutions
1
Reaction score
3
It doesn't show how the runes are given to the player, but same idea applies, only when the 'timer' elapses would the items be placed into the container / given to the player.
Your idea is good. I changed everything thinking about it.

When you click on the item this window opens. The player chooses the duration and amount of runes to be generated.

iBFidp7.png

If the player has the items the item will be transformed. however now i have 2 problems. The first is that when the item is transformed it doesn't have its duration reduced normally. If I spawn the item with god /i 1234 the duration is reduced.

The second problem is that on server save or if I close the server the item in its durability status just disappears.

FLP
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,612
Solutions
395
Reaction score
3,729
In my example above, there is only a single time-stamp.

It's the same idea as a chest that can only be used once per day.
You have a static number, and when the player looks at the item, the number never changes, only the current time changes.

Instead of giving the number to the player, in the form of a storage value, you give that number to the item.

so this would be the onUse function
Lua:
if theItemHasaTimeStamp then
    if currentTime < itemsTimeStamp then
        -- tell player the timer has not yet expired
        return true
    end
    -- give items.
    -- remove timeStamp
    return true
end
-- check for required items inside the box
-- remove items
-- set timeStamp on the item
and this would be the onLook function
Lua:
if currentTime < itemsTimeStamp then
    -- tell player the time left
    return true
end
-- tell player that the thing is finished
 
Solution
Top