Using/Consuming a potion?
-
- Posts: 163
- Joined: Fri Sep 14, 2012 6:20 pm
Using/Consuming a potion?
I need a helpful nudge. I've defined a recipe and item for a greater heal potion but I'm a bit stuck being able to make the champion use it. I know I have to use the onUseItem hook in the item's def, but I'm not sure of the syntax and command to heal...
onUseItem = function...
heal =100
end
???Help
onUseItem = function...
heal =100
end
???Help
Re: Using/Consuming a potion?
I'm fairly confident you can use cloneObject and just set the healing value, ID and item name different to produce a simpler potion.
-
- Posts: 163
- Joined: Fri Sep 14, 2012 6:20 pm
Re: Using/Consuming a potion?
Been trying to...the item is cloned from the "potion_healing" item, but when right clicking nothing happens. it even says right click to use in the tool tip that comes up ingame.
I'm also not 100% sure what the healing command is either>.<
I'm prolly just being dumb...it's 5am here
I'm also not 100% sure what the healing command is either>.<
I'm prolly just being dumb...it's 5am here
-
- Posts: 163
- Joined: Fri Sep 14, 2012 6:20 pm
Re: Using/Consuming a potion?
Friendly bump..it's holding back custom crafting for my mod. Thanks
Re: Using/Consuming a potion?
Can you show your cloned object? Have you added a onUseItem hook?SpacialKatana wrote:Friendly bump..it's holding back custom crafting for my mod. Thanks
From http://www.grimrock.net/modding/asset-d ... reference/
onUseItem: a hook which is called when the item is used (e.g. by right-clicking on it). The function gets two parameters: the item used and the champion who used the item. If the function returns true, the item is consumed when it is used.
-
- Posts: 163
- Joined: Fri Sep 14, 2012 6:20 pm
Re: Using/Consuming a potion?
Here you go Shroom...it doesn't break the game, but it don't work either
Code: Select all
cloneObject{
name = "potion_healing_greater",
baseObject = "potion_healing",
uiName = "Greater Healing Potion",
description = "A Bernard strength healing potion",
consumable = true,
onUseItem = function(self,champion)
heal = 100
end
Re: Using/Consuming a potion?
I dont know about heal = 100
I havent played with items much, but could you use champion:modifyStat("health", 100)?
Edit: - changed self to champion
I havent played with items much, but could you use champion:modifyStat("health", 100)?
Edit: - changed self to champion
-
- Posts: 163
- Joined: Fri Sep 14, 2012 6:20 pm
Re: Using/Consuming a potion?
The hook says it needs 2 parameters, the item and the user so maybe I'll try :-
onUseItem = function(self,champion:modifyStat("health", 100))
end
Edit Hmm still no dice..editor didn't like that line lol
onUseItem = function(self,champion:modifyStat("health", 100))
end
Edit Hmm still no dice..editor didn't like that line lol
Re: Using/Consuming a potion?
it says it gets 2 parameters - trySpacialKatana wrote:The hook says it needs 2 parameters, the item and the user so maybe I'll try :-
onUseItem = function(self,champion:modifyStat("health", 100))
end
Edit Hmm still no dice..editor didn't like that line lol
Code: Select all
onUseItem = function(self,champion)
champion:modifyStat("health", 100)
end
Re: Using/Consuming a potion?
also you need to add
return true
to the onUseItem or else it won't actually be consumed =)
so shroom's code modified:
(also added the playSound ^_^)
return true
to the onUseItem or else it won't actually be consumed =)
so shroom's code modified:
Code: Select all
onUseItem = function(self,champion)
champion:modifyStat("health", 100)
playSound("consume_potion")
return true
end