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 - zutokaza

Pages: [1] 2 3 ... 10
1
Development / Re: Jump movement direction4 error?
« on: June 24, 2017, 02:18:29 am »
I confirm the bug. I got the same problem when I checked this with a custom entity.

2
Development / Re: [Solved]How to get the hero in an item script?
« on: June 06, 2017, 06:32:08 pm »
@Christopho @Zefk
Both solutions work! Thank you!

3
Development / [Solved]How to get the hero in an item script?
« on: June 06, 2017, 04:58:05 am »
I am wondering how to get the hero in an item script.

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?
« on: June 05, 2017, 08:36:50 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?
« on: June 04, 2017, 04:47:02 am »
Can anyone give me an example? Please...  :D

6
Development / Re: Get all map entities?
« on: June 02, 2017, 05:08:13 pm »
Quote
make 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?
« on: 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?
« on: May 25, 2017, 03:20:23 am »
@llamazing
Exactly what I wanted. Thanks again for your assistance!

9
Development / Re: Assign argument variables in function parameter?
« on: 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
How would I do something like this?

Code: ( lua) [Select]
function test(a = 5, b = "hey", c = true)
  if a == 5 then
    print("Letter A is",a)
  end
end

test()

I know it can be done like this:

Code: ( lua) [Select]
function test(a, b, c)
a = 5
b = "hey"
c = true
  if a == 5 then
    print("Letter A is",a)
  end
end

test()

11
Development / Re: Screen vs entity position?
« on: 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?

12
Development / [Solved]Create custom entity with script?
« on: 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?
« on: 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?
« on: 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?
« on: April 16, 2017, 07:22:12 am »
Could I get an example?

I tried this, but is fails...
Code: ( lua) [Select]
function hero:on_state_changed("sword spin attack")
  hero:unfreeze()
end

Pages: [1] 2 3 ... 10