[FIX] Fix manufacturing data

This commit is contained in:
tacigar 2016-09-13 17:38:30 +09:00
parent 9b5924f299
commit 349837d5f1
3 changed files with 23 additions and 17 deletions

View File

@ -1,5 +1,5 @@
------------------------------------------------------------ ------------------------------------------------------------
-- Copyright (c) 2016 tacigar -- Copyright (c) 2016 tacigar. All rights reserved.
-- https://github.com/tacigar/maidroid -- https://github.com/tacigar/maidroid
------------------------------------------------------------ ------------------------------------------------------------
@ -75,7 +75,7 @@ maidroid.manufacturing_data = (function()
file:close() file:close()
end) end)
local file = io.open(file_name) local file = io.open(file_name, "r")
if file ~= nil then if file ~= nil then
local data = file:read("*a") local data = file:read("*a")
file:close() file:close()
@ -100,7 +100,9 @@ end
-- maidroid.register_maidroid registers a definition of a new maidroid. -- maidroid.register_maidroid registers a definition of a new maidroid.
function maidroid.register_maidroid(product_name, def) function maidroid.register_maidroid(product_name, def)
-- initialize manufacturing number of a new maidroid. -- initialize manufacturing number of a new maidroid.
maidroid.manufacturing_data[product_name] = 0 if maidroid.manufacturing_data[product_name] == nil then
maidroid.manufacturing_data[product_name] = 0
end
-- create_inventory creates a new inventory, and returns it. -- create_inventory creates a new inventory, and returns it.
function create_inventory(self) function create_inventory(self)
@ -155,6 +157,7 @@ function maidroid.register_maidroid(product_name, def)
if staticdata == "" then if staticdata == "" then
self.product_name = product_name self.product_name = product_name
self.manufacturing_number = maidroid.manufacturing_data[product_name] self.manufacturing_number = maidroid.manufacturing_data[product_name]
print(self.manufacturing_number, "KOKO")
maidroid.manufacturing_data[product_name] = maidroid.manufacturing_data[product_name] + 1 maidroid.manufacturing_data[product_name] = maidroid.manufacturing_data[product_name] + 1
create_inventory(self) create_inventory(self)
else else
@ -276,16 +279,19 @@ function maidroid.register_maidroid(product_name, def)
get_core_name = maidroid.maidroid.get_core_name, get_core_name = maidroid.maidroid.get_core_name,
}) })
minetest.register_craftitem(product_name .. "_spawner", { -- register a spawner for debugging maidroid mods.
description = product_name .. " spawner", if maidroid.debug_mode then
inventory_image = def.inventory_image, minetest.register_craftitem(product_name .. "_spawner", {
stack_max = 1, description = product_name .. " spawner",
on_use = function(item_stack, user, pointed_thing) inventory_image = "maidroid_debug_spawner.png",
if pointed_thing.above ~= nil then stack_max = 1,
minetest.add_entity(pointed_thing.above, product_name) on_use = function(item_stack, user, pointed_thing)
return itemstack if pointed_thing.above ~= nil then
end minetest.add_entity(pointed_thing.above, product_name)
return nil return itemstack
end, end
}) return nil
end,
})
end
end end

View File

@ -1,5 +1,5 @@
------------------------------------------------------------ ------------------------------------------------------------
-- Copyright (c) 2016 tacigar -- Copyright (c) 2016 tacigar. All rights reserved.
-- https://github.com/tacigar/maidroid -- https://github.com/tacigar/maidroid
------------------------------------------------------------ ------------------------------------------------------------

View File

@ -1,5 +1,5 @@
------------------------------------------------------------ ------------------------------------------------------------
-- Copyright (c) 2016 tacigar -- Copyright (c) 2016 tacigar. All rights reserved.
-- https://github.com/tacigar/maidroid -- https://github.com/tacigar/maidroid
------------------------------------------------------------ ------------------------------------------------------------