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

0 Members and 1 Guest are viewing this topic.

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: 535
  • Just helping Solarus
    • View Profile
    • Zefk Design
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",
    })