local config = {
itemIds = {2445, 2550, 2436, 6101, 2408, 7435, 7429},
position = {x = 151, y = 55, z = 7}
}
local currentIndex = 1
function onThink(interval)
local tile = getThingfromPos(config.position)
local item = nil
for _, id in ipairs(config.itemIds) do
item = getTileItemById(config.position, id)
if item.uid ~= 0 then
doTransformItem(item.uid, config.itemIds[currentIndex])
doSendMagicEffect(config.position...
local config = {
itemid = {2445, 2550, 2436, 6101, 2408, 7435, 7429}, -- IDs of the items to be transformed
position = {x = 151, y = 55, z = 7} -- Coordinates of the items to be transformed
}
function changeItemsToMagicGreenEffect()
for _, itemId in ipairs(config.itemid) do
local item = getTileItemById(config.position, itemId)
if item then
doSendMagicEffect(config.position, CONST_ME_MAGIC_GREEN)
end
end
end
function onStartup()
changeItemsToMagicGreenEffect()
addEvent(changeItemsToMagicGreenEffect, 5000) -- 5000 milliseconds = 5 seconds
return true
end
local config = {
itemid = {2445, 2550, 2436, 6101, 2408, 7435, 7429},
position = {x = 156, y = 58, z = 7},
tempo_criacao = 3
}
function changeItemToMagicGreenEffect()
local posX, posY, posZ = config.position.x, config.position.y, config.position.z
local itemId = config.itemid[math.random(1, #config.itemid)]
-- Criar novo item com o efeito CONST_ME_MAGIC_GREEN
local newItem = doCreateItem(itemId, 1, {x = posX, y = posY, z = posZ})
if newItem then
doSendMagicEffect({x = posX, y = posY, z = posZ}, CONST_ME_MAGIC_GREEN)
-- Agendar remoção do novo item após 3 segundos
addEvent(function()
doRemoveItem(newItem)
changeItemToMagicGreenEffect() -- Criar outro item após remoção
end, config.tempo_criacao * 1000) -- Tempo em milissegundos para remoção do item
end
end
function onThink(interval)
addEvent(changeItemToMagicGreenEffect, config.tempo_criacao * 1000)
return true
end
When you start your server, the script change the item then stop?create script for me item id only 2445-2550-2436-6101-2408-7435-7429
no function @highsanta
Lua:local config = { itemid = {2445, 2550, 2436, 6101, 2408, 7435, 7429}, -- IDs of the items to be transformed position = {x = 151, y = 55, z = 7} -- Coordinates of the items to be transformed } function changeItemsToMagicGreenEffect() for _, itemId in ipairs(config.itemid) do local item = getTileItemById(config.position, itemId) if item then doSendMagicEffect(config.position, CONST_ME_MAGIC_GREEN) end end end function onStartup() changeItemsToMagicGreenEffect() addEvent(changeItemsToMagicGreenEffect, 5000) -- 5000 milliseconds = 5 seconds return true end
local config = {
itemIds = {2445, 2550, 2436, 6101, 2408, 7435, 7429},
position = {x = 151, y = 55, z = 7},
changeInterval = 3000 -- Interval in milliseconds
}
local currentIndex = 1
local function changeItem()
local tile = getThingfromPos(config.position)
local item = nil
for _, id in ipairs(config.itemIds) do
item = getTileItemById(config.position, id)
if item.uid ~= 0 then
break
end
end
if item and item.uid ~= 0 then
doRemoveItem(item.uid)
currentIndex = currentIndex % #config.itemIds + 1
local nextItemId = config.itemIds[currentIndex]
doCreateItem(nextItemId, 1, config.position)
doSendMagicEffect(config.position, CONST_ME_MAGIC_GREEN)
end
addEvent(changeItem, config.changeInterval) -- restart the change
end
function onStartup()
changeItem()
addEvent(changeItem, config.changeInterval) -- start the change
return true
end
[29/03/2024 08:04:52] [Error - GlobalEvent Interface]
[29/03/2024 08:04:52] data/globalevents/scripts/item.lua:onStartup
[29/03/2024 08:04:53] Description:
[29/03/2024 08:04:53] data/globalevents/scripts/item.lua:30: attempt to call global 'changeItemsToMagicGreenEffect' (a nil value)
[29/03/2024 08:04:53] stack traceback:
[29/03/2024 08:04:54] data/globalevents/scripts/item.lua:30: in function <data/globalevents/scripts/item.lua:29>
sorry, copy the script again, I made a mistake when inserting the function name@mano368 no function
XML:[29/03/2024 08:04:52] [Error - GlobalEvent Interface] [29/03/2024 08:04:52] data/globalevents/scripts/item.lua:onStartup [29/03/2024 08:04:53] Description: [29/03/2024 08:04:53] data/globalevents/scripts/item.lua:30: attempt to call global 'changeItemsToMagicGreenEffect' (a nil value) [29/03/2024 08:04:53] stack traceback: [29/03/2024 08:04:54] data/globalevents/scripts/item.lua:30: in function <data/globalevents/scripts/item.lua:29>
Doesn't work again?how to do it onThink
local config = {
itemIds = {2445, 2550, 2436, 6101, 2408, 7435, 7429},
position = {x = 151, y = 55, z = 7},
changeInterval = 3000 -- Interval in milliseconds
}
local currentIndex = 1
local function changeItem()
local tile = getThingfromPos(config.position)
local item = nil
for _, id in ipairs(config.itemIds) do
item = getTileItemById(config.position, id)
if item.uid ~= 0 then
break
end
end
if item and item.uid ~= 0 then
doRemoveItem(item.uid)
currentIndex = currentIndex % #config.itemIds + 1
local nextItemId = config.itemIds[currentIndex]
doCreateItem(nextItemId, 1, config.position)
doSendMagicEffect(config.position, CONST_ME_MAGIC_GREEN)
end
addEvent(changeItem, config.changeInterval) -- restart the change
end
function onStartup()
changeItem()
addEvent(changeItem, config.changeInterval) -- start the change
return true
end
[29/03/2024 09:09:06] [Error - GlobalEvent Interface]
[29/03/2024 09:09:06] data/globalevents/scripts/item.lua:onThink
[29/03/2024 09:09:06] Description:
[29/03/2024 09:09:07] (luaAddEvent) Callback parameter should be a function.
local config = {
itemIds = {2445, 2550, 2436, 6101, 2408, 7435, 7429},
position = {x = 151, y = 55, z = 7}
}
local currentIndex = 1
function onThink(interval)
local tile = getThingfromPos(config.position)
local item = nil
for _, id in ipairs(config.itemIds) do
item = getTileItemById(config.position, id)
if item.uid ~= 0 then
doTransformItem(item.uid, config.itemIds[currentIndex])
doSendMagicEffect(config.position, CONST_ME_MAGIC_GREEN)
currentIndex = (currentIndex % #config.itemIds) + 1
break
end
end
return true
end
[29/03/2024 09:11:02] [Error - GlobalEvent Interface]
[29/03/2024 09:11:02] data/globalevents/scripts/item.lua:onThink
[29/03/2024 09:11:02] Description:
[29/03/2024 09:11:02] (luaAddEvent) Callback parameter should be a function.
just clean your item.lua script and change for what I give to you, don't mix scriptsXML:[29/03/2024 09:11:02] [Error - GlobalEvent Interface] [29/03/2024 09:11:02] data/globalevents/scripts/item.lua:onThink [29/03/2024 09:11:02] Description: [29/03/2024 09:11:02] (luaAddEvent) Callback parameter should be a function.