Page 1 of 3

Using/Consuming a potion?

Posted: Wed Sep 19, 2012 4:45 am
by SpacialKatana
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

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 5:39 am
by Xaxus
I'm fairly confident you can use cloneObject and just set the healing value, ID and item name different to produce a simpler potion.

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 5:50 am
by SpacialKatana
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 :o

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 3:28 pm
by SpacialKatana
Friendly bump..it's holding back custom crafting for my mod. Thanks

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 3:40 pm
by Shroom
SpacialKatana wrote:Friendly bump..it's holding back custom crafting for my mod. Thanks
Can you show your cloned object? Have you added a onUseItem hook?

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.

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 3:46 pm
by SpacialKatana
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?

Posted: Wed Sep 19, 2012 3:50 pm
by Shroom
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

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 4:02 pm
by SpacialKatana
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

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 4:11 pm
by Shroom
SpacialKatana 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
it says it gets 2 parameters - try

Code: Select all

onUseItem = function(self,champion)
  champion:modifyStat("health", 100)
end

Re: Using/Consuming a potion?

Posted: Wed Sep 19, 2012 5:00 pm
by Emciel
also you need to add
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
(also added the playSound ^_^)