Solarus-Games English Forum

Solarus => Development => Topic started by: zutokaza on March 24, 2017, 11:54:20 PM

Title: (Solved)Sword variants?
Post by: zutokaza on March 24, 2017, 11:54:20 PM
Can a sword have different variants? For example, variant 2 for a red sword graphic?

Code ( lua) Select
game:set_ability("sword", 2)
Title: Re: Sword variants?
Post by: Zefk on March 25, 2017, 12:29:53 AM
Yes, you can do that. Make another sword and call it "sword2" and change the graphics to red swords.  The sword will be at level 2. That means it will inflict more damage.

sword2 counts as the second variant in
Code ( lua) Select
game:set_ability("sword", 2)

You will need to create other names with a "2" after it. Follow the error messages. It will mentions names like "sword_stars2."

(http://forum.solarus-games.org/index.php?action=dlattach;topic=929.0;attach=496)

Your second option would be to just change the sprite. Make a new animation called, "red_sword."
http://www.solarus-games.org/doc/latest/lua_api_hero.html#lua_api_hero_set_sword_sprite_id

Code ( lua) Select
hero:set_sword_sprite_id("red_sword")
Title: (Solved)Sword variants?
Post by: zutokaza on March 25, 2017, 01:03:42 AM
Thanks again Zefk! The sword variant change is working.