Difference between revisions of "User:Kaeza/Test"

From Minetest Developer Wiki
Jump to navigation Jump to search
(Created page with " = add_entity = <code>minetest.add_entity(pos, name)</code> Spawns a Lua-defined entity at the specified position. The <code>name</code> parameter specifies the name of...")
 
m
Line 14: Line 14:
  
 
<code>
 
<code>
local pos  
+
local pos<br />
local entity = minetest.add_entity(pos, "foo_mod:bar_entity")
+
local entity = minetest.add_entity(pos, "foo_mod:bar_entity")<br />
 
+
<br />
-- Do something with it.
+
-- Do something with it.<br />
entity:[[setacceleration]]({x=0, y=-1, z=0})
+
entity:[[setacceleration]]({x=0, y=-1, z=0})<br />
 
</code>
 
</code>

Revision as of 23:23, 18 June 2013

add_entity

minetest.add_entity(pos, name)

Spawns a Lua-defined entity at the specified position.

The name parameter specifies the name of the entity to add, which must have been previously registered via a call to register_entity.

Returns the new entity as a LuaObjectRef.

Example

local pos
local entity = minetest.add_entity(pos, "foo_mod:bar_entity")

-- Do something with it.
entity:setacceleration({x=0, y=-1, z=0})