Author Topic: [Solved]Create custom entity with script?  (Read 802 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) [Select]
  map:create_custom_entity({
    name = "box",
    direction = 2,
    layer = 0,
    x = entity:get_position(),
    y = entity:get_position(),
    sprite = "entities/box",
    })
« Last Edit: May 05, 2017, 09:32:16 am by zutokaza »

Zefk

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

Code: ( lua) [Select]
local xe,ye = entity:get_position()

  map:create_custom_entity({
    name = "box",
    direction = 2,
    layer = 0,
    width = 16,
    height = 16,
    x = xe,
    y = ye,
    sprite = "entities/box",
    })