Added optional mod storage usage
parent
b7caf93195
commit
d45dcad91a
79
init.lua
79
init.lua
|
@ -4,7 +4,12 @@ price={},
|
||||||
result={}
|
result={}
|
||||||
}
|
}
|
||||||
|
|
||||||
--local storage = minetest.get_mod_storage()
|
--Default false, if true uses mod storage
|
||||||
|
local use_mod_storage = false
|
||||||
|
|
||||||
|
if use_mod_storage == true then
|
||||||
|
plastic_printer_storage = minetest.get_mod_storage()
|
||||||
|
end
|
||||||
|
|
||||||
--Functions
|
--Functions
|
||||||
local function can_dig(pos, player)--Prevent a loss of items by accident
|
local function can_dig(pos, player)--Prevent a loss of items by accident
|
||||||
|
@ -66,10 +71,13 @@ function plastic_printer_data:register_blueprint(item, description, cost, drawin
|
||||||
groups = {printer_blueprint=1},
|
groups = {printer_blueprint=1},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
--storage:set_string(item.."_blueprint cost", "basic_materials:plastic_sheet "..cost)
|
if use_mod_storage == true then
|
||||||
--storage:set_string(item.."_blueprint item", item)
|
plastic_printer_storage:set_string(item.."_blueprint cost", "basic_materials:plastic_sheet "..cost)
|
||||||
blueprint_items.price[item.."_blueprint"] = "basic_materials:plastic_sheet "..cost
|
plastic_printer_storage:set_string(item.."_blueprint item", item)
|
||||||
blueprint_items.result[item.."_blueprint"] = item
|
else
|
||||||
|
blueprint_items.price[item.."_blueprint"] = "basic_materials:plastic_sheet "..cost
|
||||||
|
blueprint_items.result[item.."_blueprint"] = item
|
||||||
|
end
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = ":"..item.."_blueprint",
|
output = ":"..item.."_blueprint",
|
||||||
|
@ -193,39 +201,40 @@ minetest.register_node(":3d_printer:printer", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not (inv:is_empty("main") or inv:is_empty("material") or inv:is_empty("battery")) then
|
if not (inv:is_empty("main") or inv:is_empty("material") or inv:is_empty("battery")) then
|
||||||
--[[local plastic_cost = storage:get_string(blueprint_used.name.." cost")
|
if use_mod_storage == true then
|
||||||
local item_result = storage:get_string(blueprint_used.name.." item")
|
local plastic_cost = plastic_printer_storage:get_string(blueprint_used.name.." cost")
|
||||||
if not plastic_cost or not item_result then
|
local item_result = plastic_printer_storage:get_string(blueprint_used.name.." item")
|
||||||
minetest.chat_send_player(puncher:get_player_name(), "Blueprint data not found")
|
if not plastic_cost or not item_result then
|
||||||
return
|
minetest.chat_send_player(puncher:get_player_name(), "Blueprint data not found")
|
||||||
end]]
|
return
|
||||||
--[[if plastic_used.name.." "..plastic_count == plastic_cost then
|
end
|
||||||
--minetest.chat_send_player(puncher:get_player_name(), "second check")
|
if plastic_used.name.." "..plastic_count == plastic_cost then
|
||||||
if battery.name == "3d_printer:battery" then
|
--minetest.chat_send_player(puncher:get_player_name(), "second check")
|
||||||
--minetest.chat_send_player(puncher:get_player_name(), "third check")
|
if battery.name == "3d_printer:battery" then
|
||||||
inv:set_stack("material", 1, "")
|
--minetest.chat_send_player(puncher:get_player_name(), "third check")
|
||||||
inv:set_stack("result", 1, item_result)
|
inv:set_stack("material", 1, "")
|
||||||
battery.wear = battery.wear + (65535/10)
|
inv:set_stack("result", 1, item_result)
|
||||||
inv:set_stack("battery", 1, battery)
|
battery.wear = battery.wear + (65535/10)
|
||||||
|
inv:set_stack("battery", 1, battery)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(puncher:get_player_name(), "Lack of plastic/Excessive plastic")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(puncher:get_player_name(), plastic_used.name.." "..plastic_count)
|
--minetest.chat_send_player(puncher:get_player_name(), "first check")
|
||||||
minetest.chat_send_player(puncher:get_player_name(), plastic_cost)--Needs fixing
|
--minetest.chat_send_player(puncher:get_player_name(), plastic_used.name)
|
||||||
minetest.chat_send_player(puncher:get_player_name(), "Lack of plastic/Excessive plastic")
|
if plastic_used.name.." "..plastic_count == blueprint_items.price[blueprint_used.name] then
|
||||||
end]]
|
--minetest.chat_send_player(puncher:get_player_name(), "second check")
|
||||||
--minetest.chat_send_player(puncher:get_player_name(), "first check")
|
if battery.name == "3d_printer:battery" then
|
||||||
--minetest.chat_send_player(puncher:get_player_name(), plastic_used.name)
|
--minetest.chat_send_player(puncher:get_player_name(), "third check")
|
||||||
if plastic_used.name.." "..plastic_count == blueprint_items.price[blueprint_used.name] then
|
inv:set_stack("material", 1, "")
|
||||||
--minetest.chat_send_player(puncher:get_player_name(), "second check")
|
inv:set_stack("result", 1, blueprint_items.result[blueprint_used.name])
|
||||||
if battery.name == "3d_printer:battery" then
|
battery.wear = battery.wear + (65535/10)
|
||||||
--minetest.chat_send_player(puncher:get_player_name(), "third check")
|
inv:set_stack("battery", 1, battery)
|
||||||
inv:set_stack("material", 1, "")
|
end
|
||||||
inv:set_stack("result", 1, blueprint_items.result[blueprint_used.name])
|
else
|
||||||
battery.wear = battery.wear + (65535/10)
|
minetest.chat_send_player(puncher:get_player_name(), "Lack of plastic/Excessive plastic")
|
||||||
inv:set_stack("battery", 1, battery)
|
|
||||||
end
|
end
|
||||||
else
|
|
||||||
minetest.chat_send_player(puncher:get_player_name(), "Lack of plastic/Excessive plastic")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue