can i use a modable tile with a sustain?
Moderator: Moderator
can i use a modable tile with a sustain?
Hi, I'm trying to make a sustain that changes the player tile when it's active, like Lichform or Deeprock Form. I'd also like to use a modable tile with it's own folder for armors, called mutant. When the sustain is deactivated, the player tile is switched back to default.
How would i go about doing this?
How would i go about doing this?
Re: can i use a modable tile with a sustain?
Does Psiblades do similar to what you are after?
My feedback meter decays into coding. Give me feedback and I make mods.
Re: can i use a modable tile with a sustain?
Edit: Nevermind. It wasn't what you're looking for.
Re: can i use a modable tile with a sustain?
The psiblades code helped alot actually! Thanks 
The only thing that doesn't work is switching back to the default player sprite when deactivating the sustain. I probably shouldn't be trying to nil the value for self.moddable_tile, and should figure out how to write an if/then statement to call the default birth descriptor and base tile. But this is way over my head!
I wish I could add a mutant_female also, but lack the intelligence to even write "if female then self.moddable_tile = mutant female" in Lua or anything else for that matter and this is very frustrating. I should have learned how to write basic code a very, very long time ago. If someone could take a look at what I have so far and point me in the right direction I'd really appreciate it!

The only thing that doesn't work is switching back to the default player sprite when deactivating the sustain. I probably shouldn't be trying to nil the value for self.moddable_tile, and should figure out how to write an if/then statement to call the default birth descriptor and base tile. But this is way over my head!
I wish I could add a mutant_female also, but lack the intelligence to even write "if female then self.moddable_tile = mutant female" in Lua or anything else for that matter and this is very frustrating. I should have learned how to write basic code a very, very long time ago. If someone could take a look at what I have so far and point me in the right direction I'd really appreciate it!
Code: Select all
newTalent{
name = "Mutant",
type = {"wild-gift/mutations", 1},
mode = "sustained",
points = 5,
require = barbgift_req1,
cooldown = 20,
sustain_stamina = 80,
tactical = { BUFF = 2 },
activate = function(self, t)
self.moddable_tile = "mutant"
self.moddable_tile_nude = true
self.moddable_tile_base = "base_mutant_01.png"
self.moddable_tile_ornament = nil
self.blood_color = colors.GREEN
self:updateModdableTile()
local t = self:getTalentFromId(self.T_MUTANT)
return {
size = self:addTemporaryValue("size_category", 0.5 * self:getTalentLevel(t)),
dam = self:addTemporaryValue("combat_dam", 20 * self:getTalentLevel(t)),
atk = self:addTemporaryValue("combat_atk", 0.04 * self:getTalentLevel(t)),
movespeed = self:addTemporaryValue("movement_speed", - 0.04 * self:getTalentLevel(t)),
liferegen = self:addTemporaryValue("life_regen", 1.5 * self:getTalentLevel(t)),
stamregen = self:addTemporaryValue("stamina_regen", - 1 * self:getTalentLevel(t)),
}
end,
deactivate = function(self, t, p)
self.moddable_tile = nil
self.moddable_tile_nude = true
self.moddable_tile_base = nil
self.moddable_tile_ornament = nil
self.blood_color = colors.RED
self:updateModdableTile()
self:removeTemporaryValue("size_category", p.size)
self:removeTemporaryValue("combat_dam", p.dam)
self:removeTemporaryValue("combat_atk", p.atk)
self:removeTemporaryValue("movement_speed", p.movespeed)
self:removeTemporaryValue("life_regen", p.liferegen)
self:removeTemporaryValue("stamina_regen", p.stamregen)
return true
end,
info = function(self, t)
return ([[You better say your prayers and take you vitamins brotha, cause Hulkamania is gonna run wild on you! Greatly increase your size, strength, and health regen. But, due to your massive increases in bulk and power, you rapidly lose your stamina, accuracy, and movement speed.
*Gain 1 size category for every two points in the skill. (First huge, then gargntuan)
+%d Physical Power
+%0.2f Health per turn
-%0.2f Stamina per turn
-%d%% Accuracy
-%d%% Movement Speed]]):format(20 * self:getTalentLevel(t), 1.5 * self:getTalentLevel(t), 0.75 * self:getTalentLevel(t), 4 * self:getTalentLevel(t), 4 * self:getTalentLevel(t))
end,
}
Re: can i use a modable tile with a sustain?
Here's a few changes:
I changed the addTemporaryValue() calls to talentTemporaryValue() calls and stored the old moddable tile settings. talentTemporaryValue() causes the engine to automatically remove the temps so you don't have to do it manually in deactivate(). Saving the moddable tile settings in activate() and restoring them in deactivate() should solve the switching back problem. If you want to change the tile by sex you could do something like:
Hopefully, that's the sort of thing you wanted.
Code: Select all
activate = function(self, t)
local ret = {}
ret.moddable_tile = self.moddable_tile
ret.moddable_tile_nude = self.moddable_tile_nude
ret.moddable_tile_base = self.moddable_tile_base
ret.moddable_tile_ornament = self.moddable_tile_ornament
ret.blood_color = self.blood_color
self.moddable_tile = "mutant"
self.moddable_tile_nude = true
self.moddable_tile_base = "base_mutant_01.png"
self.moddable_tile_ornament = nil
self.blood_color = colors.GREEN
self:updateModdableTile()
local t = self:getTalentFromId(self.T_MUTANT)
self:talentTemporaryValue(ret, "size_category", 0.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_dam", 20 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_atk", 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "movement_speed", - 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "life_regen", 1.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "stamina_regen", - 1 * self:getTalentLevel(t)),
return ret
end,
deactivate = function(self, t, p)
self.moddable_tile = p.moddable_tile
self.moddable_tile_nude = p.moddable_tile_nude
self.moddable_tile_base = p.moddable_tile_base
self.moddable_tile_ornament = p.moddable_tile_ornament
self.blood_color = p.blood_color
self:updateModdableTile()
return true
end,
Code: Select all
self.moddable_tile = self.male and "mutant_male" or "mutant_female"
self.moddable_tile_nude = true
self.moddable_tile_base = self.male and "base_mutant_male01.png" or "base_mutant_female01.png"
self.moddable_tile_ornament = nil
self.blood_color = colors.GREEN
self:updateModdableTile()
Re: can i use a modable tile with a sustain?
Yeahh aardvark! Thanks!!
Your code works, with a couple of very minor fixes. On deactivate, p.modable.tile (etc) should be ret.modable.tile (etc) as defined in your new ret code. And you need to call ret in the deactivate = function(self, t, p, ret) part. With those two small changes, it worked flawlessly! Thank you so much for taking your time with this!
New barbarian addon coming soon!
Your code works, with a couple of very minor fixes. On deactivate, p.modable.tile (etc) should be ret.modable.tile (etc) as defined in your new ret code. And you need to call ret in the deactivate = function(self, t, p, ret) part. With those two small changes, it worked flawlessly! Thank you so much for taking your time with this!
New barbarian addon coming soon!
Re: can i use a modable tile with a sustain?
You shouldn't need any changes. Unless I'm not looking in the right place (engine.interface.ActorTalents:useTalent()), then p and ret are one and the same. ret is a table that activate() populates and returns. That same table is passed to deactivate() as p. Adding a ret parameter to deactivate() should just result in a nil value.
Put another way, ret and p are just two different names for the same table. Unless I'm very wrong, it should work as posted without any extra effort to overload or superload other files or functions.
Put another way, ret and p are just two different names for the same table. Unless I'm very wrong, it should work as posted without any extra effort to overload or superload other files or functions.
Re: can i use a modable tile with a sustain?
Yeah, ret becomes p.
My feedback meter decays into coding. Give me feedback and I make mods.
Re: can i use a modable tile with a sustain?
I honestly don't know about any of that stuff man, all I did was paste your code over mine! ToME hangs at 100% after clicking on new player from the main menu, with your code added. So I tried to troubleshoot your code by removing things to see if I could get it working. I know very little about the basic engine stuff, and zero about tables. I just derp my way through things and get lucky sometimes.
So... the first thing I tried was removing the temporary value stuff to see if I could just get the tile switching to load. At this point, I tried to load a previous barbarian character with the mutant talent enabled. And ToME hung again. What I should have done at this point instead is tried to create a new character, because without the temporary values, your code does indeed work flawlessly!
When I made my last post, I had gone to the edit hammer again and mistankenly thought I should make more changes. My apologies for the confusion!! My last post is in error.
But, the game does hang because of something in here, and I'm not comprehending computer code fast enough to find it:
Again, sorry about the miscommunication. Thanks for the help, and I hope my previous post didn't offend because I didn't mean to come at you with a correction like that!
So... the first thing I tried was removing the temporary value stuff to see if I could just get the tile switching to load. At this point, I tried to load a previous barbarian character with the mutant talent enabled. And ToME hung again. What I should have done at this point instead is tried to create a new character, because without the temporary values, your code does indeed work flawlessly!
When I made my last post, I had gone to the edit hammer again and mistankenly thought I should make more changes. My apologies for the confusion!! My last post is in error.

