Hey, sorry to necro the thread, but as of the release of 1.6, the entity still doesn't seem to work. I'm going to try and look through the code to see what needs to be changed.
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.
#17
Development / Re: Lua promises
December 03, 2018, 08:10:00 PM
Not sure if it's really relevant to the topic or not, but you can have multiple movements happen simultaneously if you make each movement its own local function and then call all of them at the same time.
#18
Development / Will reflections be possible in 1.6
November 12, 2018, 05:25:35 PM
With 1.6 will it be possible to make reflections like for a mirror or water?
#19
Development / Re: Starting a menu from a dialog (NPC)?
September 25, 2018, 04:30:23 PM
I've done something similar so I'm just going to post the code that I used
Code ( lua) Select
local map = ...
local game = map:get_game()
local crafting_menu = require("scripts/menus/crafting")
local hero = game:get_hero()
function fire:on_interaction()
game:start_dialog("craft_cooking", function(answer)
if answer == 3 then
sol.menu.start(game, crafting_menu)
game:set_pause_allowed(false)
hero:freeze()
end
end)
end
function crafting_menu:on_finished()
game:set_pause_allowed(true)
hero:unfreeze()
end
#20
Development / Is it possible to check when carried object hits ground
August 18, 2018, 03:57:01 PM
I'm trying to check a carried objects position so that its sprite will change to a falling effect when it lands on a hole. However, I'm having an issue where the effect will happen for every hole tile it goes over and I only want the effect to happen on the tile that it lands on not every tile that it goes over while being thrown.
#21
Development / Re: Problem with thrown enemies after pause
August 09, 2018, 04:56:39 AM
Yeah, using the sword causes the hero to throw the carried object.
#22
Development / Re: Problem with thrown enemies after pause
August 08, 2018, 04:47:32 PM
I'm using 1.5.0, since any version higher than that causes an issue with one of my custom entities. It's a problem happening on my own game.
#23
Development / Problem with thrown enemies after pause
August 08, 2018, 04:37:45 AM
When I lift a destructible object, and then pause and check the Info of an item, the action command no longer allows the hero to thrown the object. This only seems to happen when the info message is used. Does anybody have any idea what could be a likely cause of this?
EDIT: I've tested it further, and this will happen no matter what whenever any dialog is opened while paused
EDIT: I've tested it further, and this will happen no matter what whenever any dialog is opened while paused
#24
Development / Multiple enemies not acting the same
August 06, 2018, 06:18:11 AM
I have an enemy that creates small spheres that circle around the enemy and are thrown at the hero. However, when I have 2 enemies, only one of them will do the proper attack.
Code ( lua) Select
local enemy = ...
local game = enemy:get_game()
local can_shoot = true
local sprite = nil
local nb_bats_created = 0
local nb_to_create = 0
local raintimer = nil
function enemy:on_created()
-- Set properties.
self:set_life(4); self:set_damage(6); self:set_hurt_style("normal")
self:set_pushed_back_when_hurt(true); self:set_push_hero_on_sword(false)
self:set_traversable(true)
-- Create sprite if necessary, etc.
sprite = self:get_sprite()
if not sprite then sprite = self:create_sprite("enemies/more/dark/rainbow") end
function sprite:on_animation_finished(animation)
if animation == "looking" then sprite:set_animation("stopped") end --***
end
-- Start enemy.
self:restart()
end
local function go_hero()
local map = enemy:get_map()
local hero = map:get_hero()
if enemy:get_distance(hero) < 120 then
local sprite = enemy:get_sprite()
sprite:set_animation("walking")
local movement = sol.movement.create("target")
movement:set_speed(64)
movement:start(enemy)
else
local sprite = enemy:get_sprite()
sprite:set_animation("walking")
local movement = sol.movement.create("random")
movement:set_speed(64)
movement:start(enemy)
end
end
function enemy:attack()
if jumping or attacking then
return
end
if cancel_next_attack then
cancel_next_attack = false
return
end
attacking = true
sprite:set_animation("shooting")
local prefix = "bat" .. "_bat_"
nb_to_create = 6
function repeat_throw_bat()
sol.audio.play_sound("lamp")
nb_bats_created = nb_bats_created + 1
local son_name = prefix .. nb_bats_created
local son = enemy:create_enemy{
name = son_name,
breed = "more/dark/rainattack",
x = 0,
y = 0,
layer = 0,
}
if math.random(6) == 1 then
son:set_treasure("magic_flask", 1)
end
son:go_circle(enemy)
local go_hero_delay = 2000 + (nb_to_create * 150)
sol.timer.start(son, go_hero_delay, function() son:go_hero() end)
nb_to_create = nb_to_create - 1
if nb_to_create > 0 then
raintimer = sol.timer.start(enemy:get_map(), 350, repeat_throw_bat)
else
attacking = false
attack_scheduled = false
if not vulnerable then
sol.timer.start(2000, function()
go_hero()
end)
else
cancel_next_attack = false
end
end
end
enemy:stop_movement()
enemy:get_sprite():set_direction(0)
repeat_throw_bat()
end
function enemy:on_hurt()
nb_to_create = 0
if raintimer ~= nil then
raintimer:stop()
end
enemy:get_map():remove_entities("bat" .. "_bat_")
end
function enemy:on_dying()
nb_to_create = 0
if raintimer ~= nil then
raintimer:stop()
end
enemy:get_map():remove_entities("bat" .. "_bat_")
end
function enemy:on_restarted()
local map = enemy:get_map()
local hero = map:get_hero()
go_hero()
can_shoot = true
sol.timer.start(enemy, 100, function()
local hero_x, hero_y = hero:get_position()
local x, y = enemy:get_center_position()
if can_shoot then
if enemy:get_distance(hero) < 150 then
attack()
can_shoot = false
sol.timer.start(enemy, 6666, function()
can_shoot = true
end)
end
end
return true -- Repeat the timer.
end)
end
function enemy:on_movement_changed(movement)
local direction4 = movement:get_direction4()
local sprite = self:get_sprite()
sprite:set_direction(direction4)
end
#25
Development / Re: What changed in 1.5.3?
June 04, 2018, 01:01:18 AM
I used the most recent snapshot and it still causes the same issue.
#26
Development / What changed in 1.5.3?
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:
This is the code:
Code ( lua) Select
local entity = ...
local game = entity:get_game()
local map = entity:get_map()
local hero = map:get_hero()
local grass = false
local function resetherospeed()
local hero = map:get_hero()
hero:set_walking_speed(88)
end
local function on_collision(torch, other, torch_sprite, other_sprite)
if other:get_type() == "custom_entity" then
local other_model = other:get_model()
if other_model == "fire" or other_model == "bluefire" then
local x, y, layer = entity:get_position()
map:create_pickable({layer = layer, x=x, y=y, treasure_name="random"})
if map:has_entity("grassprite") then
map:get_entity("grassprite"):remove()
end
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
entity:remove()
sol.timer.start(350, function()
local x,y, layer = entity:get_position()
if other_model == "fire" then
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y + 16, width = 16, height = 16, model="fire"})
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y - 16, width = 16, height = 16, model="fire"})
map:create_custom_entity({direction=0,
layer=layer,x=x + 16,y=y, width = 16, height = 16, model="fire"})
map:create_custom_entity({direction=0,
layer=layer,x=x - 16,y=y, width = 16, height = 16, model="fire"})
elseif other_model == "bluefire" then
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y + 16, width = 16, height = 16, model="bluefire"})
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y - 16, width = 16, height = 16, model="bluefire"})
map:create_custom_entity({direction=0,
layer=layer,x=x + 16,y=y, width = 16, height = 16, model="bluefire"})
map:create_custom_entity({direction=0,
layer=layer,x=x - 16,y=y, width = 16, height = 16, model="bluefire"})
end
end)
end
end
end
-- Event called when the custom entity is initialized.
function entity:on_created()
self:set_size(16, 16)
self:set_modified_ground("traversable")
self:set_traversable_by("hero", true)
self:create_sprite("entities/grass")
self:add_collision_test("center", function(entity, hero)
if not grass then
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
grass = true
print(hero:get_walking_speed())
grass = false
local x, y, layer = hero:get_position()
if not map:get_entity("leaves") then
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
end
sol.timer.start(300, function()
return true
end)
end
end
local x, y, layer = hero:get_position()
if not map:get_entity("grassprite") then
map:create_custom_entity({direction=0,
layer=layer + 1,x=x,y=y, width = 16, height = 16, model="ground_effects/grass", name = "grassprite"})
end
end)
sol.timer.start(entity, 30, function()
-- Save or clear solid ground position on this platform.
if self:is_on_platform(hero) and (hero:get_state() == "free" or hero:get_state() == "carrying") then
hero:set_walking_speed(70)
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)
if map:has_entity("grassprite") then
map:get_entity("grassprite"):remove()
end
elseif (not self:is_on_platform(hero)) and hero:get_state() == "sword_loading" then
hero:set_walking_speed(29)
if map:has_entity("grassprite") then
map:get_entity("grassprite"):remove()
end
------------------------------------------
else
if map:has_entity("grassprite") then
map:get_entity("grassprite"):remove()
end
-------------------------------------------
end
return true
end)
entity:add_collision_test("sprite", function(entity, other_entity, sprite, other_sprite)
-- Do nothing if the animation set is not of the sword, or if the sword is not close enough.
if other_sprite == nil then return end
local animation_set = other_sprite:get_animation_set()
local sword_id = map:get_hero():get_sword_sprite_id()
if animation_set ~= sword_id then return end
if entity:get_distance(other_entity) > 28 then return end -- Set a max distance to cut.
local x, y, layer = entity:get_position()
map:create_pickable({layer = layer, x=x, y=y, treasure_name="random"})
if map:has_entity("grassprite") then
map:get_entity("grassprite"):remove()
end
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
entity:remove()
end)
entity:add_collision_test("center", function(entity, hookshot)
if hookshot:get_sprite():get_animation() == "hook" then
local x, y, layer = entity:get_position()
map:create_pickable({layer = layer, x=x, y=y, treasure_name="random"})
if map:has_entity("grassprite") then
map:get_entity("grassprite"):remove()
end
map:create_custom_entity({direction=0,
layer=layer,x=x,y=y, width = 40, height = 56, model="ground_effects/falling_leaves", name = "leaves"})
entity:remove()
end
end)
end
function entity:is_on_platform(other)
local x, y, layer = hero:get_position()
return entity:overlaps(x, y)
end
entity:add_collision_test("sprite", on_collision)
entity:add_collision_test("overlapping", on_collision)
#27
Development / Re: How to create entity over hero?
May 08, 2018, 10:16:31 PM
Yeah, it looks like making it y+1 made it work. Thanks
#28
Development / Re: How to create entity over hero?
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.
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) Select
local entity = ...
local map = entity:get_map()
local hero = map:get_hero()
function entity:on_created()
local sprite = self:create_sprite("hero/swordflame")
self:set_traversable_by(true)
self:set_drawn_in_y_order(true)
local kai_movement = sol.movement.create("target")
kai_movement:set_target(hero)
kai_movement:set_speed(1000)
kai_movement:start(entity, function()
end)
end
function entity:on_update()
local x, y, layer = hero:get_position()
entity:set_position(x, y, layer)
end
#29
Development / How to create entity over hero?
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.
#30
Development / Are attack combos possible
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?
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?