I confirm the bug. I got the same problem when I checked this with a custom entity.
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.
#2
Development / Re: [Solved]How to get the hero in an item script?
June 06, 2017, 06:32:08 PM
@Christopho @Zefk
Both solutions work! Thank you!
Both solutions work! Thank you!
#3
Development / [Solved]How to get the hero in an item script?
June 06, 2017, 04:58:05 AM
I am wondering how to get the hero in an item script.
I want to do this:
I tried:
and
and
I want to do this:
Code ( lua) Select
--slow the hero down
function item:on_map_changed(map)
hero:set_walking_speed(30)
end
I tried:
Code ( lua) Select
local item = ...
local game = item:get_game()
local hero = game:get_hero()
and
Code ( lua) Select
local item = ...
local game = item:get_game()
local map = item:get_map()
local hero = map:get_entity("hero")
and
Code ( lua) Select
local item = ...
local game = item:get_game()
local map = item:get_map()
local hero = map:get_hero()
#4
Development / Re: Get all map entities?
June 05, 2017, 08:36:50 PMQuote from: ffomega on June 05, 2017, 01:50:45 PM
I think the best example would be the "Evil Tile". these are the tiles in dungeons that lift up and fly at the hero, one at a time, with a timed delay between each tile's movements.
Do you know what map and game the "Evil Tile" exists in?
Edit:
Found it.
https://github.com/solarus-games/zsdx/blob/dev/data/maps/evil_tiles.lua
#5
Development / Re: Get all map entities?
June 04, 2017, 04:47:02 AM
Can anyone give me an example? Please...
#6
Development / Re: Get all map entities?
June 02, 2017, 05:08:13 PMQuotemake a loop to detect the closest entity from a list of entities
How is that done? My script looks like this so far.
Code ( lua) Select
-- Call a function every second.
sol.timer.start(5000, function()
local birds = map:get_entities("bird_")
local npc_near_birds = npc_1:get_distance(birds)
if npc_near_birds < 10 then
movement = sol.movement.create("target")
movement:set_target(birds)
movement:set_speed(48)
movement:start(npc_1)
end
return true -- To call the timer again (with the same delay).
end)
#7
Development / [Solved]Get all map entities?
June 01, 2017, 09:44:18 PM
Is it possible make a NPC target entities with a prefix?
Code ( lua) Select
target_movement:set_target(map:get_entities("bird_"))
#8
Development / Re: Assign argument variables in function parameter?
May 25, 2017, 03:20:23 AM
@llamazing
Exactly what I wanted. Thanks again for your assistance!
Exactly what I wanted. Thanks again for your assistance!
#9
Development / Re: Assign argument variables in function parameter?
May 24, 2017, 08:05:43 PM
Yes, I know of that method too. I want to know if it is possible to do like the surface create function. I would like to assign variables in a table for easier reading.
Code ( lua) Select
sol.text_surface.create({ -- name a local variable something and assign it to the sol.text_surface
font = "minecraftia", -- font name
text = "what", -- text you want to show
font_size = 50, -- font size obviously
horizontal_alignment = "center", -- default "left"
vertical_alignment = "bottom", -- default "middle"
rendering_mode = "antialiasing", -- "solid" (faster) and default
color = {0,0,0}, -- color must be in a table RGB (http://www.rapidtables.com/web/color/RGB_Color.htm)
})
#10
Development / [Solved]Assign argument variables in function parameter?
May 16, 2017, 07:20:13 AM #11
Development / Re: Screen vs entity position?
May 15, 2017, 04:32:51 PM
I think getting the position of the entities with entity:get_position() only works for drawing if your map is 320 x 240. It has to be the same as the quest size.
I am not really sure how to solve this. There might need to be drawing checks as the map scrolls. Some calculations would work until the hero starts in a location where the map scrolls.
Maybe @Diarandor or Christopho knows?
I am not really sure how to solve this. There might need to be drawing checks as the map scrolls. Some calculations would work until the hero starts in a location where the map scrolls.
Maybe @Diarandor or Christopho knows?
#12
Development / [Solved]Create custom entity with script?
May 04, 2017, 03:33:03 PM
I want to create a custom entity with script, but I am having trouble creating it. I want to create a new entity at the position of an already existing entity.
Code ( lua) Select
map:create_custom_entity({
name = "box",
direction = 2,
layer = 0,
x = entity:get_position(),
y = entity:get_position(),
sprite = "entities/box",
})
#13
Development / [Solved]Disable spin Attack?
April 27, 2017, 07:05:28 PM
That works perfectly. I was able to activate it with set_value. Thanks again zefk!
#14
Development / Re: Disable spin Attack?
April 16, 2017, 10:18:40 AM
I got it somewhat working now, but it does not disable anything. It just unfreezes the player after a spin attack.
Code ( lua) Select
function hero:on_state_changed(state)
if state == "sword spin attack" then
hero:unfreeze()
end
end
#15
Development / Re: Disable spin Attack?
April 16, 2017, 07:22:12 AM
Could I get an example?
I tried this, but is fails...
I tried this, but is fails...
Code ( lua) Select
function hero:on_state_changed("sword spin attack")
hero:unfreeze()
end