The onInsertItem hook is called when an item is inserted in the socket. It returns false if the item should be rejected (not placed in the socket), and something esle if it shouldn't be (generally true or nil). Circumstances under which it makes sense to manually call it yourself are extremely esoteric. Furthermore, "essence_balance_1" is a string, not an item.Davenfal wrote:That worked perfectly, thanks for the help! I do have another question:For some reason, the field onInsertItem is returning a nil value, am I calling it wrong or is my mistake elsewhere?Code: Select all
function openNorthGates() if NorthGate.onInsertItem(NorthGate, "essence_balance_1") then north_gate1.door:open(); north_gate2.door:open(); else north_gate1.door:close(); north_gate2.door:close(); end end
The beacons accept literally any item in the game. You need to check the item's name:Grimfan wrote:Sockets normally only take a single item like a torch (they are not like altars and alcoves). Each of the beacons only accepts a single essence as far as I know.
Code: Select all
function openNorthGate()
local item = NorthGate.socket:getItem()
if item and item.go.name == "essence_balance" then
northgate1.door:open()
northgate2.door:open()
end
end