At the very least, you can create a custom entity that calls map:create_custom_entity() and automatically creates the two sensors and the invisible tile wherever you place it.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#32
Development / Re: Weird Stairs Issue
December 30, 2018, 06:39:49 PM
I forgot to mention, in my example I also have an invisible platform on layer 1 so the hero doesn't fall through once the sensor lifts her up.
I need something like this again so I'm working on creating a script to make it happen automatically.
I need something like this again so I'm working on creating a script to make it happen automatically.
#33
Development / Re: What changed in 1.5.3?
December 29, 2018, 09:27:06 PM
just change "local timer = sol.timer.start(30, function()" --> "local timer = sol.timer.start(self, 30, function()"
Sorry, should've wrote that earlier instead of triple-posting
Sorry, should've wrote that earlier instead of triple-posting
#34
Development / Re: What changed in 1.5.3?
December 29, 2018, 09:22:06 PMQuote from: llamazing on December 29, 2018, 09:16:31 PM
so it seems to me that the problem is that the timers continue to run even after you've removed the entity.
ding ding ding! I bet this is the answer. Here:
Code ( lua) Select
-- Refresh every 30ms
local timer = sol.timer.start(30, function()
if self:is_on_platform(hero) then
handle_on_platform(hero)
else
handle_off_platform(hero)
end
return true -- loop forever
end)
every 30ms the timer would check "self:is_on_platform(hero)", which would be false, and it'd cause "handle_off_platform(hero)" to run.
#35
Development / Re: What changed in 1.5.3?
December 29, 2018, 09:20:23 PM
I refactored your code even more. Try starting with this:
At least this way we can probably pinpoint exactly which function is failing. You need to write print() statements inside of each of these and make sure they all work properly.
If it's flicking between on/off, I'd guess that maybe this script is setting things globally that should only apply to each individual object, or it's repeatedly creating and destroying the object for some reason. It's hard to help more without actually testing it in your game, but I hope this helps you down the right track.
Code ( lua) Select
local entity = ...
local game = entity:get_game()
local map = entity:get_map()
local hero = map:get_hero()
local grass = false
local timer = nil
function entity:on_created()
self:set_size(16, 16)
self:set_modified_ground("traversable")
self:set_traversable_by("hero", true)
self:add_collision_test("center", function(self, hero)
local x, y, layer = hero:get_position()
if not map:has_entity("grassprite") and self:is_on_platform(hero) then -- Create ground sprite if hero overlaps entity
local grassprite = map:create_custom_entity({direction=0,
layer=layer + 1,x=x,y=y, width = 16, height = 16, model="ground_effects/nightsplash", name = "grassprite"})
end
end)
-- Remove ground sprite when not overlapping
function remove_ground_sprite()
for entity in map:get_entities_by_type("custom_entity") do
if entity:get_model() == "ground_effects/nightsplash" then
entity:remove()
end
end
end
-- Handles what to do when the hero is on the platform
function handle_on_platform(hero)
if hero:get_state() == "free" or hero:get_state() == "carrying" then
hero:set_walking_speed(70) -- reduce speed while in entity
elseif hero:get_state() == "sword_loading" then
hero:set_walking_speed(29)
end
end
-- Handle what to do when the hero is off the platform
function handle_off_platform(hero)
if hero:get_state() == "free" or hero:get_state() == "carrying" then
hero:set_walking_speed(88) -- return speed to normal when outside of entity
remove_ground_sprite()
elseif hero:get_state() == "sword_loading" then
hero:set_walking_speed(29)
remove_ground_sprite()
end
end
-- Refresh every 30ms
local timer = sol.timer.start(30, function()
if self:is_on_platform(hero) then
handle_on_platform(hero)
else
handle_off_platform(hero)
end
return true -- loop forever
end)
end
function entity:is_on_platform(other) -- function to check if hero overlaps entity
local x, y, layer = hero:get_position()
return entity:overlaps(x, y)
end
At least this way we can probably pinpoint exactly which function is failing. You need to write print() statements inside of each of these and make sure they all work properly.
If it's flicking between on/off, I'd guess that maybe this script is setting things globally that should only apply to each individual object, or it's repeatedly creating and destroying the object for some reason. It's hard to help more without actually testing it in your game, but I hope this helps you down the right track.
#36
Development / Re: What changed in 1.5.3?
December 28, 2018, 07:52:15 PM
So, it runs every 30ms? I refactored your code because it still didn't make sense to me:
Why don't you include print() lines in each conditional of the timer that tells you if that conditional was reached? Unless the remove_ground_sprite() function isn't working, it could be hitting either of the first two conditionals instead.
Code ( lua) Select
local entity = ...
local game = entity:get_game()
local map = entity:get_map()
local hero = map:get_hero()
local grass = false
local timer = nil
function entity:on_created()
self:set_size(16, 16)
self:set_modified_ground("traversable")
self:set_traversable_by("hero", true)
self:add_collision_test("center", function(self, hero)
local x, y, layer = hero:get_position()
if not map:has_entity("grassprite") and self:is_on_platform(hero) then -- create ground sprite if hero overlaps entity
local grassprite = map:create_custom_entity({direction=0,
layer=layer + 1,x=x,y=y, width = 16, height = 16, model="ground_effects/nightsplash", name = "grassprite"})
end
end)
-- remove ground sprite when not overlapping
function remove_ground_sprite()
for entity in map:get_entities_by_type("custom_entity") do -- remove ground sprite when not overlapping
if entity:get_model() == "ground_effects/nightsplash" then
entity:remove()
end
end
end
-- timer to check that hero is still overlapping
local timer = sol.timer.start(30, function()
if self:is_on_platform(hero) and (hero:get_state() == "free" or hero:get_state() == "carrying") then
hero:set_walking_speed(70) -- reduce speed while in entity
elseif self:is_on_platform(hero) and hero:get_state() == "sword_loading" then
hero:set_walking_speed(29)
elseif (not self:is_on_platform(hero)) and (hero:get_state() == "free" or hero:get_state() == "carrying") then
hero:set_walking_speed(88) -- return speed to normal when outside of entity
remove_ground_sprite()
elseif (not self:is_on_platform(hero)) and hero:get_state() == "sword_loading" then
hero:set_walking_speed(29)
remove_ground_sprite()
else
remove_ground_sprite()
end
return true -- loop forever
end)
end
function entity:is_on_platform(other) -- function to check if hero overlaps entity
local x, y, layer = hero:get_position()
return entity:overlaps(x, y)
end
Why don't you include print() lines in each conditional of the timer that tells you if that conditional was reached? Unless the remove_ground_sprite() function isn't working, it could be hitting either of the first two conditionals instead.
#37
General discussion / Re: Solarus 1.6 snap release
December 28, 2018, 04:33:40 PM
Cool, I shared on Mastodon as well. https://mastodon.gamedev.place/@solarus/101319388829691003
#38
General discussion / Re: Solarus 1.6 snap release
December 28, 2018, 03:50:06 PM
By the way, here are some badges you could use:
Code Select
<a href="https://snapcraft.io/solarus">
<img alt="Get it from the Snap Store" src="https://snapcraft.io/static/images/badges/en/snap-store-black.svg" />
</a>
Code Select
<a href="https://snapcraft.io/solarus">
<img alt="Get it from the Snap Store" src="https://snapcraft.io/static/images/badges/en/snap-store-white.svg" />
</a>
#39
General discussion / Solarus 1.6 snap release
December 28, 2018, 02:36:43 AM
Hi everyone,
I've just put some finishing touches on the Solarus 1.6 snap release.
If you're on Ubuntu, you can search for "Solarus" in the software center and install it from there. That's it!
For other distros, you need to first install snapd. It's probably as simple as sudo <yourPM> install snapd, but you can click the link for more info.
Once you have snapd installed, just run sudo snap install solarus and you'll be good to go!
Known bugs are listed here: https://gitlab.com/solarus-games/solarus-snap/issues
Please report any you find to that. Thanks!
If sound doesn't work: Open Ubuntu Software > Installed > Solarus [ver] > Permissions > Audio Channel and give it permission to run PulseAudio. (thanks latchk3y!)
I've just put some finishing touches on the Solarus 1.6 snap release.
If you're on Ubuntu, you can search for "Solarus" in the software center and install it from there. That's it!
For other distros, you need to first install snapd. It's probably as simple as sudo <yourPM> install snapd, but you can click the link for more info.
Once you have snapd installed, just run sudo snap install solarus and you'll be good to go!
Known bugs are listed here: https://gitlab.com/solarus-games/solarus-snap/issues
Please report any you find to that. Thanks!
If sound doesn't work: Open Ubuntu Software > Installed > Solarus [ver] > Permissions > Audio Channel and give it permission to run PulseAudio. (thanks latchk3y!)
#40
Development / Re: What changed in 1.5.3?
December 26, 2018, 05:32:02 PM
I want to help but it's quite difficult to read and understand your code since it isn't formatted correctly. Do you think you can repost it with all the extra lines removed, have it properly tabbed out when nesting conditionals, and maybe add some comments to explain what each piece does?
#41
Development / Re: Weird Stairs Issue
December 25, 2018, 11:05:44 PM
Oh sorry, I think I replied before fully understanding. Also I should have used hero:set_layer which I didn't know about.
I don't have this issue in my game, but my character sprite is also only 16px tall.
I don't have this issue in my game, but my character sprite is also only 16px tall.
#42
Development / Re: Weird Stairs Issue
December 25, 2018, 11:04:09 PM
Here's my solution in VOADI: https://gitlab.com/voadi/voadi/blob/master/data/maps/overworld.lua#L63-78
Here's how it looks on my map:
And the same spot with layer 2 hidden:
Would be even better to encapsulate this behavior into a custom entity that automatically creates the needed sensors.
Code Select
do
local sensor = map:get_entity("bridge_1")
function sensor:on_activated()
local x, y, z = hero:get_position()
hero:set_position(x, y, 1)
log("Hero moved to L1: ", hero:get_position())
end
end
do
local sensor = map:get_entity("bridge_2")
function sensor:on_activated()
local x, y, z = hero:get_position()
hero:set_position(x, y, 0)
log("Hero moved to L0: ", hero:get_position())
end
end
Here's how it looks on my map:
And the same spot with layer 2 hidden:
Would be even better to encapsulate this behavior into a custom entity that automatically creates the needed sensors.
#43
Development / Re: New Debian/Ubuntu Package Location
December 22, 2018, 11:50:26 PM
Hi Nate-Devv,
1.6 was just released. Do you have any plans to update the PPA? Thank you!
1.6 was just released. Do you have any plans to update the PPA? Thank you!
#44
Your projects / Re: Children of Solarus [official thread]
December 12, 2018, 02:04:23 AM
Is the story the same as zsdx but with original characters instead?
#45
Your projects / Re: Vegan on a Desert Island
December 09, 2018, 08:04:59 PM
We're now on the Solarus Discord at #voadi. I post daily updates about my progress, so feel free to follow along!
You can also join via Matrix at #voadi:matrix.org.
You can also join via Matrix at #voadi:matrix.org.