Solarus-Games English Forum

Solarus => Development => Topic started by: zutokaza on May 04, 2017, 03:33:03 PM

Title: [Solved]Create custom entity with script?
Post by: zutokaza 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",
    })
Title: Re: Create custom entity??
Post by: Zefk 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",
    })