railcarts/cart.lua
Ciaran Gultnieks 80bbb57df2 Initial commit
2014-03-26 19:10:30 +00:00

53 lines
1.5 KiB
Lua

minetest.register_entity("railcarts:cart_ent", {
physical = true,
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
visual = "mesh",
textures = { "railcarts_tex_cart.png" },
mesh= "railcarts_cart.x",
visual_size = {x=1,y=1,z=1},
groups = { immortal=1, },
carttype = "passenger",
getitem = "railcarts:cart",
on_activate = cartbase.on_activate_handler,
get_staticdata = cartbase.get_staticdata_handler,
on_step = cartbase.on_step_handler,
on_punch = cartbase.on_punch_handler,
on_rightclick = function(self, clicker)
if not self.linkedplayer then
self.linkedplayer = clicker
clicker:set_attach(self.object, "", {x=0,y=0,z=0}, {x=0,y=0,z=0})
cartbase.setdirection(self, nil, self.direction)
else
self.linkedplayer = nil
clicker:set_detach()
end
end
})
minetest.register_craftitem("railcarts:cart", {
description = "Cart",
image = minetest.inventorycube("railcarts_inv_cart_top.png",
"railcarts_inv_cart_side.png",
"railcarts_inv_cart_side.png"),
on_place = function(item, placer, pointed_thing)
return cartbase.place_cart(item, pointed_thing, "railcarts:cart_ent")
end
})
minetest.register_craft({
output = "railcarts:cart",
recipe = {
{"", "", ""},
{"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
},
})