Page 2 of 3
Re: Using/Consuming a potion?
Posted: Wed Sep 19, 2012 6:20 pm
by SpacialKatana
Cheers Emciel got it working a treat now. If anyone else wants to modify their own custom potions here are my working custom scripts:-
For the recipe:-
Code: Select all
defineRecipe{
item = "potion_healing_greater",
ingredients = {1,"flask",1,"milkreed",2,"blooddrop_blossom"}
}
And then for the potion itself:-
Code: Select all
cloneObject{
name = "potion_healing_greater",
baseObject = "potion_healing",
uiName = "Greater Healing Potion",
description = "A Bernard strength healing potion",
consumable = true,
potion = true,
onUseItem = function(self,champion)
champion:modifyStat("health", 100)
playSound("consume_potion")
return true
end
}
The consumable and potion defs may not be needed for a cloned potion, but would be needed if you had 'defined' a new item.
Re: Using/Consuming a potion?
Posted: Fri Oct 05, 2012 3:11 am
by akroma222
Thank you for posting up a greater heal potion. That one was definitely on the list
Further, I am keen to make an Elixir of Life potion - which heals the whole party regardless of who drinks it and restores everyone's food counter a fair bit (or a lot). I tried to adapt it from the greater heal potion but to no avail - it wont heal the party, just the one who drinks it..... Help me maybe??
Recipe- elixir of life
defineRecipe{
item = "elixir_of_life",
ingredients = {1,"flask",1,"milkreed",1,"blooddrop_blossom",2,"tar_bead"}
}
Script- elixir of life
cloneObject{
name = "elixir_of_life",
baseObject = "water_flask",
uiName = "Elixir of Life",
description = "A healing potion with properties that extend out from the user",
consumable = true,
potion = true,
onUseItem = function(self,party)
party:modifyStat("health", 100)
playSound("heal_party")
return true
end
}
Cloned from a water flask gives it the white potion look, and I would love for it to not only make the crystal heal party sound (that bit works) but also the fancy sparkly effect you get when you use a heal crystal.
Can someone please point out what I am doing wrong. I am not a modders bootlace and this dungeon editor is certainly popping that cherry lol any help much appreciated!!!!
Also on the agenda is a Resist magic potion. No work on that as of yet.....
Re: Using/Consuming a potion?
Posted: Fri Oct 05, 2012 3:13 am
by akroma222
Oh! and Elixir of Life should probably cure status effects too (poison, death etc).... hmmm much more complicated than I had originally thought
Re: Using/Consuming a potion?
Posted: Fri Oct 05, 2012 2:26 pm
by SpacialKatana
In the onUse hook, use a loop to heal each champion for that effect. The editing Superthread will help you there, just cut and paste what you need from a 'Party' script.
C+ is my thing, nudge Komag or another kind soul for help with lua if you get stuck, I'd probably get it wrong first attempt here!
Re: Using/Consuming a potion?
Posted: Tue Oct 23, 2012 7:13 pm
by akroma222
Ok, so I thought I would have another crack at mixing up this potion (Elixir of Life)...
Thanks for your reply specialKatana, I found what I believe is a party loop and have taken the coding from the other potions listed in the asset pack...
I have tried the following script, but it crashes the editor....
Code: Select all
cloneObject{
name = "elixir_of_life",
baseObject = "water_flask",
uiName = "Elixir of Life",
description = "A healing potion with properties that extend out from the user",
consumable = true,
potion = true,
onUseItem = function(self,party)
for i = 1,4 do
party:getChampion(i):modifyStat("health", 200),
party:getChampion(i):modifyStat("energy", 200),
party:getChampion(i):setCondition("diseased", 0),
party:getChampion(i):setCondition("paralyzed", 0),
party:getChampion(i):setCondition("poison", 0),
end
playSound("heal_party")
return true
end
}
Does anyone know why this code may not work??
Re: Using/Consuming a potion?
Posted: Wed Oct 24, 2012 8:57 pm
by Decayer
You need to remove the commas after the modifyStat / setCondition lines.
Re: Using/Consuming a potion?
Posted: Thu Oct 25, 2012 10:24 am
by akroma222
Thanks Decayer, I did try that before but consuming the potion crashes the editor still...
I received this error message...
Code: Select all
mod_assets/scripts/items.lua:84: attempt to call method 'getChampion' (a nil value)
stack traceback:
mod_assets/scripts/items.lua:84: in function 'onUseItem'
[string "Item.lua"]: in function 'useItem'
[string "CharSheet.lua"]: in function 'slotClicked'
[string "CharSheet.lua"]: in function 'draw'
[string "Gui.lua"]: in function 'draw'
[string "GameMode.lua"]: in function 'update'
[string "DungeonEditor.lua"]: in main chunk
[C]: in function 'xpcall'
[string "DungeonEditor.lua"]: in function 'preview'
[string "DungeonEditor.lua"]: in function 'update'
[string "Grimrock.lua"]: in main chunk
Re: Using/Consuming a potion?
Posted: Thu Oct 25, 2012 11:48 am
by Decayer
Oh, right, it's crashing because you're supplying your own 'party' variable to the function; try replacing
with
Code: Select all
onUseItem = function(item,champion)
Re: Using/Consuming a potion?
Posted: Thu Oct 25, 2012 5:31 pm
by akroma222
Yes indeed I was! Haha... I have enlisted some extra help and well, here it is, compliments of Crisman (thank you as well Decayer!)
Code: Select all
cloneObject{
name = "elixir_of_life",
baseObject = "water_flask",
uiName = "Elixir of Life",
description = "A healing potion with properties that extend out from the user",
consumable = true,
potion = true,
onUseItem = function(self, champion)
party:heal()
for i = 1,4 do
party:getChampion(i):modifyFood(1000)
end
playSound("heal_party")
return true
end
}
This white looking potion will heal the whole party as a crystal does (health, energy, status effects) as well as restore everyone's food counter...
It does indeed seem powerful, but in-game the recipe is hard to find and is taxing on the ingredients (2 tar bead, 1 blooddrop, 1 slime bell and 1 milkreed). Plus it will be needed for the later boss fights.
Re: Using/Consuming a potion?
Posted: Fri Sep 11, 2015 11:37 am
by Modraneth
hi. it is possible to clone a potion to create a water breathing potion ?
i think i will need it to my mod and i cant make the definition to work
Code: Select all
cloneObject{
name = "potion_waterbreathing",
baseObject = "potion_poison",
uiName = "Water Breathing Potion",
description = "A potion created to breath under water.",
consumable = true,
potion = true,
onUseItem = function(self,champion)
champion:modifyStat(what do i place here??)
playSound("consume_potion")
return true
end
}