[ADD] Add some files, and commit before brush up APIs

This commit is contained in:
tacigar 2016-09-13 14:51:23 +09:00
parent 5ec7455b1e
commit e93d43f5cb
6 changed files with 37 additions and 2 deletions

View File

@ -57,6 +57,17 @@ function maidroid.get_core(self)
return nil
end
-- maidroid.register_core registers a definition of a new core.
function maidroid.register_core(core_name, def)
maidroid.registered_cores[core_name] = def
minetest.register_craftitem(core_name, {
stack_max = 1,
description = def.description,
inventory_image = def.inventory_image,
})
end
-- maidroid.register_maidroid registers a definition of a new maidroid.
function maidroid.register_maidroid(product_name, def)
@ -69,7 +80,6 @@ function maidroid.register_maidroid(product_name, def)
if listname == "core" then
local core_name = stack:get_name()
local core = registered_cores[core_name]
core.initialize(self)
self.core_name = core_name
end
@ -88,7 +98,6 @@ function maidroid.register_maidroid(product_name, def)
on_take = function(inv, listname, index, stack, player)
if listname == "core" then
local core = registered_cores[self.core_name]
self.core_name = ""
core.finalize(self)
end

View File

@ -9,3 +9,4 @@ maidroid.modname = "maidroid"
maidroid.modpath = maidroid.get_modpath(maidroid.modname)
dofile(maidroid.modpath .. "/api.lua")
dofile(maidroid.modpath .. "/register.lua")

View File

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

25
maidroid/register.lua Normal file
View File

@ -0,0 +1,25 @@
------------------------------------------------------------
-- Copyright (c) 2016 tacigar
-- https://github.com/tacigar/maidroid
------------------------------------------------------------
maidroid.register_maidroid("maidroid:maidroid_mk1", {
hp_max = 10,
weight = 20,
mesh = "maidroid.b3d",
textures = "maidroid_mk1.png",
})
maidroid.register_maidroid("maidroid:maidroid_mk2", {
hp_max = 10,
weight = 20,
mesh = "maidroid.b3d",
textures = "maidroid_mk2.png",
})
maidroid.register_maidroid("maidroid:maidroid_mk3", {
hp_max = 10,
weight = 20,
mesh = "maidroid.b3d",
textures = "maidroid_mk3.png",
})