Show Posts

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.


Messages - Starlock

Pages: [1] 2 3 ... 6
1
Development / Re: What changed in 1.5.3?
« on: June 04, 2018, 01:01:18 am »
I used the most recent snapshot and it still causes the same issue.

2
Development / What changed in 1.5.3?
« on: June 01, 2018, 06:13:51 pm »
Hey, I created a custom grass entity in 1.5.0. Everything worked fine until I downloaded 1.5.3, and now there'es a problem. The code creates grass beneath the hero that normally disappears when the hero leaves the grass or cuts the grass down, but in 1.5.3 the grass doesn't disappear anymore.

This is the code:

Code: Lua
  1. local entity = ...
  2. local game = entity:get_game()
  3. local map = entity:get_map()
  4. local hero = map:get_hero()
  5. local grass = false
  6.  
  7. local function resetherospeed()
  8. local hero = map:get_hero()
  9.   hero:set_walking_speed(88)
  10. end
  11.  
  12.  
  13.  
  14.  
  15.  
  16. local function on_collision(torch, other, torch_sprite, other_sprite)
  17.  
  18.   if other:get_type() == "custom_entity" then
  19.  
  20.     local other_model = other:get_model()
  21.     if other_model == "fire" or other_model == "bluefire" then
  22.  
  23.     local x, y, layer = entity:get_position()
  24.     map:create_pickable({layer = layer, x=x, y=y, treasure_name="random"})
  25.  
  26.   if map:has_entity("grassprite") then
  27.     map:get_entity("grassprite"):remove()
  28.   end
  29.  
  30. map:create_custom_entity({direction=0,
  31.     layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
  32.  
  33.     entity:remove()
  34.  
  35. sol.timer.start(350, function()
  36.   local x,y, layer = entity:get_position()
  37.  
  38. if other_model == "fire" then
  39.  
  40. map:create_custom_entity({direction=0,
  41.     layer=layer,x=x,y=y + 16, width = 16, height = 16, model="fire"})
  42.  
  43. map:create_custom_entity({direction=0,
  44.     layer=layer,x=x,y=y - 16, width = 16, height = 16, model="fire"})
  45.  
  46. map:create_custom_entity({direction=0,
  47.     layer=layer,x=x + 16,y=y, width = 16, height = 16, model="fire"})
  48.  
  49. map:create_custom_entity({direction=0,
  50.     layer=layer,x=x - 16,y=y, width = 16, height = 16, model="fire"})
  51.  
  52. elseif other_model == "bluefire" then
  53.  
  54. map:create_custom_entity({direction=0,
  55.     layer=layer,x=x,y=y + 16, width = 16, height = 16, model="bluefire"})
  56.  
  57. map:create_custom_entity({direction=0,
  58.     layer=layer,x=x,y=y - 16, width = 16, height = 16, model="bluefire"})
  59.  
  60. map:create_custom_entity({direction=0,
  61.     layer=layer,x=x + 16,y=y, width = 16, height = 16, model="bluefire"})
  62.  
  63. map:create_custom_entity({direction=0,
  64.     layer=layer,x=x - 16,y=y, width = 16, height = 16, model="bluefire"})
  65.  
  66. end
  67.  
  68.   end)
  69.     end
  70.  
  71.   end
  72. end
  73.  
  74.  
  75.  
  76.  
  77. -- Event called when the custom entity is initialized.
  78. function entity:on_created()
  79.  
  80.   self:set_size(16, 16)
  81.   self:set_modified_ground("traversable")
  82.   self:set_traversable_by("hero", true)
  83.   self:create_sprite("entities/grass")
  84.  
  85.   self:add_collision_test("center", function(entity, hero)
  86.  
  87.  
  88.  
  89.     if not grass then
  90.      
  91.       if hero:get_animation() == "walking" or hero:get_animation() == "walking_with_shield" or hero:get_animation() == "rolling" or hero:get_animation() == "carrying_walking" and not grass then
  92. grass = true
  93.  
  94.     print(hero:get_walking_speed())
  95.  
  96. grass = false
  97.         local x, y, layer = hero:get_position()
  98.  
  99. if not map:get_entity("leaves") then
  100.  
  101. map:create_custom_entity({direction=0,
  102.     layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
  103.  
  104. end
  105.  
  106.       sol.timer.start(300, function()
  107.   return true
  108.  
  109.  
  110.  
  111.       end)
  112.  
  113.       end
  114.     end
  115.  
  116.         local x, y, layer = hero:get_position()
  117.  
  118. if not map:get_entity("grassprite") then
  119.  
  120. map:create_custom_entity({direction=0,
  121.     layer=layer + 1,x=x,y=y, width = 16, height = 16, model="ground_effects/grass", name = "grassprite"})
  122.  
  123. end
  124.  
  125.   end)
  126.  
  127.  
  128.   sol.timer.start(entity, 30, function()
  129.  
  130.     -- Save or clear solid ground position on this platform.
  131.     if self:is_on_platform(hero) and (hero:get_state() == "free" or hero:get_state() == "carrying") then
  132.  
  133. hero:set_walking_speed(70)
  134.  
  135.    elseif self:is_on_platform(hero) and hero:get_state() == "sword_loading" then
  136.  
  137. hero:set_walking_speed(29)
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.     elseif (not self:is_on_platform(hero)) and (hero:get_state() == "free" or hero:get_state() == "carrying") then
  145.  
  146.     hero:set_walking_speed(88)
  147.  
  148.   if map:has_entity("grassprite") then
  149.     map:get_entity("grassprite"):remove()
  150.   end
  151.  
  152.     elseif (not self:is_on_platform(hero)) and hero:get_state() == "sword_loading" then
  153.  
  154.     hero:set_walking_speed(29)
  155.  
  156.   if map:has_entity("grassprite") then
  157.     map:get_entity("grassprite"):remove()
  158.   end
  159.  
  160. ------------------------------------------
  161.  
  162.   else
  163.  
  164.  
  165.   if map:has_entity("grassprite") then
  166.     map:get_entity("grassprite"):remove()
  167.   end
  168.  
  169. -------------------------------------------
  170.  
  171.     end
  172.  
  173.  
  174.  
  175.     return true
  176.   end)
  177.  
  178.   entity:add_collision_test("sprite", function(entity, other_entity, sprite, other_sprite)
  179.     -- Do nothing if the animation set is not of the sword, or if the sword is not close enough.
  180.     if other_sprite == nil then return end
  181.     local animation_set = other_sprite:get_animation_set()
  182.     local sword_id = map:get_hero():get_sword_sprite_id()
  183.     if animation_set ~= sword_id then return end
  184.     if entity:get_distance(other_entity) > 28 then return end -- Set a max distance to cut.
  185.  
  186.     local x, y, layer = entity:get_position()
  187.     map:create_pickable({layer = layer, x=x, y=y, treasure_name="random"})
  188.  
  189.   if map:has_entity("grassprite") then
  190.     map:get_entity("grassprite"):remove()
  191.   end
  192.  
  193. map:create_custom_entity({direction=0,
  194.     layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
  195.  
  196.     entity:remove()
  197.  
  198.   end)
  199.  
  200.  
  201.  
  202.  
  203.   entity:add_collision_test("center", function(entity, hookshot)
  204.  
  205.   if hookshot:get_sprite():get_animation() == "hook" then
  206.  
  207.     local x, y, layer = entity:get_position()
  208.     map:create_pickable({layer = layer, x=x, y=y, treasure_name="random"})
  209.  
  210.   if map:has_entity("grassprite") then
  211.     map:get_entity("grassprite"):remove()
  212.   end
  213.  
  214. map:create_custom_entity({direction=0,
  215.     layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
  216.  
  217.     entity:remove()
  218.     end
  219.  
  220.   end)
  221.  
  222.  
  223.  
  224.  
  225. end
  226.  
  227.  
  228. function entity:is_on_platform(other)
  229.   local x, y, layer = hero:get_position()
  230.   return entity:overlaps(x, y)
  231. end
  232.  
  233. entity:add_collision_test("sprite", on_collision)
  234. entity:add_collision_test("overlapping", on_collision)
  235.  
  236.  
  237.  
  238.  

3
Development / Re: How to create entity over hero?
« on: May 08, 2018, 10:16:31 pm »
Yeah, it looks like making it y+1 made it work. Thanks

4
Development / Re: How to create entity over hero?
« on: May 08, 2018, 04:29:26 pm »
Hey, sorry for the late response I've been busy with college.

This doesn't really seem to work. Sometimes the entity will appear on top and other times it won't. This is the code for the entity, it's purpose is to follow directly on top of the hero.

Code: Lua
  1. local entity = ...
  2. local map = entity:get_map()
  3. local hero = map:get_hero()
  4.  
  5.  
  6. function entity:on_created()
  7.   local sprite = self:create_sprite("hero/swordflame")
  8.   self:set_traversable_by(true)
  9.   self:set_drawn_in_y_order(true)
  10.  
  11.     local kai_movement = sol.movement.create("target")
  12.     kai_movement:set_target(hero)
  13.     kai_movement:set_speed(1000)
  14.     kai_movement:start(entity, function()
  15.     end)
  16.  
  17. end
  18.  
  19. function entity:on_update()
  20.  
  21.         local x, y, layer = hero:get_position()
  22.  
  23. entity:set_position(x, y, layer)
  24.  
  25. end

5
Development / How to create entity over hero?
« on: April 09, 2018, 03:39:39 am »
So I'm trying to create an entity that overlaps the hero,but whenever I attempt this the hero is always on top. The only way I've found to fix this problem is by setting the entity to the hero's layer + 1, but this leads to other graphical issues, so it really needs to be on the hero's layer.

6
Development / Are attack combos possible
« on: January 27, 2018, 11:16:18 pm »
I've taken a break from development for a while to work on musics and to focus on college, but I'm thinking of ideas for when I start working again and was wondering if commands and keys can be combined to create different sword attacks.

Like if you use "attack" while holding a direction the hero will lunge in that direction.

There is also a custom roll code I have done that freezes the hero and makes him roll forward then unfreezes him. Would there be a way to combine the roll with attack to make a kind of "sword roll"  or would this not work since the hero is frozen?

7
Development / Re: Issue with playing music
« on: January 19, 2018, 12:04:27 am »
That didn't seem to work. The music still restarts whenever you go from one map to another. Isn't it not supposed to restart regardless if it's the same song, like what it says on the wiki?

"If you set the music name to the same music that is already playing, or to the special value "same", then this function does nothing: the music keeps playing (it does not restart) and the second parameter is ignored."

8
Development / Issue with playing music
« on: January 18, 2018, 09:52:14 pm »
Whenever I go from one map to another, the song will restart despite it being the same song. I'm calling the sol.audio.play_music(music_id, [action]) from inside of the map:on_started() since there are three different songs that can play depending on your progress in the game. What do I need to do to stop the music from restarting?

9
Development / How do drawables work
« on: November 23, 2017, 06:08:43 am »
I'm trying to make a sort of mirror using a sensor that enables a sprite using the hero sprite. I want to keep the hero sprite only within the box of the mirror and to not show any of the sprite outside of the mirror and drawable:draw_region() sounds like its something that could work, but I'm not exactly sure how to use it.

10
Development / Can an enemy activate a switch?
« on: October 26, 2017, 08:06:15 am »
I'm trying to make a projectile that activates a switch, but when I put in enemy:overlaps(entity) an error comes up saying that it expects an integer so I'm not sure what to do for this.

11
Your scripts / Re: A chest created when all the enemies are killed
« on: October 10, 2017, 08:24:56 pm »
Hey, could you post your current code?

You might have to make the declaration in the map:on_started() function It would be something like this

Code: Lua
  1.   if game:get_value("chestsavevalue") then yourchestname:set_enabled(true) else yourchestname:set_enabled(false) end

The functions you are talking about should look something like this:

Code: Lua
  1. for enemy in map:get_entities("yourenemy") do
  2.   enemy.on_dead = function()
  3.     if not map:has_entities("yourenemy") then
  4.       yourchestname:set_enabled(true)
  5.       sol.audio.play_sound("chest_appears")
  6.     end
  7.   end
  8. end

12
Development / Multiple ground sprites?
« on: August 10, 2017, 06:23:19 pm »
Is it possible to have multiple ground sprites for the same ground? Like if you have grey grass and green grass you would have different ground sprites for the hero depending on which color grass you are in.

13
Development / How does the overworld map menu work?
« on: July 16, 2017, 05:35:13 am »
Like the title says, I'm starting to try and make the overworld map for my quest,  but I'm not sure how to properly draw out the map? Does every 320x240 map become a 32x24 square on the overworld map? I just need someone to clearly state what would be the best way to tackle creating the world map. Thanks  :)

14
Development / Stop slide on ice?
« on: June 02, 2017, 04:44:15 am »
Hey, is it possible to make the hero stop sliding when walking on ice? When I use the hookshot while sliding the hero will slide but the hook leader will stay in the place from before the slide and if it hooks on something the hero will become stuck

15
Development / Problem with timer
« on: May 29, 2017, 09:48:25 pm »
I'm trying to make a bridge that appears when at least one of three torches is lit. I'm having trouble making the timer work properly, since once the timer finishes there's a delay before it can activate again so you can't light the torch again in that time frame. Is there a way to make the timer instantly be activatable again after it finishes?

Here is my code(It is part of function map:on_update()):
Code: Lua
  1.   if torch_light:get_sprite():get_animation() == "lit" or torch_light_2:get_sprite():get_animation() == "lit" or
  2.   torch_light_3:get_sprite():get_animation() == "lit" then
  3.       map:set_entities_enabled("torchbridge", true)
  4.         sol.timer.start(3500, function()
  5.  
  6.           map:set_entities_enabled("torchbridge", false)
  7. torch_light:get_sprite():set_animation("unlit")
  8. torch_light_2:get_sprite():set_animation("unlit")
  9. torch_light_3:get_sprite():set_animation("unlit")
  10.       end)
  11.     end

Pages: [1] 2 3 ... 6