Author Topic: [Solved]Create custom entity with script?  (Read 249 times)

zutokaza

  • Full Member
  • ***
  • Posts: 146
  • Active - Making stories can take the most time.
    • View Profile
[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
  1.   map:create_custom_entity({
  2.     name = "box",
  3.     direction = 2,
  4.     layer = 0,
  5.     x = entity:get_position(),
  6.     y = entity:get_position(),
  7.     sprite = "entities/box",
  8.     })
« Last Edit: May 05, 2017, 09:32:16 am by zutokaza »

Zefk

  • Sr. Member
  • ****
  • Posts: 492
  • Just helping Solarus
    • View Profile
    • Zelzec Business
Re: Create custom entity??
« Reply #1 on: May 04, 2017, 04:41:19 pm »
This should work.

Code: Lua
  1. local xe,ye = entity:get_position()
  2.  
  3.   map:create_custom_entity({
  4.     name = "box",
  5.     direction = 2,
  6.     layer = 0,
  7.     width = 16,
  8.     height = 16,
  9.     x = xe,
  10.     y = ye,
  11.     sprite = "entities/box",
  12.     })