Recent posts
#31
Development / Problem with trying to overrid...
Last post by lefthandedhero - November 03, 2023, 07:40:29 PMA while back, I created a custom entity called Follower, who exists to follow the hero. Recently, I created a function entity:swap_sprite() that replaces the Follower's current sprite with the hero's current tunic sprite. Here is that code:
I then created another function meant to override the game command "item_2"; this function will do multiple things, but right now, it just calls the entity:swap_sprite() function. I intend to store this function in a separate metatable, but right now, it is inside the Follower.lua file. Here's the code:
However, when I try to run the quest, instead of the sprite changing on command, it occurs at the very beginning of the quest, and the hero can no longer use the sword (movement still works). What could be causing this error?
EDIT: To try to figure out what went wrong, I added two lines of code to the swap_sprite() function that changes the hero's current tunic sprite to the follower's sprite (both are using hero tunic sprites of different colours; the hero's sprite is hero/tunic1 and the follower's is hero/tunic3). The modified function is as follows:
Now, the two characters swap sprites as intended, but instead of only doing so during the item_2 game command, they do so any time any game command is called: when the hero starts moving, they swap sprites (the hero still starts moving); when the hero changes direction, they swap sprites (the hero still changes direction); When I press "c" for the hero to use their sword, they swap sprites and the sword isn't used; etc.
EDIT: I looked at some default examples of the use of similar events, such as on_key_pressed() and I realized my error; I stated "game:on_command_pressed(item_2)" when I should have stated "game:on_command_pressed(command)" and then stated: if command = "item_2"...
Code Select
function entity:swap_sprite()
-- obtain the hero's current sprite:
repsprite = hero:get_tunic_sprite_id()
-- replace the current sprite with resprite:
entity:remove_sprite()
sprite = entity:create_sprite(repsprite)
end
I then created another function meant to override the game command "item_2"; this function will do multiple things, but right now, it just calls the entity:swap_sprite() function. I intend to store this function in a separate metatable, but right now, it is inside the Follower.lua file. Here's the code:
Code Select
function game:on_command_pressed(item_2)
entity:swap_sprite()
return true
end
However, when I try to run the quest, instead of the sprite changing on command, it occurs at the very beginning of the quest, and the hero can no longer use the sword (movement still works). What could be causing this error?
EDIT: To try to figure out what went wrong, I added two lines of code to the swap_sprite() function that changes the hero's current tunic sprite to the follower's sprite (both are using hero tunic sprites of different colours; the hero's sprite is hero/tunic1 and the follower's is hero/tunic3). The modified function is as follows:
Code Select
function entity:swap_sprite()
-- obtain the hero's current sprite:
repsprite = hero:get_tunic_sprite_id()
-- (For testing) replace hero's sprite with follower's
local sprite_id = sprite:get_animation_set()
hero:set_tunic_sprite_id(sprite_id)
-- replace the current sprite with resprite:
entity:remove_sprite()
sprite = entity:create_sprite(repsprite)
end
Now, the two characters swap sprites as intended, but instead of only doing so during the item_2 game command, they do so any time any game command is called: when the hero starts moving, they swap sprites (the hero still starts moving); when the hero changes direction, they swap sprites (the hero still changes direction); When I press "c" for the hero to use their sword, they swap sprites and the sword isn't used; etc.
EDIT: I looked at some default examples of the use of similar events, such as on_key_pressed() and I realized my error; I stated "game:on_command_pressed(item_2)" when I should have stated "game:on_command_pressed(command)" and then stated: if command = "item_2"...
#32
Game art & music / Re: [UPDATE] Absolute Hyrule M...
Last post by Christopho - October 31, 2023, 10:34:50 PMI eventually found them later, and they can now be found in the ALTTP Resource Pack.
#33
Development / Re: Hero Invisibilty
Last post by Stevespear46 - October 31, 2023, 08:34:14 PMI was able to get the effect I want with the script below. I created a new tunic dat with sprits that are semi transparent. also had to add a check to my tunic item so if you changed variants while invisible the spirits would update to the new transparent color. I though about going with a new sprite set altogether like a blacked out ninja set or something... maybe in the future.
local game = item:get_game()
local map = item:get_map()
local hero = map:get_hero()
local tunic_level = game:get_ability("tunic")
local isInvisible = game:get_value("hero_invisible")
if isInvisible == true then
game:set_value("hero_invisible", false)
hero:set_tunic_sprite_id("hero/tunic" .. tunic_level)
else
game:set_value("hero_invisible", true)
hero:set_tunic_sprite_id("hero/item/invisibility/tunic" .. tunic_level)
end
local game = item:get_game()
local map = item:get_map()
local hero = map:get_hero()
local tunic_level = game:get_ability("tunic")
local isInvisible = game:get_value("hero_invisible")
if isInvisible == true then
game:set_value("hero_invisible", false)
hero:set_tunic_sprite_id("hero/tunic" .. tunic_level)
else
game:set_value("hero_invisible", true)
hero:set_tunic_sprite_id("hero/item/invisibility/tunic" .. tunic_level)
end
#34
Development / Hero Invisibilty
Last post by Stevespear46 - October 31, 2023, 05:59:20 PMHey everyone,
I've looked through the forums and also though the APIs and I'm having trouble with completing a mechanic. I would like to complete the cane of byrna and magic cape. So I've implemented the the items and have been setting the Here entity visibility to false. Unfortunately this also removes the shadow and the player has no idea where the here is. Has anyone implemented this mechanic yet? I thought maybe I could set the sprites alpha to something low and have a mostly transparent Hero. I don't see APIs for that either. Anyone have some ideas?
I've looked through the forums and also though the APIs and I'm having trouble with completing a mechanic. I would like to complete the cane of byrna and magic cape. So I've implemented the the items and have been setting the Here entity visibility to false. Unfortunately this also removes the shadow and the player has no idea where the here is. Has anyone implemented this mechanic yet? I thought maybe I could set the sprites alpha to something low and have a mostly transparent Hero. I don't see APIs for that either. Anyone have some ideas?
#35
Game art & music / Re: [UPDATE] Absolute Hyrule M...
Last post by Stevespear46 - October 31, 2023, 05:55:00 PMQuote from: Christopho on July 31, 2017, 10:46:55 AM
Did anyone download the ALTTP outside sample maps that ffomega made?
Because they were lost and it was a lot of work. I only have two of them (Kakariko Village and Hyrule Castle).
Thanks for you help.
Hey I'm new here. Hoping that someone still has these maps that ffomega made. Would love to to get my hands on them.
#36
Development / Re: How to Change the Hero's S...
Last post by lefthandedhero - October 29, 2023, 02:01:23 AMQuote from: PeterB on October 28, 2023, 10:00:46 PM
Hi,
Tunic level relates to the Hero's defense level.
For example in Zelda Tunic level 1 is green, level 2 is blue and level 3 is red.
You therefore need to have a different colour sprite for each tunic level for every hero sprite.
That way when you upgrade your tunic in your game you can automatically change all your hero sprites to the next colour.
If you have a look in the sample quest that comes with the Quest Editor, in the sprites/hero folder you can see the three tunic sprite sets. It is the items/tunic script then then calls the relevant variant and updates the hero's sprite colour.
Thank you; that makes a lot of sense. There probably will not be tunic upgrades in the game I am making, so I guess I can ignore the stuff about tunic level.
Quote from: PeterB on October 28, 2023, 10:00:46 PM
If you want to set up a different sprite then you just need to add a new animation to tunic1, tunic2 and tunic3 and call that animation from a script, at least i think that is the easiest way to do it.
I see. I should point out that I'm very new to Solarus and I'm still learning how sprites and animations work.
Would adding an animation be sufficient? I want to essentially create another appearance that the hero uses when in a custom state.
#37
Development / Re: How to Change the Hero's S...
Last post by PeterB - October 28, 2023, 10:00:46 PMHi,
Tunic level relates to the Hero's defense level.
For example in Zelda Tunic level 1 is green, level 2 is blue and level 3 is red.
You therefore need to have a different colour sprite for each tunic level for every hero sprite.
That way when you upgrade your tunic in your game you can automatically change all your hero sprites to the next colour.
If you have a look in the sample quest that comes with the Quest Editor, in the sprites/hero folder you can see the three tunic sprite sets. It is the items/tunic script then then calls the relevant variant and updates the hero's sprite colour.
If you want to set up a different sprite then you just need to add a new animation to tunic1, tunic2 and tunic3 and call that animation from a script, at least i think that is the easiest way to do it.
Tunic level relates to the Hero's defense level.
For example in Zelda Tunic level 1 is green, level 2 is blue and level 3 is red.
You therefore need to have a different colour sprite for each tunic level for every hero sprite.
That way when you upgrade your tunic in your game you can automatically change all your hero sprites to the next colour.
If you have a look in the sample quest that comes with the Quest Editor, in the sprites/hero folder you can see the three tunic sprite sets. It is the items/tunic script then then calls the relevant variant and updates the hero's sprite colour.
If you want to set up a different sprite then you just need to add a new animation to tunic1, tunic2 and tunic3 and call that animation from a script, at least i think that is the easiest way to do it.
#38
Development / How to Change an Entity's Spri...
Last post by lefthandedhero - October 28, 2023, 03:11:41 AMI am trying to create a custom state for the hero that represents the hero being in a different form (think something like Wolf Link from Twilight Princess): while the hero is in this custom state, the hero uses a different sprite and a different main attack. I was wondering how to change the hero's sprite.
EDIT: I now realize that I probably phrased this question poorly. I was wondering, for any entity, how to program it to use a specific sprite under certain conditions. I watched the video on sprite and animation files, so I know how to create a sprite. But, once I have created a sprite, how do I tell the engine, "under this specific condition, this entity's sprite is now (a specific sprite)"?
I want to know this so I can change the hero's appearance during the game, but I really want to know how to do this with any entity. For instance, I currently have a custom entity that currently only exists to always follow the hero, and I want their appearance to change whenever the hero's appearance changes.
EDIT2: I think I may have found a solution: using entity:remove_sprite() then entity:create_sprite(), I have tested it, and it seems to work.
EDIT: I now realize that I probably phrased this question poorly. I was wondering, for any entity, how to program it to use a specific sprite under certain conditions. I watched the video on sprite and animation files, so I know how to create a sprite. But, once I have created a sprite, how do I tell the engine, "under this specific condition, this entity's sprite is now (a specific sprite)"?
I want to know this so I can change the hero's appearance during the game, but I really want to know how to do this with any entity. For instance, I currently have a custom entity that currently only exists to always follow the hero, and I want their appearance to change whenever the hero's appearance changes.
EDIT2: I think I may have found a solution: using entity:remove_sprite() then entity:create_sprite(), I have tested it, and it seems to work.
#39
Development / Re: Make 2nd hero un-attackabl...
Last post by pitcherposse - October 10, 2023, 11:09:33 AMThanks, it works fine for me on_Attack_hero.
#40
Development / Sword delay and footstep sound
Last post by PrincessQuest4 - October 03, 2023, 06:52:37 PMIs there a way to add sound to the walking animation. Also is there a way to delay the sword attack so the attack is not rapid sword slashing.