Re: I only have Daemon Eyes for you!
Posted: Mon Oct 22, 2012 11:56 am
In my theory this could be something like: onPickuUp destroy picked item and place new (same as before) item into slot.
Official Legend of Grimrock Forums
http://grimrock.net/forum/
If you use the OnPickupItem hook, you can use "return false" to actually prevent the item being picked up.Huder wrote:In my theory this could be something like: onPickuUp destroy picked item and place new (same as before) item into slot.
Code: Select all
if item.id == "blue_gem_fake" then
return false
else
return true
end
Code: Select all
function switchGems()
blue_gem_original:destroy()
daemon_eye_socket_left:addItem(spawn("blue_gem",nil,nil,nil,nil,"blue_gem_fake"))
end
Code: Select all
defineObject{
name = "daemon_eye_left_hold",
class = "Alcove",
anchorPos = vec(0.21, 1.58, -0.45),
targetPos = vec(0.2, 1.65, -0.45),
targetSize = vec(0.1, 0.1, 0.1),
placement = "wall",
onInsertItem = function(self, item)
return item.name == "blue_gem" and self:getItemCount() == 0
end,
onPickUpItem = function(self, item)
if item.name == "blue_gem_fake" then
return false
else
return true
end
end,
editorIcon = 92,
Code: Select all
function gemCheckBlue()
local itemFound = nil
for i in daemon_eye_left_hold_1:containedItems() do
if i .name == "blue_gem" then
itemFound = i.id
end
end
if itemFound ~= nil then
gem = findEntity(itemFound)
gem:destroy()
daemon_eye_left_hold_1:addItem(spawn("blue_gem_fake", nil, nil, nil, nil))
end
end
Code: Select all
function fakeBlueGem()
onPickUpItem = function(self, item)
if item.name == "blue_gem_fake" then
return false
else
return true
end
end,
Code: Select all
defineObject{
name = "eye_socket_left",
class = "Alcove",
anchorPos = vec(0.21, 1.58, -0.45),
targetPos = vec(0.2, 1.65, -0.45),
targetSize = vec(0.1, 0.1, 0.1),
placement = "wall",
onInsertItem = function(self, item)
return item.name == "blue_gem" and self:getItemCount() == 0
end,
editorIcon = 92,
}
defineObject{
name = "eye_socket_right",
class = "Alcove",
anchorPos = vec(-0.21, 1.58, -0.45),
targetPos = vec(-0.2, 1.65, -0.45),
targetSize = vec(0.1, 0.1, 0.1),
placement = "wall",
onInsertItem = function(self, item)
return item.name == "blue_gem" and self:getItemCount() == 0
end,
editorIcon = 92,
}
defineObject{
name = "mouth_socket",
class = "Alcove",
anchorPos = vec(0, 1.1, -0.38),
targetPos = vec(0, 1.1, -0.38),
targetSize = vec(0.3, 0.3, 0.3),
placement = "wall",
onInsertItem = function(self, item)
return item.name == "green_gem" and self:getItemCount() == 0
end,
editorIcon = 92,
}
Code: Select all
defineObject{
name = "mouth_socket",
class = "Alcove",
anchorPos = vec(0, 1.1, -0.38),
targetPos = vec(0, 1.1, -0.38),
targetSize = vec(0.3, 0.3, 0.3),
placement = "wall",
onInsertItem = function(self, item)
return item.name == "red_gem" and self:getItemCount() == 0
end,
editorIcon = 92,
Alcoves (including eyes) don't have a onPickUpItem hook; you'd have to put that check in Party:onPickUpItem instead.akroma222 wrote:Now, when blue gem is inserted, it is destroyed and replaced with blue gem fake (seamlessly). However, I can still pick up the blue gem fake from the eye socket.... Have I fumbled up the onPickUpItem hook??
Thank you all again for your help
I do apologise for not being very thorough in my explanation.akroma222 wrote: Now, when blue gem is inserted, it is destroyed and replaced with blue gem fake (seamlessly). However, I can still pick up the blue gem fake from the eye socket.... Have I fumbled up the onPickUpItem hook??
Thank you all again for your help
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party,item)
if item.id == "blue_gem_fake" then
return false
else
return true
end
end,
}