82 lines
2.3 KiB
Lua
Raw Normal View History

2024-01-27 00:10:42 +01:00
local S = buggy.S
2022-11-11 10:13:29 +01:00
2022-02-03 17:04:10 -03:00
--
-- items
--
-- body
minetest.register_craftitem("automobiles_buggy:buggy_body",{
2022-11-11 10:13:29 +01:00
description = S("Buggy Body"),
2022-02-03 17:04:10 -03:00
inventory_image = "automobiles_buggy_body.png",
})
-- wheel
minetest.register_craftitem("automobiles_buggy:wheel",{
2022-11-11 10:13:29 +01:00
description = S("Buggy Wheel"),
2022-02-03 17:04:10 -03:00
inventory_image = "automobiles_buggy_wheel_icon.png",
})
-- buggy
2024-06-06 22:05:19 -03:00
minetest.register_tool("automobiles_buggy:buggy", {
2022-11-11 10:13:29 +01:00
description = S("Buggy"),
2022-02-03 17:04:10 -03:00
inventory_image = "automobiles_buggy.png",
liquids_pointable = false,
2024-06-06 22:05:19 -03:00
stack_max = 1,
2022-02-03 17:04:10 -03:00
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return
end
2022-11-11 10:13:29 +01:00
2024-06-06 22:05:19 -03:00
local stack_meta = itemstack:get_meta()
local staticdata = stack_meta:get_string("staticdata")
2022-02-03 17:04:10 -03:00
local pointed_pos = pointed_thing.above
--pointed_pos.y=pointed_pos.y+0.2
2024-06-06 22:05:19 -03:00
local car = minetest.add_entity(pointed_pos, "automobiles_buggy:buggy", staticdata)
2022-02-03 17:04:10 -03:00
if car and placer then
local ent = car:get_luaentity()
local owner = placer:get_player_name()
if ent then
ent.owner = owner
2024-06-06 22:05:19 -03:00
ent.hp = 50 --reset hp
2022-02-03 17:04:10 -03:00
car:set_yaw(placer:get_look_horizontal())
itemstack:take_item()
ent.object:set_acceleration({x=0,y=-automobiles_lib.gravity,z=0})
2024-01-27 00:10:42 +01:00
automobiles_lib.setText(ent, S("Buggy"))
2023-09-12 11:19:56 -03:00
automobiles_lib.create_inventory(ent, ent._trunk_slots, owner)
2022-02-03 17:04:10 -03:00
end
end
return itemstack
end,
})
--
-- crafting
--
if minetest.get_modpath("default") then
minetest.register_craft({
output = "automobiles_buggy:buggy",
recipe = {
{"automobiles_buggy:wheel", "automobiles_lib:engine", "automobiles_buggy:wheel"},
{"automobiles_buggy:wheel","automobiles_buggy:buggy_body", "automobiles_buggy:wheel"},
}
})
minetest.register_craft({
output = "automobiles_buggy:buggy_body",
recipe = {
{"default:glass" ,"","default:steel_ingot"},
{"default:steel_ingot","","default:steel_ingot"},
{"default:steel_ingot","default:steel_ingot", "default:steel_ingot"},
}
})
minetest.register_craft({
output = "automobiles_buggy:wheel",
recipe = {
{"default:steel_ingot", "default:tin_ingot", "default:steel_ingot"},
{"default:tin_ingot","default:steelblock", "default:tin_ingot"},
{"default:steel_ingot", "default:tin_ingot", "default:steel_ingot"},
}
})
end