Merge pull request #24 from tacigar/tacigar/delete-disused-files
[DELETE] Delete disused files
162
api.lua
@ -1,162 +0,0 @@
|
|||||||
------------------------------------------------------------
|
|
||||||
-- Copyright (c) 2016 tacigar
|
|
||||||
-- https://github.com/tacigar/maidroid
|
|
||||||
------------------------------------------------------------
|
|
||||||
|
|
||||||
local _aux = maidroid._aux
|
|
||||||
|
|
||||||
-- aux function to generate serialnumber for inventories
|
|
||||||
local gen_inv_serialnumber = (function ()
|
|
||||||
local serialnumber = 0
|
|
||||||
return function ()
|
|
||||||
serialnumber = serialnumber + 1
|
|
||||||
return serialnumber - 1
|
|
||||||
end
|
|
||||||
end) ()
|
|
||||||
|
|
||||||
local main_invsize = 16
|
|
||||||
local main_invname = "main"
|
|
||||||
local module_invsize = 1
|
|
||||||
local module_invname = "module"
|
|
||||||
|
|
||||||
-- key = modulename, value = moduledef
|
|
||||||
maidroid.registered_modules = {}
|
|
||||||
|
|
||||||
function maidroid.register_module(module_name, def)
|
|
||||||
maidroid.registered_modules[module_name] = def
|
|
||||||
minetest.register_craftitem(module_name, {
|
|
||||||
description = def.description,
|
|
||||||
stack_max = 1,
|
|
||||||
inventory_image = def.inventory_image,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- animation frame
|
|
||||||
maidroid.animations = {
|
|
||||||
stand = {x = 0, y = 79},
|
|
||||||
lay = {x = 162, y = 166},
|
|
||||||
walk = {x = 168, y = 187},
|
|
||||||
mine = {x = 189, y = 198},
|
|
||||||
walk_mine = {x = 200, y = 219},
|
|
||||||
sit = {x = 81, y = 160},
|
|
||||||
}
|
|
||||||
|
|
||||||
function maidroid.register_maidroid(product_name, def)
|
|
||||||
minetest.register_entity(product_name, {
|
|
||||||
hp_max = def.hp_max or 1,
|
|
||||||
physical = true,
|
|
||||||
weight = def.weight or 5,
|
|
||||||
collistionbox = def.collistionbox or { -0.35, -0.5, -0.35, 0.35, 1.1, 0.35 },
|
|
||||||
visual = "mesh",
|
|
||||||
visual_size = {x = 10, y = 10},
|
|
||||||
mesh = def.mesh or "maidroid.b3d",
|
|
||||||
textures = def.textures or {"maidroid.png"},
|
|
||||||
is_visible = true,
|
|
||||||
makes_footstep_sound = true,
|
|
||||||
module = nil,
|
|
||||||
invname = "",
|
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
|
||||||
self.invname = "maidroid"..tostring(gen_inv_serialnumber())
|
|
||||||
local inv = minetest.create_detached_inventory(self.invname, {
|
|
||||||
on_put = function(inv, listname, index, stack, player)
|
|
||||||
if listname == module_invname then
|
|
||||||
local module_name = stack:get_name()
|
|
||||||
local module_def = maidroid.registered_modules[module_name]
|
|
||||||
self.module = module_def
|
|
||||||
module_def.initialize(self)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
allow_put = function(inv, listname, index, stack, player)
|
|
||||||
local item_name = stack:get_name()
|
|
||||||
local is_module = maidroid.registered_modules[item_name]
|
|
||||||
if listname == main_invname
|
|
||||||
or (listname == module_invname and is_module) then
|
|
||||||
return stack:get_count()
|
|
||||||
end
|
|
||||||
return 0
|
|
||||||
end,
|
|
||||||
on_take = function(inv, listname, index, stack, player)
|
|
||||||
if listname == module_invname then
|
|
||||||
local module_name = stack:get_name()
|
|
||||||
local module_def = maidroid.registered_modules[module_name]
|
|
||||||
self.module = nil
|
|
||||||
module_def.finalize(self)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
inv:set_size(main_invname, main_invsize)
|
|
||||||
inv:set_size(module_invname, module_invsize)
|
|
||||||
-- process staticdata
|
|
||||||
if staticdata ~= "" then
|
|
||||||
local data = minetest.deserialize(staticdata)
|
|
||||||
if data.inv.module ~= "" then
|
|
||||||
module_stack = ItemStack(data.inv.module)
|
|
||||||
module_stack:set_count(1)
|
|
||||||
inv:add_item(module_invname, module_stack)
|
|
||||||
self.module = maidroid.registered_modules[data.inv.module]
|
|
||||||
end
|
|
||||||
for _, item in ipairs(data.inv.main) do
|
|
||||||
local itemstack = ItemStack(item.name)
|
|
||||||
itemstack:set_count(item.count)
|
|
||||||
inv:add_item(main_invname, itemstack)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- initialize module
|
|
||||||
if self.module then self.module.initialize(self)
|
|
||||||
else
|
|
||||||
self.object:setvelocity{x = 0, y = 0, z = 0}
|
|
||||||
self.object:setacceleration{x = 0, y = -10, z = 0}
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
|
||||||
if self.module then self.module.on_step(self, dtime) end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
|
||||||
local formspec = "size[8,9]"
|
|
||||||
.."list[detached:"..self.invname..";"..main_invname..";0,0;4,4;]"
|
|
||||||
.."label[5,0;MODULE]"
|
|
||||||
.."list[detached:"..self.invname..";"..module_invname..";6,0;1,1;]"
|
|
||||||
.."list[current_player;"..main_invname..";0,5;8,1;]"
|
|
||||||
.."list[current_player;"..main_invname..";0,6.2;8,3;8]"
|
|
||||||
minetest.show_formspec(clicker:get_player_name(), self.invname, formspec)
|
|
||||||
end,
|
|
||||||
|
|
||||||
get_staticdata = function(self)
|
|
||||||
local inv = _aux.get_maidroid_inventory(self)
|
|
||||||
local staticdata = {}
|
|
||||||
staticdata.inv = {}
|
|
||||||
local module_name = inv:get_list(module_invname)[1]:get_name()
|
|
||||||
staticdata.inv.module = module_name or ""
|
|
||||||
staticdata.inv.main = {}
|
|
||||||
for _, item in ipairs(inv:get_list(main_invname)) do
|
|
||||||
local count = item:get_count()
|
|
||||||
local itemname = item:get_name()
|
|
||||||
if count ~= 0 then
|
|
||||||
local itemdata = { count = count, name = itemname }
|
|
||||||
table.insert(staticdata.inv.main, itemdata)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return minetest.serialize(staticdata)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- register spawn egg
|
|
||||||
minetest.register_craftitem(product_name.."_spawn_egg", {
|
|
||||||
description = def.description.." Spawn Egg",
|
|
||||||
inventory_image = def.inventory_image,
|
|
||||||
stack_max = 1,
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
|
||||||
if pointed_thing.above ~= nil then
|
|
||||||
minetest.add_entity(pointed_thing.above, product_name)
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
@ -3,8 +3,6 @@
|
|||||||
-- https://github.com/tacigar/maidroid
|
-- https://github.com/tacigar/maidroid
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
maidroid.debug_mode = true
|
|
||||||
|
|
||||||
-- maidroid.animation_frames represents the animation frame data
|
-- maidroid.animation_frames represents the animation frame data
|
||||||
-- of "models/maidroid.b3d".
|
-- of "models/maidroid.b3d".
|
||||||
maidroid.animation_frames = {
|
maidroid.animation_frames = {
|
||||||
@ -352,10 +350,9 @@ function maidroid.register_maidroid(product_name, def)
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- register a spawner for debugging maidroid mods.
|
-- register a spawner for debugging maidroid mods.
|
||||||
if maidroid.debug_mode then
|
|
||||||
minetest.register_craftitem(product_name .. "_spawner", {
|
minetest.register_craftitem(product_name .. "_spawner", {
|
||||||
description = product_name .. " spawner",
|
description = product_name .. " spawner",
|
||||||
inventory_image = "maidroid_debug_spawner.png",
|
inventory_image = def.inventory_image,
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
on_use = function(item_stack, user, pointed_thing)
|
on_use = function(item_stack, user, pointed_thing)
|
||||||
if pointed_thing.above ~= nil then
|
if pointed_thing.above ~= nil then
|
||||||
@ -366,4 +363,3 @@ function maidroid.register_maidroid(product_name, def)
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -8,6 +8,7 @@ maidroid.register_maidroid("maidroid:maidroid_mk1", {
|
|||||||
weight = 20,
|
weight = 20,
|
||||||
mesh = "maidroid.b3d",
|
mesh = "maidroid.b3d",
|
||||||
textures = {"maidroid_mk1.png"},
|
textures = {"maidroid_mk1.png"},
|
||||||
|
inventory_image = "maidroid_mk1_spawner.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
maidroid.register_maidroid("maidroid:maidroid_mk2", {
|
maidroid.register_maidroid("maidroid:maidroid_mk2", {
|
||||||
@ -15,6 +16,7 @@ maidroid.register_maidroid("maidroid:maidroid_mk2", {
|
|||||||
weight = 20,
|
weight = 20,
|
||||||
mesh = "maidroid.b3d",
|
mesh = "maidroid.b3d",
|
||||||
textures = {"maidroid_mk2.png"},
|
textures = {"maidroid_mk2.png"},
|
||||||
|
inventory_image = "maidroid_mk2_spawner.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
maidroid.register_maidroid("maidroid:maidroid_mk3", {
|
maidroid.register_maidroid("maidroid:maidroid_mk3", {
|
||||||
@ -22,4 +24,5 @@ maidroid.register_maidroid("maidroid:maidroid_mk3", {
|
|||||||
weight = 20,
|
weight = 20,
|
||||||
mesh = "maidroid.b3d",
|
mesh = "maidroid.b3d",
|
||||||
textures = {"maidroid_mk3.png"},
|
textures = {"maidroid_mk3.png"},
|
||||||
|
inventory_image = "maidroid_mk3_spawner.png",
|
||||||
})
|
})
|
||||||
|
0
textures/maidroid_maidroid.png → maidroid/textures/maidroid_mk1_spawner.png
Executable file → Normal file
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 233 B After Width: | Height: | Size: 233 B |
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 379 B |
Before Width: | Height: | Size: 385 B |
Before Width: | Height: | Size: 404 B |
Before Width: | Height: | Size: 409 B |
23
util.lua
@ -1,23 +0,0 @@
|
|||||||
------------------------------------------------------------
|
|
||||||
-- Copyright (c) 2016 tacigar
|
|
||||||
-- https://github.com/tacigar/maidroid
|
|
||||||
------------------------------------------------------------
|
|
||||||
|
|
||||||
maidroid.util = {}
|
|
||||||
|
|
||||||
-- check that the table has the value
|
|
||||||
function maidroid.util.table_find_value(tbl, value)
|
|
||||||
for k, v in ipairs(tbl) do
|
|
||||||
if v == value then return true, k end
|
|
||||||
end
|
|
||||||
return false, nil
|
|
||||||
end
|
|
||||||
|
|
||||||
-- table shallow copy
|
|
||||||
function maidroid.util.table_shallow_copy(source)
|
|
||||||
local copy = {}
|
|
||||||
for key, value in pairs(source) do
|
|
||||||
copy[key] = value
|
|
||||||
end
|
|
||||||
return copy
|
|
||||||
end
|
|