Code: Select all
cloneObject{
name = "red_eye_right",
baseObject = "eye_socket_right",
onInsertItem = function(red_gem)
return true
end,
}
Code: Select all
cloneObject{
name = "red_eye_right",
baseObject = "eye_socket_right",
onInsertItem = function(red_gem)
return true
end,
}
Ok, so how do we adjust the arguments so that it will accept a specific gem (return true) and reject the others (return false) with the onInsertItem function?petri wrote:The function should return false when the socket wants to reject an item. Now it returns true for any item.
Code: Select all
cloneObject{
name = "multi_eye_right",
baseObject = "eye_socket_right",
onInsertItem = function()
print("Gem inserted right.")
return true
end,
}
cloneObject{
name = "multi_eye_left",
baseObject = "eye_socket_left",
onInsertItem = function()
print("Gem inserted left.")
return true
end,
}
Code: Select all
function checkEyes()
for i in multi_eye_left_1:containedItems() do
if i.name == "green_gem" then
print("L Green Gem")
leftGreenGem = "true"
leftRedGem = "false"
leftBlueGem = "false"
greenGems()
end
end
for i in multi_eye_right_1:containedItems() do
if i.name == "green_gem" then
print("R Green Gem")
rightGreenGem = "true"
rightRedGem = "false"
rightBlueGem = "false"
greenGems()
end
end
for i in multi_eye_left_1:containedItems() do
if i.name == "red_gem" then
print("L Red Gem")
leftGreenGem = "false"
leftRedGem = "true"
leftBlueGem = "false"
redGems()
end
end
for i in multi_eye_right_1:containedItems() do
if i.name == "red_gem" then
print("R Red Gem")
rightGreenGem = "false"
rightRedGem = "true"
rightBlueGem = "false"
redGems()
end
end
for i in multi_eye_left_1:containedItems() do
if i.name == "blue_gem" then
print("L Blue Gem")
leftGreenGem = "false"
leftRedGem = "false"
leftBlueGem = "true"
blueGems()
end
end
for i in multi_eye_right_1:containedItems() do
if i.name == "blue_gem" then
print("R Blue Gem")
rightGreenGem = "false"
rightRedGem = "false"
rightBlueGem = "true"
blueGems()
end
end
end
function greenGems()
if rightGreenGem == "true" and leftGreenGem == "true" then
playSound("level_up")
myDoor:open()
else
myDoor:close()
end
end
function redGems()
if rightRedGem == "true" or leftRedGem == "true" then
spawn("fireburst", party.level, party.x, party.y, 0)
end
end
function blueGems()
if rightBlueGem == "true" or leftBlueGem == "true" then
spawn("frostburst", party.level, party.x, party.y, 0)
end
end
how then to program the objects file????petri wrote:The function should return false when the socket wants to reject an item. Now it returns true for any item.
Code: Select all
onInsertItem = function(self, item)
return item.name == "blue_gem" and self:getItemCount() == 0
end