[Request] A new hook for alcove "onRemoveItem"
[Request] A new hook for alcove "onRemoveItem"
I'm doing a complex puzzle in my dungeon with custom alcoves, but i can't find a hook to launch a function when an item is removed from the alcove.
I need this because the player need to put a certain item in order in a series of alcoves, and this is doable with "onInsertItem", but i need the exactly opposite and i can't find the way
With a hook like "onRemoveItem" i could do it, but there is no "onRemoveItem"
I can launch a function when the alcove is deactivated, but it isn't what i need. I need to deny the remove of the item if certain conditions are not met.
I think a hook of this kind can be useful also for other uses.
TY
I need this because the player need to put a certain item in order in a series of alcoves, and this is doable with "onInsertItem", but i need the exactly opposite and i can't find the way
With a hook like "onRemoveItem" i could do it, but there is no "onRemoveItem"
I can launch a function when the alcove is deactivated, but it isn't what i need. I need to deny the remove of the item if certain conditions are not met.
I think a hook of this kind can be useful also for other uses.
TY
Re: [Request] A new hook for alcove "onRemoveItem"
Can't you just make a script that activates upon putting that specific item in that alcove, and then keeps checking to see if it's been removed?
Re: [Request] A new hook for alcove "onRemoveItem"
A complex answer would be to replace the alcove with another alcove that has no clickbox so they can't remove the item (knowing that they've put it in there). You should explain the details of the puzzle.
There's also the party onPickUpItem hook maybe that'd be useful.
There's also the party onPickUpItem hook maybe that'd be useful.
Re: [Request] A new hook for alcove "onRemoveItem"
This looks pretty difficult, if you explain the puzzle maybe we can come up with something!
Or an alternative
Or an alternative
Re: [Request] A new hook for alcove "onRemoveItem"
You can easily solve this with "onPickUpItem"
items.lua:
In the editor make a script, name it to:
puzzle_script
Cant give more help without know more about what you are trying to do.
items.lua:
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party, self)
-- Let the script decide if the item should be picked up or not.
return puzzle_script.checkConditions(party,self)
end
}
puzzle_script
Code: Select all
function checkConditions(party, item)
-- Check the conditions here, and then return true if you can pick up the item, else return false
-- In this case I prevent the player from picking up and blue_gem's at all
if( item.name == "blue_gem" ) then
return false
end
return true
end
Re: [Request] A new hook for alcove "onRemoveItem"
Never tried that hook, I should give it a look!
- Lupe Fenrir
- Posts: 25
- Joined: Sun Oct 07, 2012 7:42 am
- Location: Sweden
Re: [Request] A new hook for alcove "onRemoveItem"
you could solve the problem by having a timer constantly updating the alcove by adding another item and then instantly removing it. this has the problem that it removes any item of the same type as the "update item" that the player may put there though.
Edit: Actualy if you just break the loop after it have removed the item it added, you won't have this problem. I uppdated the script example accordingly.
Edit: Actualy if you just break the loop after it have removed the item it added, you won't have this problem. I uppdated the script example accordingly.
Code: Select all
function update()
dungeon_alcove_1:addItem(spawn("dagger"))
for i in dungeon_alcove_1:containedItems() do
if i.name == "dagger" then
i:destroy()
break
end
end
end
My name is Torsek in some places
- Lupe Fenrir
- Posts: 25
- Joined: Sun Oct 07, 2012 7:42 am
- Location: Sweden
Re: [Request] A new hook for alcove "onRemoveItem"
Or you could just have the timer update the script that checks if the item is there.Lupe Fenrir wrote:you could solve the problem by having a timer constantly updating the alcove by adding another item and then instantly removing it. this has the problem that it removes any item of the same type as the "update item" that the player may put there though.
Edit: Actualy if you just break the loop after it have removed the item it added, you won't have this problem. I uppdated the script example accordingly.
Code: Select all
function update() dungeon_alcove_1:addItem(spawn("dagger")) for i in dungeon_alcove_1:containedItems() do if i.name == "dagger" then i:destroy() break end end end
I'm over-thinking things again.
My name is Torsek in some places
Re: [Request] A new hook for alcove "onRemoveItem"
Thank you guys, it was really simple
I solved it with this function:
I can put the gem in the alcove, but i can't remove it
I solved it with this function:
Code: Select all
function alcove_onDeactivate()
setMouseItem()
-- Destroy the gem collected
alcove:addItem(spawn("green_gem"))
-- Respawn instantly the gem
end
Re: [Request] A new hook for alcove "onRemoveItem"
I have found a more clean (and silent) solution:
In this way you can move the Green Gem normally, but when you put it in the alcove is destroyed and replaced with a Green Gem not movable.
Thank you again guys for the help
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onPickUpItem = function(party, item)
if item.name == "green_gem_PH" then return false end
end,
}
cloneObject{
name = "green_gem_PH",
baseObject = "green_gem",
}
Code: Select all
function alcove_onActivate()
local alcove = findEntity("alcove_name")
for i in alcove:containedItems() do
if i.name == "green_gem" then
i:destroy()
alcove:addItem(spawn("green_gem_PH"))
end
end
end
Thank you again guys for the help