forked from mtcontrib/homedecor_modpack
Add soda vending machine
This commit is contained in:
parent
3c891aa24e
commit
8311c7d87d
@ -118,6 +118,17 @@ minetest.register_craftitem("homedecor:chainlink_brass", {
|
||||
inventory_image = "homedecor_chainlink_brass.png"
|
||||
})
|
||||
|
||||
minetest.register_craftitem("homedecor:soda_can", {
|
||||
description = "Soda Can",
|
||||
inventory_image = "homedecor_soda_can.png",
|
||||
on_use = minetest.item_eat(2),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("homedecor:coin", {
|
||||
description = "Gold Coin",
|
||||
inventory_image = "homedecor_coin.png",
|
||||
})
|
||||
|
||||
-- alternate crafting if mesecons is/isn't installed
|
||||
|
||||
if not minetest.get_modpath("mesecons") then
|
||||
@ -3198,6 +3209,33 @@ minetest.register_craft({
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "homedecor:soda_machine",
|
||||
recipe = {
|
||||
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "dye:red", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:copperblock", "default:steel_ingot"},
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "homedecor:coin 5",
|
||||
recipe = {"moreblocks:micro_goldblock_1", "default:sword_stone"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "homedecor:coin 15",
|
||||
recipe = {"default:gold_ingot", "default:sword_steel"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "homedecor:coin 50",
|
||||
recipe = {"default:goldblock", "default:sword_mese"}
|
||||
})
|
||||
|
||||
for i in ipairs(homedecor.banister_materials) do
|
||||
|
||||
local name = homedecor.banister_materials[i][1]
|
||||
|
@ -828,3 +828,35 @@ minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack
|
||||
end
|
||||
end)
|
||||
|
||||
local svm_cbox = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5}
|
||||
}
|
||||
|
||||
homedecor.register("soda_machine", {
|
||||
description = "Soda Vending Machine",
|
||||
mesh = "homedecor_soda_machine.obj",
|
||||
tiles = {"homedecor_soda_machine.png"},
|
||||
groups = {snappy=3},
|
||||
selection_box = svm_cbox,
|
||||
collision_box = svm_cbox,
|
||||
expand = { top="air" },
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
local wielditem = puncher:get_wielded_item()
|
||||
local wieldname = wielditem:get_name()
|
||||
local fdir_to_fwd = { {0, -1}, {-1, 0}, {0, 1}, {1, 0} }
|
||||
local fdir = node.param2
|
||||
local pos_drop = { x=pos.x+fdir_to_fwd[fdir+1][1], y=pos.y, z=pos.z+fdir_to_fwd[fdir+1][2] }
|
||||
if wieldname == "homedecor:coin" then
|
||||
wielditem:take_item()
|
||||
puncher:set_wielded_item(wielditem)
|
||||
minetest.spawn_item(pos_drop, "homedecor:soda_can")
|
||||
minetest.sound_play("insert_coin", {
|
||||
pos=pos, max_hear_distance = 5
|
||||
})
|
||||
else
|
||||
minetest.chat_send_player(puncher:get_player_name(), "Please insert a coin in the machine.")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
34
homedecor/models/homedecor_soda_machine.obj
Normal file
34
homedecor/models/homedecor_soda_machine.obj
Normal file
@ -0,0 +1,34 @@
|
||||
# Blender v2.72 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib vending_machine.mtl
|
||||
o Cube
|
||||
v 0.499998 -0.499998 -0.499998
|
||||
v 0.499998 -0.499998 0.499998
|
||||
v -0.499998 -0.499998 0.499998
|
||||
v -0.499998 -0.499998 -0.499998
|
||||
v 0.499998 1.499994 -0.499998
|
||||
v 0.499998 1.499994 0.499998
|
||||
v -0.499998 1.499994 0.499998
|
||||
v -0.499998 1.499994 -0.499998
|
||||
vt 0.250050 0.250050
|
||||
vt 0.000100 0.250050
|
||||
vt 0.000100 0.000100
|
||||
vt 0.250050 0.000100
|
||||
vt 0.250050 0.749950
|
||||
vt 0.250050 0.999900
|
||||
vt 0.000100 0.999900
|
||||
vt 0.000100 0.749950
|
||||
vt 0.999900 0.250049
|
||||
vt 0.999900 0.749949
|
||||
vt 0.749950 0.749950
|
||||
vt 0.749950 0.250050
|
||||
vt 0.500000 0.749950
|
||||
vt 0.500000 0.250050
|
||||
usemtl Material
|
||||
s off
|
||||
f 1/1 2/2 3/3 4/4
|
||||
f 5/5 8/6 7/7 6/8
|
||||
f 1/1 5/5 6/8 2/2
|
||||
f 2/9 6/10 7/11 3/12
|
||||
f 3/12 7/11 8/13 4/14
|
||||
f 5/5 1/1 4/14 8/13
|
BIN
homedecor/sounds/insert_coin.ogg
Normal file
BIN
homedecor/sounds/insert_coin.ogg
Normal file
Binary file not shown.
BIN
homedecor/textures/homedecor_coin.png
Normal file
BIN
homedecor/textures/homedecor_coin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 331 B |
BIN
homedecor/textures/homedecor_soda_can.png
Normal file
BIN
homedecor/textures/homedecor_soda_can.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 B |
BIN
homedecor/textures/homedecor_soda_machine.png
Normal file
BIN
homedecor/textures/homedecor_soda_machine.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Loading…
Reference in New Issue
Block a user