diff --git a/README.md b/README.md index 6b10e55..49161d0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,61 @@ # ma_pops_furniture -A revamp of Ma & Pop's Furniture Mod + +A revamp of Ma and Pop's Furniture Mod + +================================================================ + +Credits: +Radio Mod Code (Mihobre) +BlockMen (Lots and lots) |For helping me alot with the code + |Letting me experiment with his mod + |Supporting me all the time + |Encouraging me +DanJohansen(Newgrounds) |All music used + +Nathan.S Helped with a ton of the coding and models making this mod possible + +Freezer Mod: +https://forum.minetest.net/viewtopic.php?f=9&t=14925 + +Textures (c) 2016 Gabriel Pérez-Cerezo, WTFPL + +This mod is based on the default furnace, license for the code below: + +Copyright (C) 2011-2012 celeron55, Perttu Ahola +Copyright (C) 2016 Gabriel Pérez-Cerezo + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +================================================================ + +Special thanks to: +Wizzerine +BillyS +Noodlemire + +For helping out with the microwave. + +================================================================= + +Each item used as tool and what it does: + +Hammer: Rotates and/or changes the type of sofa and bookshelf. + +Hammer1: Rotates and/or changes the type of counter and table. + +Shears: "Trims" the hedges making it possible for different rotation and direction of hedge. + +Saw: Used to turn a bookshelf into a wall bookshelf. + +================================================================== +License of source code and textures: WTFPL +------------------------------------------------------------------ +This program is free software. It comes without any warranty, to +the extent permitted by applicable law. You can redistribute it +and/or modify it under the terms of the do whatever you want with it. +To Public License, Version 2, as published by Sam Hocevar. See +http://sam.zoy.org/wtfpl/COPYING for more details. +================================================================== \ No newline at end of file diff --git a/abm.lua b/abm.lua new file mode 100644 index 0000000..c4ff6f9 --- /dev/null +++ b/abm.lua @@ -0,0 +1,54 @@ +minetest.register_abm({ -- Controls the contained fires. + nodenames = {'ma_pops_furniture:fireplace', 'ma_pops_furniture:fireplace_on'}, + interval = 1.0, + chance = 1, + action = function(pos, node, active_object_count, active_object_count_wider) + local meta = minetest.env:get_meta(pos) + for i, name in ipairs({ + 'fuel_totaltime', + 'fuel_time', + }) do + if meta:get_string(name) == '' then + meta:set_float(name, 0.0) + end + end + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local was_active = false + if meta:get_float('fuel_time') < meta:get_float('fuel_totaltime') then + was_active = true + meta:set_float('fuel_time', meta:get_float('fuel_time') + 0.25) + end + if meta:get_float('fuel_time') < meta:get_float('fuel_totaltime') then + minetest.sound_play({name='fire_small'},{gain=0.07}, + {loop=true}) + local percent = math.floor(meta:get_float('fuel_time') / + meta:get_float('fuel_totaltime') * 100) + meta:set_string('infotext','Fireplace active: '..percent..'%') + minetest.swap_node(pos, {name = 'ma_pops_furniture:fireplace_on', param2 = node.param2}) + meta:set_string('formspec', ma_pops_furniture.fireplace_formspec) + return + end + local fuel = nil + local fuellist = inv:get_list('fuel') + if fuellist then + fuel = minetest.get_craft_result({method = 'fuel', width = 1, items = fuellist}) + end + if fuel.time <= 0 then + local node = minetest.get_node(pos) + if node.name == 'ma_pops_furniture:fireplace_on' then + meta:set_string('infotext','Put more wood in the fireplace!') + minetest.swap_node(pos, {name = 'ma_pops_furniture:fireplace', param2 = node.param2}) + meta:set_string('formspec', ma_pops_furniture.fireplace_formspec) + local timer = minetest.get_node_timer(pos) + timer:start(190) + end + return + end + meta:set_string('fuel_totaltime', fuel.time) + meta:set_string('fuel_time', 0) + local stack = inv:get_stack('fuel', 1) + stack:take_item() + inv:set_stack('fuel', 1, stack) +end, +}) diff --git a/crafts.lua b/crafts.lua new file mode 100644 index 0000000..7cde3d2 --- /dev/null +++ b/crafts.lua @@ -0,0 +1,846 @@ +minetest.register_craft({ + output = 'ma_pops_furniture:smoke_detector', + recipe = { + {'default:stone','dye:white','default:stone',}, + {'default:stone','default:copper_ingot','default:stone',}, + {'default:stone','dye:red','default:stone',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:ceiling_lamp', + recipe = { + {'default:stone', 'default:stone', 'default:stone'}, + {'default:stone', 'default:meselamp', 'default:stone'}, + {'default:stone', 'default:meselamp', 'default:stone'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:outdoor_lamp', + recipe = { + {'','','',}, + {'default:stone','default:stone','default:stone',}, + {'default:stone','default:meselamp','default:stone',}, + } +}) +--changed bathroom_faucet to bath_faucet and added craft +minetest.register_craft({ + output = 'ma_pops_furniture:bath_faucet', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','','bucket:bucket_water',}, + {'default:steel_ingot','','',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:toilet_paper_roll_dispenser', + recipe = { + {'default:stone','default:stone','default:stone',}, + {'default:paper','default:water','default:paper',}, + {'','default:paper','',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:toilet_close', + recipe = { + {'','','default:steel_ingot',}, + {'default:steel_ingot','stairs:slab_wood','default:steel_ingot',}, + {'default:steel_ingot','bucket:bucket_water','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:br_sink', + recipe = { + {'default:steel_ingot','','default:steel_ingot',}, + {'','default:steel_ingot','',}, + {'','default:steel_ingot','',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:mirror_closed', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:glass','default:glass','default:glass',}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:shower_base', + recipe = { + {'','','',}, + {'','','',}, + {'default:steel_ingot','bucket:bucket_empty','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:shower_top', + recipe = { + {'','default:steel_ingot','',}, + {'default:steel_ingot','bucket:bucket_water','default:steel_ingot',}, + {'default:steel_ingot','','default:steel_ingot',}, + } +}) + +local night_table = { --name, material, invimg +{'wood'}, +{'aspen_wood'}, +{'junglewood'}, +{'acacia_wood'}, +{'pine_wood'}, +{'cobble'} +} + +for i in ipairs (night_table) do + local material = night_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:nightstand_'..material, + recipe = { + {'default:'..material, 'default:'..material, 'default:'..material}, + {'default:'..material, 'default:chest', 'default:'..material}, + {'default:'..material, 'default:'..material, 'default:'..material} + } +}) +end + +local chair = { --name, material, invimg +{'wood'}, +{'aspen_wood'}, +{'junglewood'}, +{'acacia_wood'}, +{'pine_wood'}, +{'cobble'} +} + +for i in ipairs (chair) do + local material = chair[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:chair_'..material, + recipe = { + {'default:'..material, '', ''}, + {'default:'..material, 'default:'..material, 'default:'..material}, + {'default:'..material, '', 'default:'..material} + } +}) +end +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:dw', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','bucket:bucket_water','default:steel_ingot',}, + {'default:steel_ingot','default:mese_crystal','default:steel_ingot',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:oven', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','default:furnace','default:steel_ingot',}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:oven_overhead', + recipe = { + {'default:steel_ingot','default:mese_crystal_fragment','default:steel_ingot',}, + {'','','',}, + {'','','',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:microwave', + recipe = { + {'','','',}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','default:furnace','default:steel_ingot',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:coffee_maker', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','default:copper_ingot','default:steel_ingot',}, + {'','default:glass','',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:toaster', + recipe = { + {'','','',}, + {'default:steel_ingot','default:mese_crystal','default:steel_ingot',}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:sink', + recipe = { + {'default:steel_ingot','bucket:bucket_water','default:steel_ingot',}, + {'','default:steel_ingot','',}, + {'','default:steel_ingot','',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:kitchen_faucet', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','','default:steel_ingot',}, + {'default:steel_ingot','','',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:cutting_board', + recipe = { + {'','','',}, + {'','','',}, + {'default:wood','default:wood','default:wood',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:counter', + recipe = { + {'group:wood','group:wood','group:wood',}, + {'group:wood','','group:wood',}, + {'group:wood','group:wood','group:wood',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:counter1', + recipe = { + {'group:wood','group:wood','group:wood',}, + {'group:wood','group:wood','group:wood',}, + {'group:wood','group:wood','group:wood',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:upcabinet', + recipe = { + {'group:wood','group:wood','group:wood',}, + {'group:wood','default:chest','group:wood',}, + {'group:wood','group:wood','group:wood',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:upcabinet_corner', + recipe = { + {'group:wood','group:wood','group:wood',}, + {'group:wood','group:wood','default:chest',}, + {'group:wood','','',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:fridge', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','default:snow','default:steel_ingot',}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:freezer', + recipe = { + {'default:steel_ingot','default:mese_crystal','default:steel_ingot',}, + {'default:steel_ingot','default:ice','default:steel_ingot',}, + {'default:steel_ingot','default:mese_crystal','default:steel_ingot',}, + } +}) + +local chair2_table = { --color +{'black'}, +{'blue'}, +{'brown'}, +{'cyan'}, +{'dark_green'}, +{'dark_grey'}, +{'green'}, +{'grey'}, +{'magenta'}, +{'orange'}, +{'pink'}, +{'red'}, +{'violet'}, +{'yellow'}, +} + +for i in ipairs (chair2_table) do + local color = chair2_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_'..color, + recipe = { + {'wool:'..color, 'wool:'..color, 'wool:'..color, }, + {'wool:'..color, 'wool:'..color, 'wool:'..color, }, + {'group:wood', '', 'group:wood', }, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_'..color, + recipe = { + {'ma_pops_furniture:chair2_white', 'dye:'..color} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_white', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:white'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_black', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:black'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_blue', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:blue'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_brown', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:brown'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_cyan', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:cyan'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_dark_grey', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:dark_grey'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_grey', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:grey'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_green', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:green'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_magenta', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:magenta'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_orange', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:orange'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_pink', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:pink'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_red', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:red'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_violet', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:violet'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_yellow', + recipe = { + {'ma_pops_furniture:chair2_'..color, 'dye:yellow'} + } +}) +end + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_white', + recipe = { + {'wool:white', 'wool:white', 'wool:white', }, + {'wool:white', 'wool:white', 'wool:white', }, + {'group:wood', '', 'group:wood', }, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:chair2_rainbow', + recipe = { + {'wool:black', '', '', }, + {'wool:blue', 'wool:yellow', 'wool:pink', }, + {'default: acacia_tree', '', 'default: acacia_tree', }, + } +}) + +local sofa_table = { --color +{'black'}, +{'blue'}, +{'brown'}, +{'cyan'}, +{'dark_green'}, +{'dark_grey'}, +{'green'}, +{'grey'}, +{'magenta'}, +{'orange'}, +{'pink'}, +{'red'}, +{'violet'}, +{'white'}, +{'yellow'}, +} + +for i in ipairs (sofa_table) do + local color = sofa_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:sofa_'..color, + recipe = { + {'', '', '', }, + {'wool:'..color, 'wool:'..color, 'wool:'..color, }, + {'wool:'..color, 'wool:'..color, 'wool:'..color, }, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:sofa_'..color, + recipe = { + {'ma_pops_furniture:sofa_white', 'dye:'..color} + } +}) +end + +local fs_table = { --color +{'black'}, +{'blue'}, +{'brown'}, +{'cyan'}, +{'dark_green'}, +{'dark_grey'}, +{'green'}, +{'grey'}, +{'magenta'}, +{'orange'}, +{'pink'}, +{'red'}, +{'violet'}, +{'yellow'}, +} + +for i in ipairs (fs_table) do + local color = fs_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_'..color, + recipe = { + {'wool:'..color, 'wool:'..color, 'wool:'..color, }, + {'group:wood', '', 'group:wood', }, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_'..color, + recipe = { + {'ma_pops_furniture:fs_white', 'dye:'..color} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_white', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:white'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:'..color} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_black', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:black'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_blue', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:blue'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_brown', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:brown'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_cyan', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:cyan'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_dark_grey', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:dark_grey'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_grey', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:grey'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_green', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:green'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_magenta', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:magenta'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_orange', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:orange'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_pink', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:pink'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_red', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:red'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_violet', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:violet'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_yellow', + recipe = { + {'ma_pops_furniture:fs_'..color, 'dye:yellow'} + } +}) +end + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_white', + recipe = { + {'wool:white', 'wool:white', 'wool:white', }, + {'group:wood', '', 'group:wood', }, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fs_rainbow', + recipe = { + {'', '', '', }, + {'wool:blue', 'wool:yellow', 'wool:pink', }, + {'default: acacia_tree', '', 'default: acacia_tree', }, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:vcr_off', + recipe = { + {'','','',}, + {'default:coalblock','default:coalblock','default:coalblock',}, + {'default:coalblock','default:mese_crystal','default:coalblock',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:entertainment_unit', + recipe = { + {'default:wood','default:wood','default:wood',}, + {'default:wood','default:chest','default:wood',}, + {'default:wood','default:wood','default:wood',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:fireplace', + recipe = { + {'default:brick', 'default:brick', 'default:brick'}, + {'default:brick', 'default:furnace', 'default:brick'}, + {'default:brick', 'default:brick', 'default:brick'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:lamp_off', + recipe = { + {'wool:white','wool:white', 'wool:white'}, + {'wool:white', 'default:torch', 'wool:white'}, + {'wool:red', 'wool:red', 'wool:red'} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:curtains', + recipe = { + {'default:acacia_tree','default:acacia_tree', 'default:acacia_tree'}, + {'wool:red', '', 'wool:red'}, + {'wool:red', '', 'wool:red'} + } +}) + +minetest.register_craft({ + type = "shapeless", + output = 'ma_pops_furniture:curtains_2_tall', + recipe = + {'ma_pops_furniture:curtains', 'ma_pops_furniture:curtains'} +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:blinds', + recipe = { + {'default:stick', 'default:stick', 'default:stick'}, + {'default:stick', 'dye:white', 'default:stick'}, + {'default:stick', 'default:stick', 'default:stick'} + } +}) + +minetest.register_craft({ + output = "ma_pops_furniture:stereo", + recipe = { + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot", }, + {"default:steel_ingot", "default:chest", "default:steel_ingot", }, + {"default:stick", "", "default:stick", } + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:tv_off', + recipe = { + {'default:tree', 'default:tree', 'default:tree'}, + {'default:tree', 'wool:black', 'default:tree'}, + {'default:tree', 'default:tree', 'default:tree'} + } +}) + +local c_table = { --name, material, invimg +{'wood'}, +{'aspen_wood'}, +{'junglewood'}, +{'acacia_wood'}, +{'pine_wood'}, +{'cobble'} +} + +for i in ipairs (c_table) do + local material = c_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:c_'..material, + recipe = { + {'', '', ''}, + {'default:'..material, 'default:'..material, 'default:'..material}, + {'default:'..material, '', 'default:'..material} + } +}) +end + +local end_table = { --name, material, invimg +{'wood'}, +{'aspen_wood'}, +{'junglewood'}, +{'acacia_wood'}, +{'pine_wood'}, +{'cobble'} +} + +for i in ipairs (end_table) do + local material = end_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:end_table_'..material, + recipe = { + {'default:'..material, 'default:'..material, 'default:'..material}, + {'default:'..material, '', 'default:'..material}, + {'default:'..material, '', 'default:'..material} + } +}) +end + +minetest.register_craft({ + output = 'ma_pops_furniture:computer', + recipe = { + {'default:stone','default:stone','default:stone',}, + {'default:stone','default:mese_crystal','default:stone',}, + {'default:stone','default:copper_lump','default:stone',}, + } +}) + +local table = { --name, material, invimg +{'wood'}, +{'aspen_wood'}, +{'junglewood'}, +{'acacia_wood'}, +{'pine_wood'}, +{'cobble'} +} + +for i in ipairs (table) do + local material = table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:table_'..material, + recipe = { + {'default:'..material, 'default:'..material, 'default:'..material}, + {'', 'default:'..material, ''}, + {'', 'default:'..material, ''} + } +}) +end + +local hedge_table = { --name, material, invimg +{'leaves'}, +{'pine_needles'}, +{'jungleleaves'}, +{'acacia_leaves'}, +{'aspen_leaves'} +} + +for i in ipairs (hedge_table) do + local material = hedge_table[i][1] + +minetest.register_craft({ + output = 'ma_pops_furniture:hedge_'..material, + recipe = { + {'', '', ''}, + {'default:'..material, 'default:'..material, 'default:'..material}, + {'default:'..material, 'default:'..material, 'default:'..material} + } +}) +end +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:birdbath', + recipe = { + {'','','',}, + {'default:steel_ingot','bucket:bucket_water','default:steel_ingot',}, + {'','default:steel_ingot','',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:doorbell 4', + recipe = { + {'','default:stone','',}, + {'','default:mese_crystal','',}, + {'','','',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:grill', + recipe = { + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','default:steel_ingot','default:steel_ingot',}, + {'default:steel_ingot','','default:steel_ingot',}, + } +}) +--added craft +minetest.register_craft({ + output = 'ma_pops_furniture:stone_path_1 5', + recipe = { + {'default:stone','','default:stone',}, + {'','','',}, + {'default:stone','','default:stone',}, + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:hammer', + recipe = { + {'','default:steel_ingot', ''}, + {'', 'default:stick', 'default:steel_ingot'}, + {'default:stick', '', ''} + } +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:shears', + recipe = { + {'','default:steel_ingot', ''}, + {'default:stick', '', 'default:steel_ingot'}, + {'', 'default:stick', ''} + } +}) diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..f9d97e9 --- /dev/null +++ b/depends.txt @@ -0,0 +1,6 @@ +default +fire +ethereal? +mobs_mc? +farming? +unifieddyes? \ No newline at end of file diff --git a/formspecs.lua b/formspecs.lua new file mode 100644 index 0000000..6f9507e --- /dev/null +++ b/formspecs.lua @@ -0,0 +1,9 @@ +ma_pops_furniture.fireplace_formspec = + 'size[8,6]'.. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + 'background[8,6;0,0;default_brick.png;true]'.. + 'list[current_name;fuel;1,0;1,1;]'.. + 'list[current_player;main;0,2.5;8,4;]' + default.get_hotbar_bg(0,4.85) \ No newline at end of file diff --git a/freezer.lua b/freezer.lua new file mode 100644 index 0000000..dc3d30c --- /dev/null +++ b/freezer.lua @@ -0,0 +1,227 @@ +-- +-- Freezer for mintest: a device which turns water (in buckets) into ice +-- And does a couple of other tricks, discovering which is left as a pleasant +-- surprise for the player. +-- + +-- enable extra popsicle types provided there are both vessels and fruits/veggies available +-- fruit + glass -> juice; juice @ freezer -> popsicle + empty glass + +-- +-- Formspecs +-- + +local function active_formspec(fuel_percent, item_percent) + local formspec = + "size[8,8.5]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "list[current_name;src;2.5,1;1,1;]".. + "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:".. + (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]".. + "list[current_name;dst;4.75,0.96;3,2;]".. + "list[current_player;main;0,4.25;8,1;]".. + "list[current_player;main;0,5.5;8,3;8]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4.25) + return formspec +end + +local inactive_formspec = + "size[8,8.5]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "list[current_name;src;2.5,1.5;1,1;]".. + "image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]".. + "list[current_name;dst;4.75,0.96;3,2;]".. + "list[current_player;main;0,4.25;8,1;]".. + "list[current_player;main;0,5.5;8,3;8]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]".. + default.get_hotbar_bg(0, 4.25) + +-- +-- Node callback functions that are the same for active and inactive freezer +-- + +local function can_dig(pos, player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("dst") and inv:is_empty("src") +end + + +local function allow_metadata_inventory_put(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if listname == "src" then + return stack:get_count() + elseif listname == "dst" then + return 0 + end +end + + +local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack(from_list, from_index) + return allow_metadata_inventory_put(pos, to_list, to_index, stack, player) +end + + +local function allow_metadata_inventory_take(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + return stack:get_count() +end + + +local function swap_node(pos, name) + local node = minetest.get_node(pos) + if node.name == name then + return + end + node.name = name + minetest.swap_node(pos, node) +end + + +local function freezer_node_timer(pos, elapsed) + -- + -- Inizialize metadata + -- + local meta = minetest.get_meta(pos) + + local src_time = meta:get_float("src_time") or 0 + + + local inv = meta:get_inventory() + local srclist = inv:get_list("src") + + local dstlist = inv:get_list("dst") + + -- + -- Cooking + -- + + -- takes both regular and river water + if inv:contains_item("src", "bucket:bucket_water") or + inv:contains_item("src", "bucket:bucket_river_water") then + if inv:room_for_item("dst", "default:ice") then + inv:remove_item("src", "bucket:bucket_water") + inv:remove_item("src", "bucket:bucket_river_water") + inv:add_item("dst", "default:ice") + inv:add_item("dst", "bucket:bucket_empty") + end + end + + -- Check if we have cookable content + return +end + + +-- +-- Node definitions +-- + +minetest.register_node("ma_pops_furniture:freezer", { + description = "Freezer", + tiles = { + "mp_froz_top.png", + "mp_froz_bottom.png", + "mp_froz_right.png", + "mp_froz_left.png", + "mp_froz_back.png", + "mp_froz_front.png" + }, + paramtype2 = "facedir", + groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1}, + legacy_facedir_simple = true, + is_ground_content = false, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5}, -- NodeBox1 + {-0.5, -0.4375, -0.375, 0.4375, 0.5, -0.3125}, -- NodeBox2 + {0.3125, -0.25, -0.5, 0.375, 0.25, -0.4375}, -- NodeBox6 + {0.3125, -0.25, -0.4375, 0.375, -0.1875, -0.375}, -- NodeBox7 + {0.3125, 0.1875, -0.4375, 0.375, 0.25, -0.375}, -- NodeBox8 + } + }, + tube = (function() if minetest.get_modpath("pipeworks") then return { + -- using a different stack from defaut when inserting + insert_object = function(pos, node, stack, direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local timer = minetest.get_node_timer(pos) + if not timer:is_started() then + timer:start(1.0) + end + return inv:add_item("src", stack) + end, + can_insert = function(pos,node,stack,direction) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:room_for_item("src", stack) + end, + -- the default stack, from which objects will be taken + input_inventory = "dst", + connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1} + } end end)(), + + can_dig = can_dig, + + on_timer = freezer_node_timer, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", inactive_formspec) + local inv = meta:get_inventory() + inv:set_size('src', 1) + inv:set_size('dst', 6) + end, + + on_metadata_inventory_move = function(pos) + local timer = minetest.get_node_timer(pos) + timer:start(1.0) + end, + on_metadata_inventory_put = function(pos) + -- start timer function, it will sort out whether freezer will work or not. + local timer = minetest.get_node_timer(pos) + timer:start(1.0) + end, + on_blast = function(pos) + local drops = {} + default.get_inventory_drops(pos, "src", drops) + default.get_inventory_drops(pos, "dst", drops) + drops[#drops+1] = "ma_pops_furniture:freezer" + minetest.remove_node(pos) + return drops + end, + + allow_metadata_inventory_put = allow_metadata_inventory_put, + allow_metadata_inventory_move = allow_metadata_inventory_move, + allow_metadata_inventory_take = allow_metadata_inventory_take, +}) + +minetest.register_craft({ + output = "default:snowblock 3", + type = "shapeless", + recipe = { + "default:ice" + } +}) \ No newline at end of file diff --git a/functions.lua b/functions.lua new file mode 100644 index 0000000..0a068fd --- /dev/null +++ b/functions.lua @@ -0,0 +1,58 @@ +function ma_pops_furniture.sit(pos, node, clicker) + local meta = minetest.get_meta(pos) + local param2 = node.param2 + local name = clicker:get_player_name() + + if name == meta:get_string("is_sit") then + print 'player should be standing.' + meta:set_string("is_sit", "") + pos.y = pos.y-0.5 + clicker:setpos(pos) + clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) + clicker:set_physics_override(1, 1, 1) + default.player_attached[name] = false + default.player_set_animation(clicker, "stand", 30) + else + meta:set_string("is_sit", clicker:get_player_name()) + print 'player should be sitting.' + clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0}) + clicker:set_physics_override(0, 0, 0) + clicker:setpos(pos) + default.player_attached[name] = true + default.player_set_animation(clicker, "sit", 30) + if param2 == 0 then + clicker:set_look_yaw(3.15) + elseif param2 == 1 then + clicker:set_look_yaw(7.9) + elseif param2 == 2 then + clicker:set_look_yaw(6.28) + elseif param2 == 3 then + clicker:set_look_yaw(4.75) + else return end + end +end + +ma_pops_furniture.window_operate = function( pos, old_node_state_name, new_node_state_name ) + + local offsets = {-1,1,-2,2,-3,3}; + local stop_up = 0; + local stop_down = 0; + + for i,v in ipairs(offsets) do + + local node = minetest.env:get_node_or_nil( {x=pos.x, y=(pos.y+v), z=pos.z } ); + if( node and node.name and node.name==old_node_state_name + and ( (v > 0 and stop_up == 0 ) + or (v < 0 and stop_down == 0 ))) then + + minetest.env:add_node({x=pos.x, y=(pos.y+v), z=pos.z }, {name = new_node_state_name, param2 = node.param2}) + + -- found a diffrent node - no need to search further up + elseif( v > 0 and stop_up == 0 ) then + stop_up = 1; + + elseif( v < 0 and stop_down == 0 ) then + stop_down = 1; + end + end +end diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..a8a9c88 --- /dev/null +++ b/init.lua @@ -0,0 +1,30 @@ +ma_pops_furniture = {} + +dofile(minetest.get_modpath('ma_pops_furniture')..'/sit.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/functions.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/formspecs.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/crafts.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/nodes.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/tools.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/freezer.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/microwave.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/oven.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/sofa.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/abm.lua') + + +--GreenDimond's code from waffle mod +local MP = minetest.get_modpath(minetest.get_current_modname()) +local S, NS = dofile(MP.."/intllib.lua") + +ma_pops_furniture.intllib = S +dofile(minetest.get_modpath('ma_pops_furniture')..'/toaster.lua') +dofile(minetest.get_modpath('ma_pops_furniture')..'/intllib.lua') + +minetest.register_alias("furniture_mod:toilet_closed", "ma_pops_furniture:toilet_closed") +minetest.register_alias("furniture_mod:toilet_open", "ma_pops_furniture:toilet_open") +minetest.register_alias("furniture_mod:tv", "ma_pops_furniture:tv") +minetest.register_alias("furniture_mod:lamp", "ma_pops_furniture:lamp") +minetest.register_alias("furniture_mod:lamp_off", "ma_pops_furniture:lamp_off") +minetest.register_alias("furniture_mod:ceiling_light", "ma_pops_furniture:ceiling_lamp") +minetest.register_alias("furniture_mod:ceiling_light_off", "ma_pops_furniture:ceiling_lamp_off") diff --git a/intllib.lua b/intllib.lua new file mode 100644 index 0000000..458cc8c --- /dev/null +++ b/intllib.lua @@ -0,0 +1,45 @@ + +-- Fallback functions for when `intllib` is not installed. +-- Code released under Unlicense . + +-- Get the latest version of this file at: +-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua + +local function format(str, ...) + local args = { ... } + local function repl(escape, open, num, close) + if escape == "" then + local replacement = tostring(args[tonumber(num)]) + if open == "" then + replacement = replacement..close + end + return replacement + else + return "@"..open..num..close + end + end + return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl)) +end + +local gettext, ngettext +if minetest.get_modpath("intllib") then + if intllib.make_gettext_pair then + -- New method using gettext. + gettext, ngettext = intllib.make_gettext_pair() + else + -- Old method using text files. + gettext = intllib.Getter() + end +end + +-- Fill in missing functions. + +gettext = gettext or function(msgid, ...) + return format(msgid, ...) +end + +ngettext = ngettext or function(msgid, msgid_plural, n, ...) + return format(n==1 and msgid or msgid_plural, ...) +end + +return gettext, ngettext \ No newline at end of file diff --git a/microwave.lua b/microwave.lua new file mode 100644 index 0000000..332b617 --- /dev/null +++ b/microwave.lua @@ -0,0 +1,166 @@ +--microwave code by Wizzerine +--item_percent code by Noodlemire + +local microwave_fs = + "size[8,7]" + .."button[6.5,1.5;1.5,2;btn_start;START]" + .."image[6.5,.2;1.5,.5;mp_mw_bar.png^[transformR270]" + .."list[current_player;main;0,3;8,1;]" + .."list[current_player;main;0,4.25;8,3;8]" + .."list[context;cook_slot;3.5,1.25;1,1;]" + .."label[3,0.5;Microwave]" + -- possibly add "fire" image? + +local function get_active_microwave_fs(item_percent) + return "size[8,7]" + .."button[6.5,1.5;1.5,2;button_start;START]" + .."image[6.5,.2;1.5,.5;mp_mw_bar.png^[lowpart:" + ..(item_percent)..":mp_mw_bar_on.png^[transformR270]" + .."list[current_player;main;0,3;8,1;]" + .."list[current_player;main;0,4.25;8,3;8]" + .."list[context;cook_slot;3.5,1.25;1,1;]" + .."label[3,0.5;Microwave]" + -- possibly add "fire" image? +end + +--x,y;w,h + +-- Adding recipe API so we don't end up hardcoding items +ma_pops_furniture.microwave = {} +local microwave = ma_pops_furniture.microwave +microwave.recipes = {} +function microwave.register_recipe(input, output) microwave.recipes[input] = output end + +local function update_formspec(progress, goal, meta) + local formspec + + if progress > 0 and progress <= goal then + local item_percent = math.floor(progress / goal * 100) + formspec = get_active_microwave_fs(item_percent) + else + formspec = microwave_fs + end + + meta:set_string("formspec", formspec) +end + +local function recalculate(pos) + local meta, timer = minetest.get_meta(pos), minetest.get_node_timer(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack("cook_slot", 1) + local goal = 3 * stack:get_count() + + local k = microwave.recipes[stack:get_name()] + if not k then return end + + timer:stop() + update_formspec(0, goal, meta) + timer:start(1) +end + +local function do_cook_all(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local stack = meta:get_inventory():get_stack("cook_slot", 1) + local food_uncooked = inv:remove_item("cook_slot", inv:get_stack("cook_slot", 1)) -- Clear the slot + local food_cooked = microwave.recipes[food_uncooked:get_name()] .. " " .. tostring(food_uncooked:get_count()) -- Get the cooked food + inv:add_item("cook_slot", food_cooked) -- Put the cooked food in the slot +end + +minetest.register_node("ma_pops_furniture:microwave", { + description = "Microwave", + tiles = {"mp_mw_top.png", "mp_mw_bottom.png", "mp_mw_right.png", "mp_mw_left.png", "mp_mw_back.png", "mp_mw_front.png"}, + paramtype2 = "facedir", + groups = {cracky = 2}, -- currently no pipeworks compat as I don't know how it works + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.4375, -0.3125, 0.4375, 0.0625, 0.3125}, + {-0.375, -0.5, -0.25, 0.375, -0.4375, 0.25}, + }, + }, + can_dig = function(pos, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:is_empty("cook_slot") + end, + + on_timer = function(pos, elapsed) + local meta = minetest.get_meta(pos) + local stack = meta:get_inventory():get_stack("cook_slot", 1) + local goal = 3 * stack:get_count() + local cooking_time = meta:get_int("cooking_time") or 0 + cooking_time = cooking_time + 1 + + update_formspec(cooking_time, goal, meta) + meta:set_int("cooking_time", cooking_time) + + --Keep cooking until there is nothing left to cook. + if cooking_time <= goal then + return true + else + do_cook_all(pos) + meta:set_int("cooking_time", 0) + update_formspec(0, goal, meta) + return false + end + end, + + --on_metadata_inventory_put = recalculate, + --on_metadata_inventory_take = recalculate, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", microwave_fs) + local inv = meta:get_inventory() + inv:set_size("cook_slot", 1) + end, + on_receive_fields = function(pos, _, fields) + if fields.quit then return end + if fields.btn_start then + recalculate(pos) + end + end, + + on_blast = function(pos) + local drops = {} + default.get_inventory_drops(pos, "cook_slot", drops) + table.insert(drops, "ma_pops_furniture:microwave") + minetest.remove_node(pos) + return drops + end, + + allow_metadata_inventory_put = function(pos, list, index, stack, player) + return microwave.recipes[stack:get_name()] and stack:get_count() or 0 + end, + + --Only allow items to be taken if the microwave hasn't started yet + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if not minetest.get_node_timer(pos):is_started() then + return stack:get_count() + else + return 0 + end + end +}) + +minetest.register_craft({ + output = "ma_pops_furniture:microwave", + recipe = { + {"default:steel_ingot", "default:mese_crystal", "default:steel_ingot"}, + {"default:steel_ingot", "", "default:steel_ingot"}, + {"default:steel_ingot", "default:mese_crystal", "default:steel_ingot"} + } +}) + +-- Recipe Registration +microwave.register_recipe("default:ice", "default:water_source") +-- No milk bucket as this doesn't support substitutes for now +microwave.register_recipe("mobs_mc:chicken_raw", "test:chicken_cooked") +--[[ We don't need to check mod existance when registering recipe +Recipe won't even be executed if there is no raw chicken in input ]]-- +microwave.register_recipe("mobs_mc:beef_raw", "test:beef_cooked") +microwave.register_recipe("farming:coffee_cup", "farming:coffee_cup_hot") -- What a crutch there was... +-- Add needed recipes as you go, note that other mods can add more recipes too diff --git a/nodes.lua b/nodes.lua new file mode 100644 index 0000000..2666e26 --- /dev/null +++ b/nodes.lua @@ -0,0 +1,2326 @@ +--Overall-- +minetest.register_node("ma_pops_furniture:smoke_detector", { + description = "Smoke Detector", + tiles = { + "mp_t.png", + "mp_b.png", + "mp_si.png", + "mp_si.png", + "mp_si.png", + "mp_si.png" + }, + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + on_timer = function(pos,elapsed) + if minetest.find_node_near(pos, 20, {"fire:basic_flame"}, false) then + local node = minetest.get_node(pos) + node.name = "ma_pops_furniture:smoke_detector_on" + minetest.remove_node(pos) + minetest.add_node(pos, node) + minetest.get_node_timer(pos):start(0.0) + else + -- Update every 10 seconds. + minetest.get_node_timer(pos):start(10.0) + end + end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_node_timer(pos):start(0.0) + end, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.375, 0.375, -0.375, 0.375, 0.5, 0.375}, -- NodeBox1 + {-0.3125, 0.3125, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox2 + } + } +}) + +minetest.register_node("ma_pops_furniture:smoke_detector_on", { + description = "Smoke Detector", + tiles = { + "mp_t.png", + "mp_b.png", + "mp_si.png", + "mp_si.png", + "mp_si.png", + "mp_si.png" + }, + on_destruct = function(pos) + local meta = minetest.get_meta(pos) + if meta then + local tmp = meta:to_table() + if tmp then + if tmp.fields.sound_handle then + minetest.sound_stop(tmp.fields.sound_handle) + tmp.fields.sound_handle = nil + meta:from_table(tmp) + end + end + end + end, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + local meta = minetest.get_meta(pos) + if meta then + local tmp = meta:to_table() + if tmp then + if tmp.fields.sound_handle then + minetest.sound_stop(tmp.fields.sound_handle) + tmp.fields.sound_handle = nil + minetest.get_node_timer(pos):start(3.0) + meta:from_table(tmp) + end + end + end + end, + drop = 'ma_pops_furniture:smoke_detector', + groups = {cracky = 3, oddly_breakable_by_hand = 3}, + on_timer = function(pos,elapsed) + if minetest.find_node_near(pos, 20, {"fire:basic_flame"}, false) then + -- Play sound. + local meta = minetest.get_meta(pos) + if meta then + local tmp = meta:to_table() + if tmp then + if not tmp.fields.sound_handle then + local handle = minetest.sound_play("mp_smoke_detector", {pos = pos, gain = 2.1,max_hear_distance = 96,loop = true}) + tmp.fields.sound_handle = handle + end + end + meta:from_table(tmp) + end + -- Update every 1.0 second. + minetest.get_node_timer(pos):start(1.0) + else + local meta = minetest.get_meta(pos) + if meta then + local tmp = meta:to_table() + if tmp then + minetest.sound_stop(tmp.fields.sound_handle) + if tmp.fields.sound_handle then + tmp.fields.sound_handle = nil + meta:from_table(tmp) + end + end + end + local node = minetest.get_node(pos) + node.name = "ma_pops_furniture:smoke_detector" + minetest.remove_node(pos) + minetest.add_node(pos, node) + minetest.get_node_timer(pos):start(0.0) + end + end, + drawtype = "nodebox", + paramtype = "light", + light_source = default.LIGHT_MAX - 1, + node_box = { + type = "fixed", + fixed = { + {-0.375, 0.375, -0.375, 0.375, 0.5, 0.375}, -- NodeBox1 + {-0.3125, 0.3125, -0.3125, 0.3125, 0.375, 0.3125}, -- NodeBox2 + } + } +}) + +minetest.register_lbm({ + label = "Replace all smoke detector's that are turned on.", + name = "ma_pops_furniture:replace_smoke_detector_on", + nodenames = {"ma_pops_furniture:smoke_detector_on"}, + run_at_every_load = true, + action = function(pos, node) + node.name = "ma_pops_furniture:smoke_detector" + minetest.remove_node(pos) + minetest.add_node(pos, node) + minetest.get_node_timer(pos):start(0.0) + end +}) + +minetest.register_node('ma_pops_furniture:trash_can', { + description = 'Trash Can', + drawtype = 'nodebox', + tiles = {'default_steel_block.png'}, + groups = {cracky=2, oddly_breakably_by_hand=2, furniture=1}, + --inventory_image = 'fm_chair_stone.png', + paramtype = 'light', + paramtype2 = 'facedir', + node_box = { + type = "fixed", + fixed = { + {-0.375, -0.5, -0.375, 0.375, 0.375, 0.375}, -- NodeBox1 + {-0.4375, 0.375, -0.4375, 0.4375, 0.4375, 0.4375}, -- NodeBox2 + {-0.125, 0.4375, -0.3125, 0.125, 0.5, 0.3125}, -- NodeBox3 + } + }, + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", + "size[8,9]" .. + "button[0,0;2,1;empty;Empty Trash]" .. + "list[context;trashlist;3,1;2,3;]" .. + "list[current_player;main;0,5;8,4;]" + ) + meta:set_string("infotext", "Trash Can") + local inv = meta:get_inventory() + inv:set_size("main", 8*4) + inv:set_size("trashlist", 2*3) + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty("main") + end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + minetest.log("action", player:get_player_name() .. + " moves stuff in trash can at " .. minetest.pos_to_string(pos)) + end, + on_metadata_inventory_put = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name() .. + " moves stuff to trash can at " .. minetest.pos_to_string(pos)) + end, + on_metadata_inventory_take = function(pos, listname, index, stack, player) + minetest.log("action", player:get_player_name() .. + " takes stuff from trash can at " .. minetest.pos_to_string(pos)) + end, + on_receive_fields = function(pos, formname, fields, sender) + if fields.empty then + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_list("trashlist", {}) + minetest.sound_play("trash", {to_player=sender:get_player_name(), gain = 1.0}) + minetest.log("action", sender:get_player_name() .. + " empties trash can at " .. minetest.pos_to_string(pos)) + end + end +}) + +minetest.register_node("ma_pops_furniture:ceiling_lamp", { + description = "Ceiling Lamp", + tiles = { + "default_stone.png", + "default_stone.png^mp_light_off.png", + "default_stone.png", + "default_stone.png", + "default_stone.png", + "default_stone.png" +}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:ceiling_lamp_on" + minetest.set_node(pos, node) + end, + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.050, 0.5, -0.050, 0.050, -0.2, 0.050}, + {-0.1, -0.0, -0.1, 0.1, -0.2, 0.1}, + {-0.2, -0.1, -0.2, 0.2, -0.2, 0.2}, + {-0.3, -0.2, -0.3, 0.3, -0.5, 0.3}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:ceiling_lamp_on", { + description = "Ceiling Lamp On", + tiles = { + "default_stone.png", + "default_stone.png^mp_light_on.png", + "default_stone.png", + "default_stone.png", + "default_stone.png", + "default_stone.png" +}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + light_source = 14, + drop = 'ma_pops_furniture:ceiling_lamp', + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:ceiling_lamp" +minetest.set_node(pos, node) +end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.050, 0.5, -0.050, 0.050, -0.2, 0.050}, + {-0.1, -0.0, -0.1, 0.1, -0.2, 0.1}, + {-0.2, -0.1, -0.2, 0.2, -0.2, 0.2}, + {-0.3, -0.2, -0.3, 0.3, -0.5, 0.3}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:light", { + description = "Ceiling Light", + tiles = { + "default_coral_skeleton.png", + "mp_ceiling_light_bottom.png", + "mp_ceiling_light_side.png", + "mp_ceiling_light_side.png", + "mp_ceiling_light_side.png", + "mp_ceiling_light_side.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:light_on" + minetest.set_node(pos, node) + end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.25, 0.4375, -0.25, 0.25, 0.5, 0.25}, -- NodeBox1 + {-0.125, 0.3125, -0.125, 0.125, 0.4375, 0.125}, -- NodeBox2 + {-0.1875, -0.0625, -0.1875, 0.1875, 0.3125, 0.1875}, -- NodeBox3 + }, + } +}) + +minetest.register_node("ma_pops_furniture:light_on", { + description = "Ceiling Light", + tiles = { + "default_coral_skeleton.png", + "mp_ceiling_light_bottom.png", + "mp_ceiling_light_side.png", + "mp_ceiling_light_side.png", + "mp_ceiling_light_side.png", + "mp_ceiling_light_side.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + drop = "ma_pops_furniture:light", + light_source = 14, + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:light" + minetest.set_node(pos, node) + end, + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.25, 0.4375, -0.25, 0.25, 0.5, 0.25}, -- NodeBox1 + {-0.125, 0.3125, -0.125, 0.125, 0.4375, 0.125}, -- NodeBox2 + {-0.1875, -0.0625, -0.1875, 0.1875, 0.3125, 0.1875}, -- NodeBox3 + }, + } +}) + +minetest.register_node("ma_pops_furniture:outdoor_lamp", { + description = "Outdoor Lamp", + tiles = { + "default_stone.png", + "default_stone.png^mp_light_off.png", + "default_stone.png", + "default_stone.png", + "default_stone.png", + "default_stone.png" +}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:outdoor_lamp_on" + minetest.set_node(pos, node) + end, + groups = {choppy = 2, oddly_breakable_by_hand = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.125, 0.25, -0.125, 0.125, 0.5, 0.125}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:outdoor_lamp_on", { + description = "Outdoor Lamp On", + tiles = { + "default_stone.png", + "default_stone.png^mp_light_on.png", + "default_stone.png", + "default_stone.png", + "default_stone.png", + "default_stone.png" +}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + light_source = 14, + drop = 'ma_pops_furniture:outdoor_lamp', + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:outdoor_lamp" +minetest.set_node(pos, node) +end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.125, 0.25, -0.125, 0.125, 0.5, 0.125}, + }, + } +}) + +--Bathroom-- +minetest.register_node("ma_pops_furniture:bath_faucet", { + description = "Bathroom Faucet", + tiles = { + "mp_knob_top.png", + "mp_knob_bottom.png", + "mp_knob_right.png", + "mp_knob_left.png", + "mp_knob_back.png", + "mp_knob_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, 0.3125, 0.0625, -0.1875, 0.4375}, + {-0.0625, -0.1875, 0.125, 0.0625, -0.125, 0.4375}, + {0.125, -0.25, 0.25, 0.25, -0.0625, 0.4375}, + {-0.25, -0.25, 0.25, -0.125, -0.0625, 0.4375}, + {-0.0625, -0.25, 0.125, 0.0625, -0.125, 0.1875}, + {-0.125, -0.1875, 0.3125, 0.125, -0.125, 0.375}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:toilet_paper_roll_dispenser", { + description = "Toilet Paper Roll Dispenser", + tiles = { + "mp_tp_top.png", + "mp_tp_bottom.png", + "mp_tp_right.png", + "mp_tp_left.png", + "mp_tp_back.png", + "mp_tp_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.3125, -0.1875, 0.4375, 0.3125, 0.125, 0.5}, + {-0.1875, -0.125, 0.25, 0.1875, 0.0625, 0.4375}, + {-0.25, -0.0625, 0.3125, 0.25, 0, 0.5}, + }, + } +}) + +minetest.register_node('ma_pops_furniture:toilet_open', { + description = 'Toilet', + drawtype = 'mesh', + mesh = 'FM_toilet_open.obj', + tiles = {{name='default_clay.png'},{name='default_wood.png'}}, + groups = {choppy=2, oddly_breakably_by_hand=2, furniture=1, not_in_creative_inventory=1}, + --inventory_image = 'fm_chair_stone.png', + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = { + {-.35, -.5, -.35, .35, 0, .5}, -- Right, Bottom, Back, Left, Top, Front + {-.35, 0, .2, .35, .5, .5}, + } + }, + collision_box = { + fixed = { + {-.35, -.5, -.35, .35, 0, .5}, -- Right, Bottom, Back, Left, Top, Front + {-.35, 0, .2, .35, .5, .5}, + } + }, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, + on_punch = function (pos, node, puncher) + node.name = "ma_pops_furniture:toilet_close" + minetest.set_node(pos, node) + end, +}) + +minetest.register_node('ma_pops_furniture:toilet_close', { + description = 'Toilet', + drawtype = 'mesh', + mesh = 'FM_toilet_close.obj', + tiles = {{name='default_clay.png'},{name='default_wood.png'}}, + groups = {choppy=2, oddly_breakably_by_hand=2, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = { + {-.35, -.5, -.35, .35, 0, .5}, -- Right, Bottom, Back, Left, Top, Front + {-.35, 0, .2, .35, .5, .5}, + } + }, + collision_box = { + fixed = { + {-.35, -.5, -.35, .35, 0, .5}, -- Right, Bottom, Back, Left, Top, Front + {-.35, 0, .2, .35, .5, .5}, + } + }, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, + on_punch = function (pos, node, puncher) + node.name = "ma_pops_furniture:toilet_open" + minetest.set_node(pos, node) + end, +}) + +minetest.register_node("ma_pops_furniture:br_sink", { + description = "Sink (Bathroom)", + tiles = { + "mp_hw_top.png", + "mp_hw_bottom.png", + "mp_hw_right.png", + "mp_hw_left.png", + "mp_hw_back.png", + "mp_hw_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, 0.25, -0.3125, 0.4375, 0.5, 0.5}, + {-0.125, -0.5, 0.125, 0.125, 0.25, 0.4375}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:mirror_closed", { + description = "Mirror", + tiles = { + "mp_mirror_top.png", + "mp_mirror_bottom.png", + "mp_mirror_right.png", + "mp_mirror_left.png", + "default_wood.png", + "mp_mirror_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + on_rightclick = function(pos, node, puncher) + minetest.env:add_node(pos, {name = "ma_pops_furniture:mirror", param2 = node.param2}) + ma_pops_furniture.window_operate( pos, "ma_pops_furniture:mirror_closed", "ma_pops_furniture:mirror" ); + end, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.375, 0.3125, 0.4375, 0.5, 0.5}, + {0, -0.375, 0.25, 0.4375, 0.5, 0.3125}, + {-0.4375, -0.375, 0.25, 2.98023e-008, 0.5, 0.3125}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:mirror", { + description = "Mirror (Open)", + tiles = { + "mp_mirror_open_top.png", + "mp_mirror_open_bottom.png", + "mp_mirror_open_right.png", + "mp_mirror_open_left.png", + "mp_mirror_front.png", + "mp_mirror_open_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + drop = "ma_pops_furniture:mirror_closed", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_creative_inventory = 1}, + on_rightclick = function(pos, node, puncher) + minetest.env:add_node(pos, {name = "ma_pops_furniture:mirror_closed", param2 = node.param2}) + ma_pops_furniture.window_operate( pos, "ma_pops_furniture:mirror", "ma_pops_furniture:mirror_closed" ); + end, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 4*4) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.375, 0.3125, 0.4375, 0.5, 0.5}, + {0.4375, -0.375, -0.125, 0.5, 0.5, 0.3125}, + {-0.5, -0.375, -0.125, -0.4375, 0.5, 0.3125}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:shower_base", { + description = "Shower Base", + tiles = { + "mp_showbas_top.png", + "mp_showbas_top.png", + "mp_showbas_sides.png", + "mp_showbas_sides.png", + "mp_showbas_sides.png", + "mp_showbas_sides.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.5, -0.4375, 0.4375, -0.4375, 0.4375}, + {0.4375, -0.5, -0.5, 0.5, -0.3125, 0.5}, + {-0.5, -0.5, 0.4375, 0.5, -0.3125, 0.5}, + {-0.5, -0.5, -0.5, -0.4375, -0.3125, 0.5}, + {-0.5, -0.5, -0.5, 0.5, -0.3125, -0.4375}, + {-0.125, -0.5, 0.125, 0.125, -0.375, 0.375}, + } + }, +}) + +minetest.register_node("ma_pops_furniture:shower_top", { + description = "Shower Head", + tiles = { + "mp_shk_top.png", + "mp_shk_bottom.png", + "mp_shk_right.png", + "mp_shk_left.png", + "mp_shk_back.png", + "mp_shk_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.25, -0.5, 0.4375, 0.25, 0.5, 0.5}, + {-0.125, 0.3125, -0.1875, 0.125, 0.4375, 0.25}, + {-0.1875, -0.25, 0.375, -0.125, -0.1875, 0.4375}, + {0.125, -0.25, 0.375, 0.1875, -0.1875, 0.4375}, + {-0.1875, -0.25, 0.3125, -0.125, -0.0625, 0.375}, + {0.125, -0.25, 0.3125, 0.1875, -0.0625, 0.375}, + {-0.0625, 0.375, 0.25, 0.0625, 0.4375, 0.4375}, + }, + } +}) + +--Bedroom-- +local night_table = { --name, material, invimg +{'Wood Nightstand', 'wood'}, +{'Acacia Wood Nightstand', 'acacia_wood'}, +{'Aspen Wood Nightstand', 'aspen_wood'}, +{'Pine Wood Nightstand', 'pine_wood'}, +{'Jungle Wood Nightstand', 'junglewood'} +} + +for i in ipairs (night_table) do + local name = night_table[i][1] + local material = night_table[i][2] + local invimg = night_table[i][3] + +minetest.register_node('ma_pops_furniture:nightstand_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {choppy=2, oddly_breakably_by_hand=2, furniture=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.4375, 0.5, -0.4375, 0.5}, -- NodeBox1 + {-0.5, 0.4375, -0.4375, 0.5, 0.5, 0.5}, -- NodeBox2 + {-0.5, -0.4375, -0.375, 0.5, 0.4375, 0.5}, -- NodeBox3 + {-0.4375, 0.0625, -0.4375, 0.4375, 0.375, -0.375}, -- NodeBox4 + {-0.4375, -0.375, -0.4375, 0.4375, -0.0625, -0.375}, -- NodeBox5 + {-0.125, -0.3125, -0.5, 0.125, -0.125, -0.4375}, -- NodeBox6 + {-0.125, 0.125, -0.5, 0.125, 0.3125, -0.4375}, -- NodeBox7 + } + } +}) +end + +--Kitchen/Dining Room-- +local chair_table = { --name, material, invimg +{'Stone Chair', 'cobble', 'mp_chair_stone.png'}, +{'Wood Chair', 'wood', 'mp_chair_wood.png'}, +{'Acacia Wood Chair', 'acacia_wood', 'mp_chair_acacia_wood.png'}, +{'Aspen Wood Chair', 'aspen_wood', 'mp_chair_aspen_wood.png'}, +{'Pine Wood Chair', 'pine_wood', 'mp_chair_pine_wood.png'}, +{'Jungle Wood Chair', 'junglewood', 'mp_chair_junglewood.png'} +} + +for i in ipairs (chair_table) do + local name = chair_table[i][1] + local material = chair_table[i][2] + local invimg = chair_table[i][3] + +minetest.register_node('ma_pops_furniture:chair_'..material, { + description = name, + drawtype = 'mesh', + mesh = 'FM_chair.obj', + tiles = {'default_'..material..'.png'}, + groups = {choppy=2, oddly_breakably_by_hand=2, furniture=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, + selection_box = { + type = 'fixed', + fixed = { + {-.4, -.4, -.3, .4, 0, .5}, + {-.4, 0, .3, .4, .62, .4}, + } + }, + collision_box = { + type = 'fixed', + fixed = { + {-.4, -.4, -.3, .4, 0, .5}, + {-.4, 0, .3, .4, .62, .4}, + } + }, +}) +end + +local table_table = { --name, material, invimg +{'Stone Table', 'cobble', 'mp_table_stone.png'}, +{'Wood Table', 'wood', 'mp_table_wood.png'}, +{'Acacia Wood Table', 'acacia_wood', 'mp_table_wood_acacia.png'}, +{'Aspen Wood Table', 'aspen_wood', 'mp_table_wood_aspen.png'}, +{'Pine Wood Table', 'pine_wood', 'mp_table_wood_pine.png'}, +{'Jungle Wood Table', 'junglewood', 'mp_table_wood_jungle.png'} +} + +for i in ipairs (table_table) do + local name = table_table[i][1] + local material = table_table[i][2] + local invimg = table_table[i][3] + +minetest.register_node('ma_pops_furniture:table_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy = 2, oddly_breakable_by_hand = 2, furniture = 1, flammable = 1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.125, -0.5, -0.125, 0.125, 0.3125, 0.125}, -- NodeBox2 + {-0.5, 0.3125, -0.5, 0.5, 0.5, 0.5}, -- NodeBox3 + } + } +}) +end + +local table_c_table = { --name, material, invimg +{'Stone Corner Table', 'cobble', 'mp_table_stone.png'}, +{'Wood Corner Table', 'wood', 'mp_table_wood.png'}, +{'Acacia Corner Wood Table', 'acacia_wood', 'mp_table_wood_acacia.png'}, +{'Aspen Corner Wood Table', 'aspen_wood', 'mp_table_wood_aspen.png'}, +{'Pine Corner Wood Table', 'pine_wood', 'mp_table_wood_pine.png'}, +{'Jungle Corner Wood Table', 'junglewood', 'mp_table_wood_jungle.png'} +} + +for i in ipairs (table_c_table) do + local name = table_c_table[i][1] + local material = table_c_table[i][2] + local invimg = table_c_table[i][3] + +minetest.register_node('ma_pops_furniture:table_c_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy = 2, oddly_breakable_by_hand = 2, furniture = 1, flammable = 1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.3125, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1 + {-0.375, -0.5, -0.125, -0.125, 0.3125, 0.125}, -- NodeBox3 + } + } +}) +end + +local table_c2_table = { --name, material, invimg +{'Stone Corner (right) Table', 'cobble', 'mp_table_stone.png'}, +{'Wood Corner (right) Table', 'wood', 'mp_table_wood.png'}, +{'Acacia Corner(right) Wood Table', 'acacia_wood', 'mp_table_wood_acacia.png'}, +{'Aspen Corner (right) Wood Table', 'aspen_wood', 'mp_table_wood_aspen.png'}, +{'Pine Corner (right) Wood Table', 'pine_wood', 'mp_table_wood_pine.png'}, +{'Jungle Corner (right) Wood Table', 'junglewood', 'mp_table_wood_jungle.png'} +} + +for i in ipairs (table_c2_table) do + local name = table_c2_table[i][1] + local material = table_c2_table[i][2] + local invimg = table_c2_table[i][3] + +minetest.register_node('ma_pops_furniture:table_c2_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy = 2, oddly_breakable_by_hand = 2, furniture = 1, flammable = 1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.3125, -0.5, 0.5, 0.5, 0.5}, -- NodeBox1 + {0.125, -0.5, -0.125, 0.375, 0.3125, 0.125}, -- NodeBox3 + } + } +}) +end + +local table_center_table = { --name, material, invimg +{'Stone Center Table', 'cobble', 'mp_table_stone.png'}, +{'Wood Center Table', 'wood', 'mp_table_wood.png'}, +{'Acacia Center Wood Table', 'acacia_wood', 'mp_table_wood_acacia.png'}, +{'Aspen Center Wood Table', 'aspen_wood', 'mp_table_wood_aspen.png'}, +{'Pine Center Wood Table', 'pine_wood', 'mp_table_wood_pine.png'}, +{'Jungle Center Wood Table', 'junglewood', 'mp_table_wood_jungle.png'} +} + +for i in ipairs (table_center_table) do + local name = table_center_table[i][1] + local material = table_center_table[i][2] + local invimg = table_center_table[i][3] + +minetest.register_node('ma_pops_furniture:table_center_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy = 2, oddly_breakable_by_hand = 2, furniture = 1, flammable = 1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.3125, -0.5, 0.5, 0.5, 0.5}, + } + } +}) +end + +minetest.register_node("ma_pops_furniture:dw", { + description= "Dishwasher", + tiles = { + "mp_dw_top.png", + "mp_dw_bottom.png", + "mp_dw_left.png", + "mp_dw_right.png", + "mp_dw_back.png", + "mp_dw_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.5, -0.4375, 0.4375, -0.4375, 0.4375}, + {-0.5, -0.4375, -0.4375, 0.5, 0.5, 0.5}, + {-0.5, 0.3125, -0.5, 0.5, 0.5, -0.4375}, + {-0.4375, -0.4375, -0.5, 0.4375, 0.25, 0.5}, + } + } +}) + +minetest.register_node("ma_pops_furniture:oven_overhead", { + description= "Oven Overhead", + tiles = { + "mp_camp_top.png", + "mp_camp_bottom.png", + "mp_camp_left.png", + "mp_camp_right.png", + "mp_camp_back.png", + "mp_camp_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, 0.4375, -0.4375, 0.4375, 0.5, 0.4375}, + {-0.5, 0.25, -0.5, 0.5, 0.4375, 0.5}, + } + } +}) + +minetest.register_node("ma_pops_furniture:microwave", { + description = "Microwave", + tiles = { + "mp_mw_top.png", + "mp_mw_bottom.png", + "mp_mw_right.png", + "mp_mw_left.png", + "mp_mw_back.png", + "mp_mw_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.4375, -0.3125, 0.4375, 0.0625, 0.3125}, + {-0.375, -0.5, -0.25, 0.375, -0.4375, 0.25}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:coffee_maker", { + description = "Coffee Maker", + tiles = { + "mp_cof_top.png", + "mp_cof_bottom.png", + "mp_cof_right.png", + "mp_cof_left.png", + "mp_cof_back.png", + "mp_cof_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.5, -0.0625, 0, -0.4375, 0.4375}, + {-0.4375, -0.5, 0.3125, 0, 0.1875, 0.4375}, + {-0.4375, -0.0625, 0, 0, 0.25, 0.4375}, + {-0.375, -0.4375, 0, -0.0625, -0.125, 0.25}, + {-0.25, -0.375, -0.125, -0.1875, -0.1875, 0.0625}, + } + } +}) + +minetest.register_node("ma_pops_furniture:toaster", { + description = "Toaster", + tiles = { + "mp_toas_top.png", + "mp_toas_bottom.png", + "mp_toas_right.png", + "mp_toas_left.png", + "mp_toas_back.png", + "mp_toas_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, + {-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:sink", { + description = "Counter (Sink)", + tiles = { + "mp_sink_top.png", + "mp_enc_bottom.png", + "mp_enc_right.png", + "mp_enc_left.png", + "mp_enc_back.png", + "mp_enc_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.375, 0.5, -0.4375, 0.5}, -- NodeBox1 + {-0.5, -0.4375, -0.4375, 0.5, 0.375, 0.5}, -- NodeBox2 + {0.0625, -0.375, -0.5, 0.4375, 0.3125, -0.4375}, -- NodeBox3 + {-0.4375, -0.375, -0.5, -0.0625, 0.3125, -0.4375}, -- NodeBox4 + {-0.5, 0.375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox5 + } + } +}) + +minetest.register_node("ma_pops_furniture:kitchen_faucet", { + description = "Kitchen Faucet", + tiles = { + "mp_grif_top.png", + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.0625, -0.5, 0.375, 0.0625, -0.1875, 0.4375}, + {-0.0625, -0.1875, 0.0625, 0.0625, -0.125, 0.4375}, + {-0.0625, -0.25, 0.0625, 0.0625, -0.1875, 0.125}, + {0.125, -0.5, 0.3125, 0.25, -0.375, 0.4375}, + {-0.25, -0.5, 0.3125, -0.125, -0.375, 0.4375}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:cutting_board", { + description = "Cutting Board", + tiles = { + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png", + "default_wood.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.4375, -0.5, -0.25, 0.25, -0.4375, 0.25}, + {0.25, -0.5, -0.0625, 0.4375, -0.4375, 0.0625}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:counter", { + description = "Counter", + tiles = { + "mp_enc_top.png", + "mp_enc_bottom.png", + "mp_enc_right.png", + "mp_enc_left.png", + "mp_enc_back.png", + "mp_enc_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.375, 0.5, -0.4375, 0.5}, -- NodeBox1 + {-0.5, -0.4375, -0.4375, 0.5, 0.375, 0.5}, -- NodeBox2 + {0.0625, -0.375, -0.5, 0.4375, 0.3125, -0.4375}, -- NodeBox3 + {-0.4375, -0.375, -0.5, -0.0625, 0.3125, -0.4375}, -- NodeBox4 + {-0.5, 0.375, -0.5, 0.5, 0.5, 0.5}, -- NodeBox5 + } + } +}) + +minetest.register_node("ma_pops_furniture:counterl", { + description = "Counter (Corner)", + tiles = { + "mp_corn_r_top.png", + "mp_corn_r_bottom.png", + "mp_corn_r_right.png", + "mp_corn_r_left.png", + "mp_corn_r_back.png", + "mp_corn_r_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {0.5, 0.5, 0.5, -0.5, -0.5, -0.5}, -- NodeBox1 + } + } +}) + +minetest.register_node("ma_pops_furniture:upcabinet", { +description = "Upper Cabinets", + tiles = { + "mp_up_top.png", + "mp_up_bottom.png", + "mp_up_right.png", + "mp_up_left.png", + "default_wood.png", + "mp_up_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.3125, -0.375, 0.5, 0.5, 0.5}, -- NodeBox1 + {-0.4375, -0.25, -0.4375, -0.0625, 0.4375, -0.375}, -- NodeBox2 + {0.0625, -0.25, -0.4375, 0.4375, 0.4375, -0.375}, -- NodeBox3 + {-0.1875, -0.1875, -0.5, -0.125, 0, -0.4375}, -- NodeBox4 + {0.125, -0.1875, -0.5, 0.1875, 0, -0.4375}, -- NodeBox5 + } + } +}) + +minetest.register_node("ma_pops_furniture:upcabinet_corner", { +description = "Upper Cabinets(corner)", + tiles = { + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png", + "mp_grif_sides.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.3125, -0.5, 0.5, 0.5, 0.5}, + } + } +}) + +minetest.register_node("ma_pops_furniture:fridge", { + description= "Fridge", + tiles = { + "mp_fridge_top.png", + "mp_fridge_bottom.png", + "mp_fridge_right.png", + "mp_fridge_left.png", + "mp_fridge_back.png", + "mp_fridge_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 6*4) + meta:set_string('formspec', + 'size [9,10]'.. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;1.5,1;6,4;]'.. + 'list[current_player;main;0.5,6;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.3125, 0.5, 0.5, 0.5}, -- NodeBox1 + {-0.5, -0.4375, -0.375, 0.4375, 0.5, -0.3125}, -- NodeBox2 + {0.3125, -0.25, -0.5, 0.375, 0.25, -0.4375}, -- NodeBox6 + {0.3125, -0.25, -0.4375, 0.375, -0.1875, -0.375}, -- NodeBox7 + {0.3125, 0.1875, -0.4375, 0.375, 0.25, -0.375}, -- NodeBox8 + } + } +}) + +--Living Room-- +local chair2_table = { --name, color, colorize(hex or color name:intensity(1-255)) +{'Black', 'black', 'black:225'}, +{'Blue', 'blue', 'blue:225'}, +{'Brown', 'brown', 'brown:225'}, +{'Cyan', 'cyan', 'cyan:200'}, +{'Dark Green', 'dark_green', 'green:225'}, +{'Dark Grey', 'dark_grey', 'black:200'}, +{'Green', 'green', '#32cd32:150'}, +{'Grey', 'grey', 'black:100'}, +{'Magenta', 'magenta', 'magenta:200'}, +{'Orange', 'orange', 'orange:225'}, +{'Pink', 'pink', 'pink:225'}, +{'Red', 'red', 'red:225'}, +{'Violet', 'violet', 'violet:225'}, +{'White', 'white', 'white:1'}, +{'Yellow', 'yellow', 'yellow:225'}, +} + +for i in ipairs (chair2_table) do + local name = chair2_table[i][1] + local color = chair2_table[i][2] + local hex = chair2_table[i][3] + +local cb = "^([combine:16x16:0,0=mp_cb.png^[mask:mp_mask.png)" +local cf = "^([combine:16x16:0,0=mp_cf.png^[mask:mp_mask.png)" + +minetest.register_node("ma_pops_furniture:chair2_"..color, { + description = name.." Chair", + tiles = {"wool_"..color..".png","wool_"..color..".png"..cb,"wool_"..color..".png"..cf,"wool_"..color..".png"..cf,"wool_"..color..".png"..cf,"wool_"..color..".png"..cf,}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1, fall_damage_add_percent=-80, bouncy=80}, + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, + node_box = { + type = "fixed", + fixed = { + {-0.4, -0.5, -0.4, -0.3, -0.4, -0.3}, + {-0.4, -0.5, 0.4, -0.3, -0.4, 0.3}, + {0.4, -0.5, 0.4, 0.3, -0.4, 0.3}, + {0.4, -0.5, -0.4, 0.3, -0.4, -0.3}, + ----------------------------------- + {-0.450, -0.4, -0.450, 0.450, 0.1, 0.450}, + {-0.5, 0.1, -0.5, -0.3, 0.3, 0.0}, + {0.5, 0.1, -0.5, 0.3, 0.3, 0.0}, + {0.450, 0.1, -0.0, -0.450, 0.5, 0.450}, + }, + } +}) +end + +local rbt = {name="mp_wool_coloured_rainbow.png", animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=7.0}} + +local rbt_cb = {name="mp_wool_coloured_rainbow.png^mp_r_cb.png", animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=7.0}} + +local rbt_cf = {name="mp_wool_coloured_rainbow.png^mp_r_cf.png", animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=7.0}} + +minetest.register_node("ma_pops_furniture:chair2_rainbow", { + description = "Rainbow Chair", + tiles = {rbt, rbt_cb, rbt_cf, rbt_cf, rbt_cf, rbt_cf}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1, fall_damage_add_percent=-80, bouncy=80}, + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, + node_box = { + type = "fixed", + fixed = { + {-0.4, -0.5, -0.4, -0.3, -0.4, -0.3}, + {-0.4, -0.5, 0.4, -0.3, -0.4, 0.3}, + {0.4, -0.5, 0.4, 0.3, -0.4, 0.3}, + {0.4, -0.5, -0.4, 0.3, -0.4, -0.3}, + ----------------------------------- + {-0.450, -0.4, -0.450, 0.450, 0.1, 0.450}, + {-0.5, 0.1, -0.5, -0.3, 0.3, 0.0}, + {0.5, 0.1, -0.5, 0.3, 0.3, 0.0}, + {0.450, 0.1, -0.0, -0.450, 0.5, 0.450}, + }, + } +}) + +local fs_table = { --name, color, colorize(hex or color name:intensity(1-255)) +{'Black', 'black', 'black:225'}, +{'Blue', 'blue', 'blue:225'}, +{'Brown', 'brown', 'brown:225'}, +{'Cyan', 'cyan', 'cyan:200'}, +{'Dark Green', 'dark_green', 'green:225'}, +{'Dark Grey', 'dark_grey', 'black:200'}, +{'Green', 'green', '#32cd32:150'}, +{'Grey', 'grey', 'black:100'}, +{'Magenta', 'magenta', 'magenta:200'}, +{'Orange', 'orange', 'orange:225'}, +{'Pink', 'pink', 'pink:225'}, +{'Red', 'red', 'red:225'}, +{'Violet', 'violet', 'violet:225'}, +{'White', 'white', 'white:1'}, +{'Yellow', 'yellow', 'yellow:225'}, +} + +for i in ipairs (fs_table) do + local name = fs_table[i][1] + local color = fs_table[i][2] + local hex = fs_table[i][3] + +minetest.register_node("ma_pops_furniture:fs_"..color, { + description = name.." Footstool", + tiles = {"wool_"..color..".png","wool_"..color..".png^mp_cb.png","wool_"..color..".png^mp_cf.png","wool_"..color..".png^mp_cf.png","wool_"..color..".png^mp_cf.png","wool_"..color..".png^mp_cf.png",}, + drawtype = "nodebox", + paramtype = "light", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.4, -0.5, -0.4, -0.3, -0.4, -0.3}, + {-0.4, -0.5, 0.4, -0.3, -0.4, 0.3}, + {0.4, -0.5, 0.4, 0.3, -0.4, 0.3}, + {0.4, -0.5, -0.4, 0.3, -0.4, -0.3}, + ----------------------------------- + {-0.450, -0.4, -0.450, 0.450, -0.1, 0.450}, + }, + } +}) +end + +local rbt = {name="mp_wool_coloured_rainbow.png", animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=7.0}} + +local rbt_cb = {name="mp_wool_coloured_rainbow.png^mp_r_cb.png", animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=7.0}} + +local rbt_cf = {name="mp_wool_coloured_rainbow.png^mp_r_cf.png", animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=7.0}} + +minetest.register_node('ma_pops_furniture:fs_rainbow', { + description = "Rainbow Footstool", + tiles = {rbt, rbt_cb, rbt_cf, rbt_cf, rbt_cf, rbt_cf}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.4, -0.5, -0.4, -0.3, -0.4, -0.3}, + {-0.4, -0.5, 0.4, -0.3, -0.4, 0.3}, + {0.4, -0.5, 0.4, 0.3, -0.4, 0.3}, + {0.4, -0.5, -0.4, 0.3, -0.4, -0.3}, + ----------------------------------- + {-0.450, -0.4, -0.450, 0.450, -0.1, 0.450}, + }, + } +}) + +minetest.register_node('ma_pops_furniture:vcr_on', { + description= "VCR", + tiles = { + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png^mp_vcr_on.png" + }, + drawtype= "nodebox", + paramtype= "light", + paramtype2 = "facedir", + drop = 'ma_pops_furniture:vcr_off', + groups = {choppy = 2, oddly_breakable_by_hand = 2, not_in_creative_inventory=1, furniture = 1}, + node_box= { + type= "fixed", + fixed= { + {-0.375, -0.5, -0.25, 0.375, -0.4375, 0.25}, + {-0.4375, -0.4375, -0.3125, 0.4375, -0.25, 0.3125}, + }, + }, + on_rightclick = function (pos, node, puncher) + node.name = "ma_pops_furniture:vcr_off" + minetest.set_node(pos, node) + end, +}) + +minetest.register_node('ma_pops_furniture:vcr_off', { + description= "VCR", + tiles = { + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png", + "default_coal_block.png^mp_vcr_off.png" + }, + drawtype= "nodebox", + paramtype= "light", + paramtype2 = "facedir", + drop = 'ma_pops_furniture:vcr_off', + groups = {choppy = 2, oddly_breakable_by_hand = 2, furniture = 1}, + node_box= { + type= "fixed", + fixed= { + {-0.375, -0.5, -0.25, 0.375, -0.4375, 0.25}, + {-0.4375, -0.4375, -0.3125, 0.4375, -0.25, 0.3125}, + }, + }, + on_rightclick = function (pos, node, puncher) + node.name = "ma_pops_furniture:vcr_on" + minetest.set_node(pos, node) + end, +}) + +local unit_table = { --name, material +{'Wood Entertainment Unit', 'wood'}, +{'Acacia Wood Entertainment Unit', 'acacia_wood'}, +{'Aspen Wood Entertainment Unit', 'aspen_wood'}, +{'Pine Wood Entertainment Unit', 'pine_wood'}, +{'Jungle Wood Entertainment Unit', 'junglewood'} +} + +for i in ipairs (unit_table) do + local name = unit_table[i][1] + local material = unit_table[i][2] + local invimg = unit_table[i][3] + +minetest.register_node("ma_pops_furniture:entertainment_unit_"..material, { + description= name, + tiles= {'default_'..material..'.png'}, + drawtype= "nodebox", + paramtype= "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box= { + type= "fixed", + fixed= { + {-0.5, -0.5, -0.5, -0.4, 0.5, 0.5}, + {0.5, -0.5, -0.5, 0.4, 0.5, 0.5}, + {-0.5, 0.4, -0.5, 0.5, 0.5, 0.5}, + {-0.5, -0.050, -0.5, 0.5, 0.050, 0.5}, + {-0.5, -0.5, 0.5, 0.5, 0.5, 0.4}, + }, + } +}) +end + +minetest.register_node('ma_pops_furniture:fireplace', { + description = 'Fireplace', + drawtype = 'mesh', + mesh = 'FM_fireplace_off.obj', + tiles = {{name='default_brick.png'},{name='xpanes_bar.png'}}, + groups = {cracky=2, oddly_breakable_by_hand=6, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_stone_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('fuel', 1) + inv:set_size('main', 8*4) + meta:set_string('formspec', ma_pops_furniture.fireplace_formspec) + meta:set_string('infotext', 'Fireplace') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('fuel') + end, +}) + +minetest.register_node('ma_pops_furniture:fireplace_on', { + description = 'Fireplace', + drawtype = 'mesh', + mesh = 'FM_fireplace_on.obj', + tiles = {{name='default_brick.png'},{name='xpanes_bar.png'},{name='default_tree.png'},{name='fire_basic_flame_animated.png', animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=1}}}, + groups = {cracky=2, oddly_breakable_by_hand=3, furniture=1, not_in_creative_inventory=1}, + light_source = 14, + paramtype = 'light', + paramtype2 = 'facedir', + drops = 'ma_pops_furniture:fireplace', + sounds = default.node_sound_stone_defaults(), + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('fuel') + end, +}) + +minetest.register_node("ma_pops_furniture:lamp", { + description= "Lamp", + tiles= {"mp_lt.png","mp_lb.png","mp_ls.png","mp_ls.png","mp_ls.png","mp_ls.png",}, + drawtype= "nodebox", + light_source = 14, + paramtype = "facedir", + drop= 'ma_pops_furniture:lamp_off', + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:lamp_off" + minetest.set_node(pos, node) + end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_creative_inventory = 1, furniture = 1}, + node_box= { + type= "fixed", + fixed= { + {-0.25, -0.4375, -0.25, 0.25, -0.0625, 0.25}, + {-0.375, -0.0625, -0.375, 0.375, 0.5, 0.375}, + {-0.1875, -0.4375, -0.1875, 0.1875, -0.5, 0.1875}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:lamp_off", { + description= "Lamp", + tiles= {"mp_lt.png","mp_lb.png","mp_ls.png","mp_ls.png","mp_ls.png","mp_ls.png",}, + drawtype= "nodebox", + paramtype = "facedir", + on_rightclick = function (pos, node, player, itemstack, pointed_thing) + node.name = "ma_pops_furniture:lamp" + minetest.set_node(pos, node) + end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + node_box= { + type= "fixed", + fixed= { + {-0.25, -0.4375, -0.25, 0.25, -0.0625, 0.25}, + {-0.375, -0.0625, -0.375, 0.375, 0.5, 0.375}, + {-0.1875, -0.4375, -0.1875, 0.1875, -0.5, 0.1875}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:curtains", { + description= "Curtains", + tiles= {"default_acacia_tree.png","mp_curtainb.png","wool_red.png^mp_curtains.png","wool_red.png^mp_curtains.png","wool_red.png^mp_curtains.png","wool_red.png^mp_curtains.png",}, + drawtype= "nodebox", + paramtype= "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + on_rightclick = function(pos, node, puncher) + minetest.env:add_node(pos, {name = "ma_pops_furniture:curtains_closed", param2 = node.param2}) + ma_pops_furniture.window_operate( pos, "ma_pops_furniture:curtains", "ma_pops_furniture:curtains_closed" ); + end, + node_box= { + type= "fixed", + fixed= { + {-0.5, -0.3, 0.5, -0.2, 0.5, 0.4}, + {-0.5, -0.5, 0.5, -0.3, -0.3, 0.4}, + {-0.5, 0.5, 0.5, 0.5, 0.2, 0.4}, + {-0.5, 0.5, 0.5, 0.5, 0.440, 0.350}, + {0.5, -0.3, 0.5, 0.2, 0.5, 0.4}, + {0.5, -0.5, 0.5, 0.3, -0.3, 0.4}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:curtains_closed", { + description = "curtains closed", + tiles= {"default_acacia_tree.png","mp_curtainb.png","wool_red.png^mp_curtains.png","wool_red.png^mp_curtains.png","wool_red.png^mp_curtains.png","wool_red.png^mp_curtains.png",}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_creative_inventory = 1, furniture = 1}, + on_rightclick = function(pos, node, puncher) + minetest.env:add_node(pos, {name = "ma_pops_furniture:curtains", param2 = node.param2}) + ma_pops_furniture.window_operate( pos, "ma_pops_furniture:curtains_closed", "ma_pops_furniture:curtains" ); + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, 0.5, 0.5, 0.5, 0.4}, + {-0.5, 0.5, 0.5, 0.5, 0.440, 0.350}, + + }, + } +}) + +minetest.register_node("ma_pops_furniture:curtains_2_tall", { +description= "Curtains 2 tall", +tiles = {"wool_red.png"}, +drawtype= "nodebox", +paramtype= "light", +paramtype2 = "facedir", +groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) +node.name = "ma_pops_furniture:curtains_2_tall_closed" minetest.set_node(pos, node) +end, +node_box= { +type= "fixed", +fixed= { +{-0.5, -0.3, 0.5, -0.2, 0.5, 0.4}, +{-0.5, -0.5, 0.5, -0.3, -0.3, 0.4}, +{-0.5, 0.5, 0.5, 0.5, 0.2, 0.4}, +{0.5, -0.3, 0.5, 0.2, 0.5, 0.4}, +{0.5, -0.5, 0.5, 0.3, -0.3, 0.4}, + {-0.5, -0.5, 0.5, -0.3, -1.2, 0.4}, + {0.5, -0.5, 0.5, 0.3, -1.2, 0.4}, + {-0.5, -1.2, 0.5, -0.4, -1.5, 0.4}, + {0.5, -1.2, 0.5, 0.4, -1.5, 0.4}, +}, +} +}) + +minetest.register_node("ma_pops_furniture:curtains_2_tall_closed", { +description= "Curtains 2 tall closed", +tiles = {"wool_red.png"}, +drawtype= "nodebox", +paramtype= "light", +paramtype2 = "facedir", +groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_creative_inventory = 1}, +on_rightclick = function(pos, node, player, itemstack, pointed_thing) +node.name = "ma_pops_furniture:curtains_2_tall" minetest.set_node(pos, node) +end, +node_box= { +type= "fixed", +fixed= { + {0.5, 0.5, 0.5, -0.5, -1.5, 0.4}, +}, +} +}) + +minetest.register_node("ma_pops_furniture:blinds", { + description = "Blinds", + tiles = {"mp_blinds.png"}, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.5, 0.5, 0.5, 0.4, 0.4}, + {-0.5, 0.3, 0.5, 0.5, 0.2, 0.4}, + {-0.5, 0.1, 0.5, 0.5, 0.0, 0.4}, + {-0.5, -0.1, 0.5, 0.5, -0.2, 0.4}, + {-0.5, -0.3, 0.5, 0.5, -0.4, 0.4}, + }, + } +}) + +local songs = { "static" +} + +minetest.register_node("ma_pops_furniture:stereo", { + description = "Stereo", + tiles = { + "mp_radio_top.png", + "mp_radio_bottom.png", + "mp_radio_right.png", + "mp_radio_left.png", + "mp_radio_back.png", + "mp_radio_front.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, furniture = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, 0.1875, 0.5, -0.125, 0.5}, -- NodeBox1 + {-0.25, -0.5, 0.125, 0.25, -0.0625, 0.5}, -- NodeBox2 + } + }, + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then + minetest.sound_stop(meta:get_string("hwnd")) + meta:set_string("hwnd",nil) + else + meta:set_string("hwnd",minetest.sound_play("radio_" .. songs[math.random(1,#songs)], {gain = 0.5, max_hear_distance = 25})) + end + end, + on_destruct = function(pos) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end + end, +}) + +minetest.register_node('ma_pops_furniture:tv_rainbow', { + description = 'TV', + drawtype = 'mesh', + mesh = 'FM_tv.obj', + drop = 'ma_pops_furniture:tv_off', + tiles = {{name='default_tree.png'},{name='mp_channel_rainbow.png', animation={type='vertical_frames', aspect_w=64, aspect_h=48, length=3}}}, + groups = {cracky=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + light_source = 14, + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, -- Right, Bottom, Back, Left, Top, Front + }, + collision_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, + }, + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.env:get_meta(pos) + node.name = "ma_pops_furniture:tv_blast" + minetest.set_node(pos, node) + if string.len(meta:get_string("hwnd")) > 0 then + minetest.sound_stop(meta:get_string("hwnd")) + meta:set_string("hwnd",nil) + else + meta:set_string("hwnd",minetest.sound_play("mp_blast", {gain = 0.5, max_hear_distance = 25})) + end + end, + on_destruct = function(pos) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end + end, +}) + +minetest.register_node('ma_pops_furniture:tv_blast', { + description = 'TV', + drawtype = 'mesh', + mesh = 'FM_tv.obj', + drop = 'ma_pops_furniture:tv_off', + tiles = {{name='default_tree.png'},{name='mp_channel_blast.png', animation={type='vertical_frames', aspect_w=64, aspect_h=64, length=22}}}, + groups = {cracky=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + light_source = 14, + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, -- Right, Bottom, Back, Left, Top, Front + }, + collision_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, + }, + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.env:get_meta(pos) + node.name = "ma_pops_furniture:tv_static" + minetest.set_node(pos, node) + if string.len(meta:get_string("hwnd")) > 0 then + minetest.sound_stop(meta:get_string("hwnd")) + meta:set_string("hwnd",nil) + else + meta:set_string("hwnd",minetest.sound_play("mp_static", {gain = 0.5, max_hear_distance = 25})) + end + end, + on_destruct = function(pos) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end + end, +}) + +minetest.register_node('ma_pops_furniture:tv_static', { + description = 'TV', + drawtype = 'mesh', + mesh = 'FM_tv.obj', + drop = 'ma_pops_furniture:tv_off', + tiles = {{name='default_tree.png'},{name='mp_channel_static.png', animation={type='vertical_frames', aspect_w=40, aspect_h=30, length=1}}}, + groups = {cracky=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + light_source = 14, + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, -- Right, Bottom, Back, Left, Top, Front + }, + collision_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, + }, + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.env:get_meta(pos) + node.name = "ma_pops_furniture:tv_cube" + minetest.set_node(pos, node) + if string.len(meta:get_string("hwnd")) > 0 then + minetest.sound_stop(meta:get_string("hwnd")) + meta:set_string("hwnd",nil) + else + meta:set_string("hwnd",minetest.sound_play("mp_glass", {gain = 0.5, max_hear_distance = 25})) + end + end, + on_destruct = function(pos) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end + end, +}) + +minetest.register_node('ma_pops_furniture:tv_cube', { + description = 'TV', + drawtype = 'mesh', + mesh = 'FM_tv.obj', + drop = 'ma_pops_furniture:tv_off', + tiles = {{name='default_tree.png'},{name='mp_channel_cube.png', animation={type='vertical_frames', aspect_w=40, aspect_h=40, length=2}}}, + groups = {cracky=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + light_source = 14, + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, -- Right, Bottom, Back, Left, Top, Front + }, + collision_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, + }, + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.env:get_meta(pos) + node.name = "ma_pops_furniture:tv_off" + minetest.set_node(pos, node) + if string.len(meta:get_string("hwnd")) > 0 then + minetest.sound_stop(meta:get_string("hwnd")) + meta:set_string("hwnd",nil) + end + end, + on_destruct = function(pos) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end + end, +}) + +minetest.register_node('ma_pops_furniture:tv_off', { + description = 'TV', + drawtype = 'mesh', + mesh = 'FM_tv.obj', + tiles = {{name='default_tree.png'},{name='wool_black.png^default_glass_detail.png^[colorize:black:225',}}, + groups = {cracky=2, oddly_breakable_by_hand=3, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + light_source = 1, + sounds = default.node_sound_wood_defaults(), + selection_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, -- Right, Bottom, Back, Left, Top, Front + }, + collision_box = { + type = 'fixed', + fixed = {-.45, -.5, -.5, .45, .4, .45}, + }, + on_rightclick = function(pos, node, clicker, itemstack) + local meta = minetest.env:get_meta(pos) + node.name = "ma_pops_furniture:tv_rainbow" + minetest.set_node(pos, node) + if string.len(meta:get_string("hwnd")) > 0 then + minetest.sound_stop(meta:get_string("hwnd")) + meta:set_string("hwnd",nil) + else + meta:set_string("hwnd",minetest.sound_play("mp_rainbow", {gain = 0.5, max_hear_distance = 25})) + end + end, + on_destruct = function(pos) + local meta = minetest.env:get_meta(pos) + if string.len(meta:get_string("hwnd")) > 0 then minetest.sound_stop(meta:get_string("hwnd")) end + end, +}) + +local c_table = { --name, material, invimg +{'Stone Coffee Table', 'cobble'}, +{'Wood Coffee Table', 'wood'}, +{'Acacia Wood Coffee Table', 'acacia_wood'}, +{'Aspen Wood Coffee Table', 'aspen_wood'}, +{'Pine Wood Coffee Table', 'pine_wood'}, +{'Jungle Wood Coffee Table', 'junglewood'} +} + +for i in ipairs (c_table) do + local name = c_table[i][1] + local material = c_table[i][2] + local invimg = c_table[i][3] + +minetest.register_node('ma_pops_furniture:c_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {choppy=2, oddly_breakably_by_hand=2, furniture=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, -0.4, 0.0, -0.4}, + {-0.5, -0.5, 0.5, -0.4, 0.0, 0.4}, + {0.5, -0.5, -0.5, 0.4, 0.0, -0.4}, + {0.5, -0.5, 0.5, 0.4, 0.0, 0.4}, + {0.5, 0.1, 0.5, -0.5, 0.0, -0.5}, + {0.5, -0.3, 0.5, -0.5, -0.4, -0.5}, + }, + } +}) +end + +local end_table = { --name, material, invimg +{'Stone End Table', 'cobble'}, +{'Wood End Table', 'wood'}, +{'Acacia Wood End Table', 'acacia_wood'}, +{'Aspen Wood End Table', 'aspen_wood'}, +{'Pine Wood End Table', 'pine_wood'}, +{'Jungle Wood End Table', 'junglewood'} +} + +for i in ipairs (end_table) do + local name = end_table[i][1] + local material = end_table[i][2] + local invimg = end_table[i][3] + +minetest.register_node('ma_pops_furniture:end_table_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {choppy=2, oddly_breakably_by_hand=2, furniture=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.env:get_meta(pos) + local inv = meta:get_inventory() + inv:set_size('main', 8*4) + inv:set_size('storage', 3*3) + meta:set_string('formspec', + 'size [9,10]'.. + 'bgcolor[#080808BB;true]'.. + 'list[current_name;storage;3,1.5;3,3;]'.. + 'list[current_player;main;0.5,6.5;8,4;]') + end, + can_dig = function(pos,player) + local meta = minetest.get_meta(pos); + local inv = meta:get_inventory() + return inv:is_empty('storage') and inv:is_empty('storage1') + end, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, -0.4, 0.5, -0.4}, + {-0.5, -0.5, 0.5, -0.4, 0.5, 0.4}, + {0.5, -0.5, -0.5, 0.4, 0.5, -0.4}, + {0.5, -0.5, 0.5, 0.4, 0.5, 0.4}, + {0.5, 0.4, 0.5, -0.5, 0.5, -0.5}, + {0.5, -0.3, 0.5, -0.5, -0.2, -0.5}, + }, + } +}) +end + +--Office-- +minetest.register_node("ma_pops_furniture:computer", { + description = "Computer", + tiles = { + "mp_s.png^mp_top.png", + "mp_s.png", + "mp_s.png", + "mp_s.png", + "mp_s.png", + "mp_s.png^mp_f.png" + }, + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=2, oddly_breakable_by_hand=2, furniture=1, flammable=1}, + sounds = default.node_sound_wood_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.1875, 0.5, -0.25, 0.5}, + {-0.5, -0.5, -0.5, 0.1875, -0.375, -0.25}, + {0.25, -0.5, -0.5, 0.4375, -0.375, -0.25}, + {-0.125, -0.25, 0.0625, 0.125, -0.0625, 0.25}, + {-0.3125, -0.125, -0.25, 0.3125, 0.5, 0.3125}, + {-0.25, 0, 0.3125, 0.25, 0.375, 0.5}, + } + } +}) + +--Outside-- +local hedge_table = { --name, material, invimg +{'Hedge', 'leaves'}, +{'Pine Hedge', 'pine_needles'}, +{'Jungle Hedge', 'jungleleaves'}, +{'Acacia Hedge', 'acacia_leaves'}, +{'Aspen Hedge', 'aspen_leaves'} +} + +for i in ipairs (hedge_table) do + local name = hedge_table[i][1] + local material = hedge_table[i][2] + local invimg = hedge_table[i][3] + +minetest.register_node('ma_pops_furniture:hedge_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy=2, oddly_breakable_by_hand=2, furniture=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_leaves_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.1875, 0.5, 0.1875, 0.1875}, + } + } +}) + +minetest.register_node('ma_pops_furniture:hedge_c_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_leaves_defaults(), + drop = 'ma_pops_furniture:hedge_'..material, + node_box = { + type = "fixed", + fixed = { + {-0.1875, -0.5, -0.1875, 0.5, 0.1875, 0.1875}, + {-0.1875, -0.5, 0.1875, 0.1875, 0.1875, 0.5}, + } + } +}) + +minetest.register_node('ma_pops_furniture:hedge_t_'..material, { + description = name, + drawtype = 'nodebox', + tiles = {'default_'..material..'.png'}, + groups = {snappy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1, flammable=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_leaves_defaults(), + drop = 'ma_pops_furniture:hedge_'..material, + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.1875, 0.5, 0.1875, 0.1875}, + {-0.1875, -0.5, 0.1875, 0.1875, 0.1875, 0.5}, + } + } +}) +end + +minetest.register_node('ma_pops_furniture:birdbath', { + description = 'Birdbath', + drawtype = 'mesh', + mesh = 'FM_birdbath.obj', + tiles = {{name='default_stone.png'},{name='default_water_source_animated.png', animation={type='vertical_frames', aspect_w=16, aspect_h=16, length=2.0}}}, + groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node('ma_pops_furniture:doorbell', { + description = 'Doorbell', + drawtype = 'nodebox', + tiles = { + "mp_db_top.png", + "mp_db_top.png", + "mp_db_right.png", + "mp_db_left.png", + "default_wood.png", + "mp_db_front.png" + }, + groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + on_rightclick = function(pos, node, clicker, itemstack) + node.name = "ma_pops_furniture:doorbell_ring" + minetest.swap_node(pos, node) + -- one second ring. + minetest.get_node_timer(pos):start(1.0) + end, + sounds = default.node_sound_stone_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.125, -0.375, 0.4375, 0.125, -0.125, 0.5}, + {-0.0625, -0.3125, 0.375, 0.0625, -0.1875, 0.4375}, + }, + } +}) + +minetest.register_node('ma_pops_furniture:doorbell_ring', { + description = 'Doorbell (ring)', + drawtype = 'nodebox', + tiles = { + "mp_db_top.png", + "mp_db_top.png", + "mp_db_right.png", + "mp_db_left.png", + "default_wood.png", + "mp_db_front.png" + }, + groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1, not_in_creative_inventory=1}, + drop = 'ma_pops_furniture:doorbell', + on_timer = function(pos,elapsed) + local node = minetest.get_node(pos) + node.name = "ma_pops_furniture:doorbell" + minetest.swap_node(pos, node) + end, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_stone_defaults(), + node_box = { + type = "fixed", + fixed = { + {-0.125, -0.375, 0.4375, 0.125, -0.125, 0.5}, + {-0.0625, -0.3125, 0.375, 0.0625, -0.1875, 0.4375}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:grill", { + description = "Grill", + tiles = { + "default_coal_block.png^mp_grillt.png", + "default_stone.png", + "default_stone.png^mp_grills.png", + "default_stone.png^mp_grills.png", + "default_stone.png^mp_grills.png", + "default_stone.png^mp_grills.png" +}, + drawtype = "nodebox", + paramtype = "light", + on_rightclick = function (pos, node, player, itemstack, pointed_thing) +node.name = "ma_pops_furniture:grill_on" +minetest.set_node(pos, node) +end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, + node_box = { + type = "fixed", + fixed = { + {-0.450, -0.5, -0.450, -0.350, -0.3, -0.350}, + {0.450, -0.5, -0.450, 0.350, -0.3, -0.350}, + {-0.450, -0.5, 0.450, -0.350, -0.3, 0.350}, + {0.450, -0.5, 0.450, 0.350, -0.3, 0.350}, + + {-0.4, -0.3, -0.4, -0.3, 0.0, -0.3}, + {0.4, -0.3, -0.4, 0.3, 0.0, -0.3}, + {-0.4, -0.3, 0.4, -0.3, 0.0, 0.3}, + {0.4, -0.3, 0.4, 0.3, 0.0, 0.3}, + + {-0.4, -0.0, -0.4, 0.4, 0.2, 0.4}, + {-0.5, 0.190, -0.5, 0.5, 0.4, 0.5}, + + {-0.4375, 0.4, 0.5, -0.5, 0.5, -0.5}, + {0.4375, 0.4, 0.5, 0.5, 0.5, -0.5}, + {-0.5, 0.4, 0.4375, 0.5, 0.5, 0.5}, + {-0.5, 0.4, -0.4375, 0.5, 0.5, -0.5}, + }, + } +}) + +minetest.register_node("ma_pops_furniture:grill_on", { + description = "grill on", + tiles = { + "default_coal_block.png^mp_grillton.png", + "default_stone.png", + "default_stone.png^mp_grills.png", + "default_stone.png^mp_grills.png", + "default_stone.png^mp_grills.png", + "default_stone.png^mp_grills.png" +}, + drawtype = "nodebox", + paramtype = "light", + light_source = 14, + on_rightclick = function (pos, node, player, itemstack, pointed_thing) +node.name = "ma_pops_furniture:grill" +minetest.set_node(pos, node) +end, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, not_in_creative_inventory = 1}, + node_box = { + type = "fixed", + fixed = { + {-0.450, -0.5, -0.450, -0.350, -0.3, -0.350}, + {0.450, -0.5, -0.450, 0.350, -0.3, -0.350}, + {-0.450, -0.5, 0.450, -0.350, -0.3, 0.350}, + {0.450, -0.5, 0.450, 0.350, -0.3, 0.350}, + + {-0.4, -0.3, -0.4, -0.3, 0.0, -0.3}, + {0.4, -0.3, -0.4, 0.3, 0.0, -0.3}, + {-0.4, -0.3, 0.4, -0.3, 0.0, 0.3}, + {0.4, -0.3, 0.4, 0.3, 0.0, 0.3}, + + {-0.4, -0.0, -0.4, 0.4, 0.2, 0.4}, + {-0.5, 0.190, -0.5, 0.5, 0.4, 0.5}, + + {-0.4375, 0.4, 0.5, -0.5, 0.5, -0.5}, + {0.4375, 0.4, 0.5, 0.5, 0.5, -0.5}, + {-0.5, 0.4, 0.4375, 0.5, 0.5, 0.5}, + {-0.5, 0.4, -0.4375, 0.5, 0.5, -0.5}, + }, + } +}) + +minetest.register_node('ma_pops_furniture:stone_path_1', { + description = 'Stone Path', + drawtype = 'mesh', + mesh = 'FM_stone_path_1.obj', + tiles = {'default_stone.png'}, + groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_stone_defaults(), + selection_box = { + type = 'fixed', + fixed = {-.5, -.5, -.5, .5, -.4, .5}, + }, + collision_box = { + type = 'fixed', + fixed = {-.5, -.5, -.5, .5, -.4, .5}, + }, + on_place = function(itemstack, placer, pointed_thing) + local stack = ItemStack("ma_pops_furniture:stone_path_" .. math.random(1,4)) + local ret = minetest.item_place(stack, placer, pointed_thing) + return ItemStack("ma_pops_furniture:stone_path_1 " .. + itemstack:get_count() - (1 - ret:get_count())) + end, +}) + +for i = 2, 4 do +minetest.register_node('ma_pops_furniture:stone_path_'..i, { + description = 'Stone Path', + drawtype = 'mesh', + mesh = 'FM_stone_path_'..i..'.obj', + tiles = {'default_stone.png'}, + groups = {cracky=2, oddly_breakable_by_hand=5, furniture=1, not_in_creative_inventory=1}, + paramtype = 'light', + paramtype2 = 'facedir', + sounds = default.node_sound_stone_defaults(), + drop = 'ma_pops_furniture:stone_path_1', + selection_box = { + type = 'fixed', + fixed = {-.5, -.5, -.5, .5, -.4, .5}, + }, + collision_box = { + type = 'fixed', + fixed = {-.5, -.5, -.5, .5, -.4, .5}, + }, +}) +end \ No newline at end of file diff --git a/oven.lua b/oven.lua new file mode 100644 index 0000000..d89fa0e --- /dev/null +++ b/oven.lua @@ -0,0 +1,163 @@ +local oven_fs = "size[8,7]" + .."image[3.5,1.5;1,1;default_furnace_fire_bg.png]" + .."list[current_player;main;0,3;8,4;]" + .."list[context;input;2,1.5;1,1;]" + .."list[context;output;5,1.5;1,1;]" + .."label[3,0.5;Oven]" + .."label[1.5,1;Uncooked Food]" + .."label[4.5,1;Cooked Food]" + -- possibly add "fire" image? + +local function get_active_oven_fs(item_percent) + return "size[8,7]" + .."image[3.5,1.5;1,1;default_furnace_fire_bg.png^[lowpart:" + ..(item_percent)..":default_furnace_fire_fg.png]" + .."list[current_player;main;0,3;8,4;]" + .."list[context;input;2,1.5;1,1;]" + .."list[context;output;5,1.5;1,1;]" + .."label[3,0.5;Oven]" + .."label[1.5,1;Uncooked Food]" + .."label[4.5,1;Cooked Food]" + -- possibly add "fire" image? +end + +--x,y;w,h + +-- Adding recipe API so we don't end up hardcoding items +ma_pops_furniture.oven = {} +local oven = ma_pops_furniture.oven +oven.recipes = {} +function oven.register_recipe(input, output) oven.recipes[input] = output end + +local function update_formspec(progress, goal, meta) + local formspec + + if progress > 0 and progress <= goal then + local item_percent = math.floor(progress / goal * 100) + formspec = get_active_oven_fs(item_percent) + else + formspec = oven_fs + end + + meta:set_string("formspec", formspec) +end + +local function recalculate(pos) + local meta, timer = minetest.get_meta(pos), minetest.get_node_timer(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack("input", 1) + + local k = oven.recipes[stack:get_name()] + if not k then return end + + timer:stop() + update_formspec(0, 3, meta) + timer:start(1) +end + +local function do_cook_single(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local food_uncooked = inv:get_stack("input", 1) + food_uncooked:set_count(1) + + --If the uncooked food wasn't removed mid-cooking, then cook it. + if not oven.recipes[food_uncooked:get_name()] then + minetest.chat_send_all("Oven cooked nothing because there was nothing to cook.") + minetest.get_node_timer(pos):stop() + update_formspec(0, 3, meta) + else + inv:remove_item("input", food_uncooked) -- Clear the slot + local food_cooked = oven.recipes[food_uncooked:get_name()] -- Get the cooked food + inv:add_item("output", food_cooked) -- Put the cooked food in the slot + end +end + +minetest.register_node("ma_pops_furniture:oven", { + description = "Oven", + tiles = { + "mp_oven_top.png", + "mp_oven_bottom.png", + "mp_oven_right.png", + "mp_oven_left.png", + "mp_oven_back.png", + "mp_oven_front.png" + }, + paramtype2 = "facedir", + groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1}, + legacy_facedir_simple = true, + is_ground_content = false, + sounds = default.node_sound_stone_defaults(), + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, 0.3125, -0.5, 0.5, 0.5, 0.5}, + {-0.5, -0.5, -0.375, 0.5, 0.3125, 0.5}, + {-0.4375, -0.4375, -0.4375, 0.4375, 0.25, -0.375}, + {-0.375, 0.125, -0.5, 0.375, 0.1875, -0.375}, + }, + }, + can_dig = function(pos, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + return inv:is_empty("input") and inv:is_empty("output") + end, + + on_timer = function(pos, elapsed) + local meta = minetest.get_meta(pos) + local stack = meta:get_inventory():get_stack("input", 1) + local cooking_time = meta:get_int("cooking_time") or 0 + cooking_time = cooking_time + 1 + + if cooking_time % 3 == 0 then + do_cook_single(pos) + end + + update_formspec(cooking_time % 3, 3, meta) + meta:set_int("cooking_time", cooking_time) + + --Keep cooking until there is nothing left to cook. + if not stack:is_empty() then + return true + else + meta:set_int("cooking_time", 0) + update_formspec(0, 3, meta) + return false + end + end, + + on_metadata_inventory_put = recalculate, + on_metadata_inventory_take = recalculate, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", oven_fs) + local inv = meta:get_inventory() + inv:set_size("input", 1) + inv:set_size("output", 1) + end, + + on_blast = function(pos) + local drops = {} + default.get_inventory_drops(pos, "input", drops) + default.get_inventory_drops(pos, "output", drops) + table.insert(drops, "ma_pops_furniture:oven") + minetest.remove_node(pos) + return drops + end, + + allow_metadata_inventory_put = function(pos, list, index, stack, player) + return oven.recipes[stack:get_name()] and stack:get_count() or 0 + end, +}) + +-- Recipe Registration +oven.register_recipe("default:ice", "default:water_source") +-- No milk bucket as this doesn't support substitutes for now +oven.register_recipe("mobs_mc:chicken_raw", "test:chicken_cooked") +--[[ We don't need to check mod existance when registering recipe +Recipe won't even be executed if there is no raw chicken in input ]]-- +oven.register_recipe("mobs_mc:beef_raw", "test:beef_cooked") +oven.register_recipe("farming:coffee_cup", "farming:coffee_cup_hot") -- What a crutch there was... +-- Add needed recipes as you go, note that other mods can add more recipes too diff --git a/sit.lua b/sit.lua new file mode 100644 index 0000000..ff2fa85 --- /dev/null +++ b/sit.lua @@ -0,0 +1,32 @@ +function ma_pops_furniture.sit(pos, node, clicker) + do return end -- delete it when the engine is stabler for the player's physics + local meta = minetest.get_meta(pos) + local param2 = node.param2 + local name = clicker:get_player_name() + + if name == meta:get_string("is_sit") then + meta:set_string("is_sit", "") + pos.y = pos.y-0.5 + clicker:setpos(pos) + clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) + clicker:set_physics_override(1, 1, 1) + default.player_attached[name] = false + default.player_set_animation(clicker, "stand", 30) + else + meta:set_string("is_sit", clicker:get_player_name()) + clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0}) + clicker:set_physics_override(0, 0, 0) + clicker:setpos(pos) + default.player_attached[name] = true + default.player_set_animation(clicker, "sit", 30) + if param2 == 0 then + clicker:set_look_yaw(3.15) + elseif param2 == 1 then + clicker:set_look_yaw(7.9) + elseif param2 == 2 then + clicker:set_look_yaw(6.28) + elseif param2 == 3 then + clicker:set_look_yaw(4.75) + else return end + end +end diff --git a/sofa.lua b/sofa.lua new file mode 100644 index 0000000..b995410 --- /dev/null +++ b/sofa.lua @@ -0,0 +1,193 @@ +ma_pops_furniture.default_hues = { + "white", + "grey", + "dark_grey", + "black", + "violet", + "blue", + "cyan", + "dark_green", + "green", + "yellow", + "orange", + "red", + "magenta" +} + +local sofa_table = { --name, color, colorize(hex or color name:intensity(1-255)) +{'Black', 'black', 'black:225'}, +{'Blue', 'blue', 'blue:225'}, +{'Brown', 'brown', 'brown:225'}, +{'Cyan', 'cyan', 'cyan:200'}, +{'Dark Green', 'dark_green', 'green:225'}, +{'Dark Grey', 'dark_grey', 'black:200'}, +{'Green', 'green', '#32cd32:150'}, +{'Grey', 'grey', 'black:100'}, +{'Magenta', 'magenta', 'magenta:200'}, +{'Orange', 'orange', 'orange:225'}, +{'Pink', 'pink', 'pink:225'}, +{'Red', 'red', 'red:225'}, +{'Violet', 'violet', 'violet:225'}, +{'White', 'white', 'white:1'}, +{'Yellow', 'yellow', 'yellow:225'}, +} + +for i in ipairs (sofa_table) do + local name = sofa_table[i][1] + local color = sofa_table[i][2] + local hex = sofa_table[i][3] + +minetest.register_node('ma_pops_furniture:sofa_'..color, { + description = name..' Sofa', + drawtype = 'mesh', + mesh = 'FM_sofa.obj', + tiles = {'wool_'..color..'.png'}, + groups = {cracky=3, oddly_breakable_by_hand=2, flammable=1, furniture=1, fall_damage_add_percent=-80, bouncy=80}, + --inventory_image = 'mp_sofa.png^[colorize:'..hex, + paramtype = "light", + paramtype2 = "facedir", + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, + selection_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, --Right, Bottom, Back, Left, Top, Front + {-.5, 0, .5, .5, .5, .2}, + {-.65, -.15, -.45, -.45, .3, .25}, --left + {.65, -.15, -.45, .45, .3, .25}, --right + }, + }, + collision_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, --base + {-.5, 0, .5, .5, .5, .2}, --back + {-.65, -.15, -.45, -.45, .3, .25}, --left + {.65, -.15, -.45, .45, .3, .25}, --right + }, + }, +}) + +minetest.register_node('ma_pops_furniture:sofa_l_'..color, { + description = name..' Sofa', + drawtype = 'mesh', + mesh = 'FM_sofa_l.obj', + tiles = {'wool_'..color..'.png'}, + groups = {cracky=3, oddly_breakable_by_hand=2, flammable=1, not_in_creative_inventory=1, fall_damage_add_percent=-80, bouncy=80}, + drop = 'ma_pops_furniture:sofa_'..color, + paramtype = "light", + paramtype2 = "facedir", + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + selection_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + {.65, -.15, -.45, .45, .3, .25}, + } + }, + collision_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + {.65, -.15, -.45, .45, .3, .25}, + } + }, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, +}) + +minetest.register_node('ma_pops_furniture:sofa_m_'..color, { + description = name..' Sofa', + drawtype = 'mesh', + mesh = 'FM_sofa_m.obj', + tiles = {'wool_'..color..'.png'}, + groups = {cracky=3, oddly_breakable_by_hand=2, flammable=1, not_in_creative_inventory=1, fall_damage_add_percent=-80, bouncy=80}, + drop = 'ma_pops_furniture:sofa_'..color, + paramtype = "light", + paramtype2 = "facedir", + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + selection_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + } + }, + collision_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + } + }, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, +}) + +minetest.register_node('ma_pops_furniture:sofa_r_'..color, { + description = name..' Sofa', + drawtype = 'mesh', + mesh = 'FM_sofa_r.obj', + tiles = {'wool_'..color..'.png'}, + groups = {cracky=3, oddly_breakable_by_hand=2, flammable=1, not_in_creative_inventory=1, fall_damage_add_percent=-80, bouncy=80}, + drop = 'ma_pops_furniture:sofa_'..color, + paramtype = "light", + paramtype2 = "facedir", + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + selection_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + {-.65, -.15, -.45, -.45, .3, .25}, + } + }, + collision_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + {-.65, -.15, -.45, -.45, .3, .25}, + } + }, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end, +}) + +minetest.register_node('ma_pops_furniture:sofa_c_'..color, { + description = name..' Sofa', + drawtype = 'mesh', + mesh = 'FM_sofa_c.obj', + tiles = {'wool_'..color..'.png'}, + groups = {cracky=3, oddly_breakable_by_hand=2, flammable=1, not_in_creative_inventory=1, furniture=1, fall_damage_add_percent=-80, bouncy=80}, + drop = 'ma_pops_furniture:sofa_'..color, + paramtype = "light", + paramtype2 = "facedir", + sounds = {wood = {name="furn_bouncy", gain=0.8}}, + selection_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, --bottom + {-.5, 0, .5, .5, .5, .2}, --back + {.2, 0, -.5, .5, .5, .2}, --side + } + }, + collision_box = { + type = 'fixed', + fixed = { + {-.5, -.5, -.5, .5, 0, .5}, + {-.5, 0, .5, .5, .5, .2}, + } + }, + on_rightclick = function(pos, node, clicker) + ma_pops_furniture.sit(pos, node, clicker) + end +}) +end \ No newline at end of file diff --git a/toaster.lua b/toaster.lua new file mode 100644 index 0000000..98a3743 --- /dev/null +++ b/toaster.lua @@ -0,0 +1,195 @@ +local S = ma_pops_furniture.intllib + +--Toaster and Toast-- +minetest.register_node("ma_pops_furniture:toaster", { + description = S("Toaster"), + tiles = { + "mp_toas_top.png", + "mp_toas_bottom.png", + "mp_toas_right.png", + "mp_toas_left.png", + "mp_toas_back.png", + "mp_toas_front.png" + }, + walkable = false, + groups = { snappy=3 }, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, + {-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, + }, + }, +}) + +minetest.override_item("farming:bread", { + description = S("Bread"), +}) + +local function breadslice_on_use(itemstack, user, pointed_thing) + local node, pos + if pointed_thing.under then + pos = pointed_thing.under + node = minetest.get_node(pos) + end + + local pname = user:get_player_name() + + if node and pos and (node.name == "ma_pops_furniture:toaster") then + if minetest.is_protected(pos, pname) then + minetest.record_protection_violation(pos, pname) + else + if itemstack:get_count() >= 2 then + itemstack:take_item(2) + minetest.set_node(pos, {name = "ma_pops_furniture:toaster_with_breadslice", param2 = node.param2}) + return itemstack + end + end + else + return minetest.do_item_eat(2, nil, itemstack, user, pointed_thing) + end +end + +if minetest.registered_items["farming:bread_slice"] then + minetest.override_item("farming:bread_slice", {on_use = breadslice_on_use }) + minetest.register_alias("ma_pops_furniture:breadslice", "farming:bread_slice") +else + minetest.register_craftitem("ma_pops_furniture:breadslice", { + description = S("Slice of Bread"), + inventory_image = "mp_breadslice.png", + groups = {flammable = 2}, + on_use = breadslice_on_use, + }) +end + +if minetest.registered_items["farming:toast"] then + minetest.register_alias("ma_pops_furniture:toast", "farming:toast") +else + minetest.register_craftitem("ma_pops_furniture:toast", { + description = S("Toast"), + inventory_image = "mp_toast.png", + on_use = minetest.item_eat(3), + groups = {flammable = 2}, + }) +end + +minetest.register_node("ma_pops_furniture:toaster_with_breadslice", { + description = S("Toaster with Breadslice"), + tiles = { + "mp_toas_top_bread.png", + "mp_toas_bottom.png", + "mp_toas_right_bread.png", + "mp_toas_left_bread.png", + "mp_toas_back_bread.png", + "mp_toas_front_bread.png" + }, + walkable = false, + groups = {not_in_creative_inventory=1}, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + diggable = false, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, -- NodeBox1 + {-0.25, -0.0625, 0.0625, 0.25, 0.0625, 0.125}, -- NodeBox2 + {-0.25, -0.0625, 0.1875, 0.25, 0.0625, 0.25}, -- NodeBox3 + {-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, -- NodeBox4 + }, + }, + on_punch = function(pos, node, clicker, itemstack, pointed_thing) + local fdir = node.param2 + minetest.set_node(pos, { name = "ma_pops_furniture:toaster_toasting_breadslice", param2 = fdir }) + minetest.after(6, minetest.set_node, pos, { name = "ma_pops_furniture:toaster_with_toast", param2 = fdir }) + minetest.sound_play("toaster", { + pos = pos, + gain = 1.0, + max_hear_distance = 5 + }) + return itemstack + end +}) + +minetest.register_node("ma_pops_furniture:toaster_toasting_breadslice", { + description = S("Toaster Toasting Slice of Bread"), + tiles = { + "mp_toas_top_bread_on.png", + "mp_toas_bottom.png", + "mp_toas_right_bread.png", + "mp_toas_left_toast_side.png", + "mp_toas_back_side.png", + "mp_toas_front_side.png" + }, + walkable = false, + groups = {not_in_creative_inventory = 1 }, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + diggable = false, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, -- NodeBox1 + {-0.4375, -0.375, 0.0625, -0.375, -0.3125, 0.25}, -- NodeBox4 + }, + }, +}) + +minetest.register_node("ma_pops_furniture:toaster_with_toast", { + description = S("Toaster with Toast"), + tiles = { + "mp_toas_top_toast.png", + "mp_toas_bottom.png", + "mp_toas_right_toast.png", + "mp_toas_left_toast.png", + "mp_toas_back_toast.png", + "mp_toas_front_toast.png" + }, + walkable = false, + groups = { snappy=3, not_in_creative_inventory=1 }, + paramtype = "light", + paramtype2 = "facedir", + is_ground_content = false, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.375, -0.5, 0, 0.375, -0.0625, 0.3125}, -- NodeBox1 + {-0.25, -0.0625, 0.0625, 0.25, 0.0625, 0.125}, -- NodeBox2 + {-0.25, -0.0625, 0.1875, 0.25, 0.0625, 0.25}, -- NodeBox3 + {-0.4375, -0.1875, 0.0625, -0.375, -0.125, 0.25}, -- NodeBox4 + }, + }, + on_punch = function (pos, node, player, pointed_thing) + local inv = player:get_inventory() + local left = inv:add_item("main", "ma_pops_furniture:toast 2") + if left:is_empty() then + minetest.set_node(pos, {name = "ma_pops_furniture:toaster", param2 = node.param2}) + end + end +}) + +minetest.register_craft({ + output = 'ma_pops_furniture:toaster', + recipe = { + {'','','',}, + {'default:steel_ingot','default:mese_crystal','default:steel_ingot',}, + {'default:steel_ingot','bucket:bucket_lava','default:steel_ingot',}, + } +}) + +--Slice of Bread (only if not farming one used) +if not minetest.registered_items["farming:bread_slice"] then + minetest.register_craft({ + output = 'ma_pops_furniture:breadslice 2', + type = "shapeless", + recipe = {"farming:bread"} + }) +end \ No newline at end of file diff --git a/tools.lua b/tools.lua new file mode 100644 index 0000000..c4e187b --- /dev/null +++ b/tools.lua @@ -0,0 +1,129 @@ +local USES = 200 --how many times you can use the tool before it breaks. + +minetest.register_tool('ma_pops_furniture:hammer', { + description = 'Hammer', + inventory_image = 'mp_hammer.png', + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= 'node' then + return + end + local pos = pointed_thing.under + local node = minetest.get_node(pos) + local sofa_table = { + {'black'}, + {'blue'}, + {'brown'}, + {'cyan'}, + {'dark_green'}, + {'dark_grey'}, + {'green'}, + {'grey'}, + {'magenta'}, + {'orange'}, + {'pink'}, + {'red'}, + {'violet'}, + {'white'}, + {'yellow'}, + } + + for i in ipairs (sofa_table) do + local color = sofa_table[i][1] + + if node.name == 'ma_pops_furniture:sofa_'..color then + minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_r_'..color, param2=node.param2}) + end + if node.name == 'ma_pops_furniture:sofa_r_'..color then + minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_m_'..color, param2=node.param2}) + end + if node.name == 'ma_pops_furniture:sofa_m_'..color then + minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_l_'..color, param2=node.param2}) + end + if node.name == 'ma_pops_furniture:sofa_l_'..color then + minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_c_'..color, param2=node.param2}) + end + if node.name == 'ma_pops_furniture:sofa_c_'..color then + minetest.set_node(pos,{name = 'ma_pops_furniture:sofa_'..color, param2=node.param2}) + end + end + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535 / (USES - 1)) + end + return itemstack + end, + + on_place = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= 'node' then + return + end + local pos = pointed_thing.under + local node = minetest.get_node(pos).name + local para = minetest.get_node(pos).param2 + local newpara = para + 1 + if newpara > 3 then + newpara = 0 + end + minetest.set_node(pos,{name = ""..node, param2 = newpara}) + + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535 / (USES - 1)) + end + return itemstack + end, +}) + +minetest.register_tool('ma_pops_furniture:shears', { + description = 'Shears', + inventory_image = 'mp_shears.png', + on_use = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= 'node' then + return + end + local pos = pointed_thing.under + local node = minetest.get_node(pos) + local hedge_table = { --material + {'leaves'}, + {'pine_needles'}, + {'jungleleaves'}, + {'aspen_leaves'}, + {'acacia_leaves'} + } + + for i in ipairs (hedge_table) do + local mat = hedge_table[i][1] + + if node.name == 'ma_pops_furniture:hedge_'..mat then + minetest.set_node(pos,{name = 'ma_pops_furniture:hedge_t_'..mat, param2=node.param2}) + end + if node.name == 'ma_pops_furniture:hedge_t_'..mat then + minetest.set_node(pos,{name = 'ma_pops_furniture:hedge_c_'..mat, param2=node.param2}) + end + if node.name == 'ma_pops_furniture:hedge_c_'..mat then + minetest.set_node(pos,{name = 'ma_pops_furniture:hedge_'..mat, param2=node.param2}) + end + end + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535 / (USES - 1)) + end + return itemstack + end, + + on_place = function(itemstack, user, pointed_thing) + if pointed_thing.type ~= 'node' then + return + end + local pos = pointed_thing.under + local node = minetest.get_node(pos).name + local para = minetest.get_node(pos).param2 + local newpara = para + 1 + if newpara > 3 then + newpara = 0 + end + minetest.set_node(pos,{name = ""..node, param2 = newpara}) + + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535 / (USES - 1)) + end + return itemstack + end, +})