Code: Select all
altar_1.surface:addConnector('onInsertItem', self.go.id, "itemSwap") --< change altar_1 to the ID of your altar >
function itemSwap(surface, item)
local checkItem = "rock" -------------------------------< Name of the user placed item >
local itemReplacement = "figure_skeleton" ----< Name of the replacement item >
if item.go.item:getStackSize() < 2 and
item.go.name == checkItem then
item.go:destroy()
surface:addItem(spawn(itemReplacement).item)
end
end
Code: Select all
altar_1.surface:addConnector('onInsertItem', self.go.id, "itemSwap")
function itemSwap(surface, item)
local checkItem = "rock"
local itemReplacement = "figure_skeleton"
if item.go.item:getStackSize() == 1 and
item.go.name == checkItem then
item.go:destroy()
surface:addItem(spawn(itemReplacement).item)
--optional effect
surface.go:createComponent('Particle'):setParticleSystem('beacon_crystal')
surface.go.particle:setDestroySelf(true)
surface.go.particle:fadeOut(1)
surface.go:playSound('teleport')
end
end