60 lines
1.6 KiB
Lua
60 lines
1.6 KiB
Lua
|
minetest.register_entity("amogus_rails:cart", {
|
||
|
initial_properties = {
|
||
|
visual = "mesh",
|
||
|
mesh = "cart.obj",
|
||
|
physical = true,
|
||
|
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||
|
visual_size = {x=1, y=1},
|
||
|
textures = {"cart_texture.png"},
|
||
|
},
|
||
|
|
||
|
on_activate = function(self, staticdata)
|
||
|
self.object:set_acceleration({x=0, y=-9.8, z=0})
|
||
|
end,
|
||
|
|
||
|
on_rightclick = function(self, clicker)
|
||
|
clicker:get_inventory():add_item("main", "amogus_rails:cart_item")
|
||
|
self.object:remove()
|
||
|
end,
|
||
|
})
|
||
|
|
||
|
minetest.register_craftitem("amogus_rails:cart_item", {
|
||
|
description = "Custom Cart",
|
||
|
inventory_image = "cart_inventory.png",
|
||
|
wield_image = "cart_inventory.png",
|
||
|
stack_max = 1,
|
||
|
liquids_pointable = false,
|
||
|
|
||
|
on_use = function(itemstack, placer, pointed_thing)
|
||
|
local pos = pointed_thing.under
|
||
|
--local node = minetest.get_node(pos)
|
||
|
--if minetest.get_item_group(node.name, "rail") == 0 then
|
||
|
-- return
|
||
|
--end
|
||
|
minetest.add_entity(pos, "amogus_rails:cart")
|
||
|
--if not minetest.setting_getbool("creative_mode") then
|
||
|
itemstack:take_item()
|
||
|
--end
|
||
|
return itemstack
|
||
|
end,
|
||
|
})
|
||
|
|
||
|
|
||
|
minetest.register_node("amogus_rails:rail", {
|
||
|
description = "Custom Rail",
|
||
|
drawtype = "raillike",
|
||
|
tiles = {"rail.png", "rail_curved.png", "rail_t_junction.png", "rail_crossing.png"},
|
||
|
inventory_image = "rail.png",
|
||
|
wield_image = "rail.png",
|
||
|
paramtype = "light",
|
||
|
sunlight_propagates = true,
|
||
|
is_ground_content = false,
|
||
|
walkable = false,
|
||
|
selection_box = {
|
||
|
type = "fixed",
|
||
|
fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
|
||
|
},
|
||
|
groups = {cracky=3, attached_node=1},
|
||
|
--sounds = default.node_sound_stone_defaults(),
|
||
|
})
|