But, the game does hang because of something in here, and I'm not comprehending computer code fast enough to find it:
Code: Select all
local t = self:getTalentFromId(self.T_MUTANT)
self:talentTemporaryValue(ret, "size_category", 0.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_dam", 20 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "combat_atk", 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "movement_speed", - 0.04 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "life_regen", 1.5 * self:getTalentLevel(t)),
self:talentTemporaryValue(ret, "stamina_regen", - 1 * self:getTalentLevel(t)),
Re: can i use a modable tile with a sustain?
Oops. Of course it would crash since I forgot to remove the commas at the ends of the talentTemporaryValue() calls. I just modified your addTemporaryValue() calls, which were inside a table declaration, and missed that part.Sorry about that.
And I'm not offended. I do make mistakes. Obviously.
P.S. This line could probably be deleted:t is already passed as an argument to activate() and doesn't need be gotten again.
Code: Select all
self:talentTemporaryValue(ret, "size_category", 0.5 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "combat_dam", 20 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "combat_atk", 0.04 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "movement_speed", - 0.04 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "life_regen", 1.5 * self:getTalentLevel(t))
self:talentTemporaryValue(ret, "stamina_regen", - 1 * self:getTalentLevel(t))
And I'm not offended. I do make mistakes. Obviously.
P.S. This line could probably be deleted:
Code: Select all
local t = self:getTalentFromId(self.T_MUTANT)
Re: can i use a modable tile with a sustain?
Working 100%
Thanks dude
Thanks dude

Re: can i use a modable tile with a sustain?
This class better have grappling.
And a cooking talent. Any enemies who smell what you're cooking are dazed.
And a cooking talent. Any enemies who smell what you're cooking are dazed.