diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-11-27 04:31:05 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-11-29 19:13:54 +0200 |
commit | 82a460ec90b4537926f31603219504bce8817ac2 (patch) | |
tree | 91bfae1ab35367a3617e19023842d9218255b1eb /data/mods/default | |
parent | b4e6ca63b54407bf67e5656692016c4f2927358d (diff) | |
download | minetest-82a460ec90b4537926f31603219504bce8817ac2.tar.gz minetest-82a460ec90b4537926f31603219504bce8817ac2.tar.bz2 minetest-82a460ec90b4537926f31603219504bce8817ac2.zip |
Improve luaentity sprite functionality (and add some random stuff)
Diffstat (limited to 'data/mods/default')
-rw-r--r-- | data/mods/default/init.lua | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index 6ea15b4ee..ea6bf3da9 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -49,6 +49,9 @@ -- - setpos(pos); pos={x=num, y=num, z=num} -- - moveto(pos, continuous=false): interpolated move -- - add_to_inventory(itemstring): add an item to object inventory +-- - settexturemod(mod) +-- - setsprite(p={x=0,y=0}, num_frames=1, framelength=0.2, +-- - select_horiz_by_yawpitch=false) -- -- Registered entities: -- - Functions receive a "luaentity" as self: @@ -1171,8 +1174,6 @@ local TNT = { collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, visual = "cube", textures = {"tnt_top.png","tnt_bottom.png","tnt_side.png","tnt_side.png","tnt_side.png","tnt_side.png"}, - --visual = "single_sprite", - --textures = {"mese.png^[forcesingle"}, -- Initial value for our timer timer = 0, -- Number of punches required to defuse @@ -1227,6 +1228,36 @@ print("TNT dump: "..dump(TNT)) print("Registering TNT"); minetest.register_entity("TNT", TNT) + +minetest.register_entity("testentity", { + -- Static definition + physical = true, -- Collides with things + -- weight = 5, + collisionbox = {-0.7,-1.35,-0.7, 0.7,1.0,0.7}, + --collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + visual = "sprite", + visual_size = {x=2, y=3}, + textures = {"dungeon_master.png^[makealpha:128,0,0^[makealpha:128,128,0"}, + spritediv = {x=6, y=5}, + initial_sprite_basepos = {x=0, y=0}, + + on_activate = function(self, staticdata) + print("testentity.on_activate") + self.object:setsprite({x=0,y=0}, 1, 0, true) + --self.object:setsprite({x=0,y=0}, 4, 0.3, true) + + -- Set gravity + self.object:setacceleration({x=0, y=-10, z=0}) + -- Jump a bit upwards + self.object:setvelocity({x=0, y=10, z=0}) + end, + + on_punch = function(self, hitter) + self.object:remove() + hitter:add_to_inventory('CraftItem testobject1 1') + end, +}) + -- -- Falling stuff -- |