mirror of
https://github.com/tacigar/maidroid.git
synced 2024-11-16 23:30:21 +01:00
Merge branch 'master' into tacigar/readme_ja
This commit is contained in:
commit
ab6232c85d
|
@ -250,15 +250,15 @@ end)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("maidroid:dummy_item", {
|
minetest.register_entity("maidroid:dummy_item", {
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
visual = "wielditem",
|
visual = "wielditem",
|
||||||
visual_size = {x = 0.025, y = 0.025},
|
visual_size = {x = 0.025, y = 0.025},
|
||||||
collisionbox = {0, 0, 0, 0, 0, 0},
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
physical = false,
|
physical = false,
|
||||||
textures = {"air"},
|
textures = {"air"},
|
||||||
on_activate = on_activate,
|
on_activate = on_activate,
|
||||||
on_step = on_step,
|
on_step = on_step,
|
||||||
itemname = "",
|
itemname = "",
|
||||||
})
|
})
|
||||||
end) ()
|
end) ()
|
||||||
|
|
||||||
|
|
13
maidroid/crafting.lua
Normal file
13
maidroid/crafting.lua
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
------------------------------------------------------------
|
||||||
|
-- Copyright (c) 2016 tacigar. All rights reserved.
|
||||||
|
-- https://github.com/tacigar/maidroid
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
||||||
|
minetest.register_craft{
|
||||||
|
output = "maidroid:empty_egg",
|
||||||
|
recipe = {
|
||||||
|
{"default:bronze_ingot", "default:bronze_ingot", "default:bronze_ingot"},
|
||||||
|
{"default:bronze_ingot", "default:steel_ingot", "default:bronze_ingot"},
|
||||||
|
{"default:bronze_ingot", "default:bronze_ingot", "default:bronze_ingot"},
|
||||||
|
},
|
||||||
|
}
|
|
@ -10,3 +10,4 @@ maidroid.modpath = minetest.get_modpath(maidroid.modname)
|
||||||
|
|
||||||
dofile(maidroid.modpath .. "/api.lua")
|
dofile(maidroid.modpath .. "/api.lua")
|
||||||
dofile(maidroid.modpath .. "/register.lua")
|
dofile(maidroid.modpath .. "/register.lua")
|
||||||
|
dofile(maidroid.modpath .. "/crafting.lua")
|
||||||
|
|
|
@ -72,8 +72,10 @@ function maidroid_tool.register_writer(nodename, options)
|
||||||
local main_name = main_list[1]:get_name()
|
local main_name = main_list[1]:get_name()
|
||||||
|
|
||||||
if main_name == empty_itemname and (not fuel_list[1]:is_empty()) and (not dye_list[1]:is_empty()) then
|
if main_name == empty_itemname and (not fuel_list[1]:is_empty()) and (not dye_list[1]:is_empty()) then
|
||||||
|
local output = dye_item_map[dye_list[1]:get_name()]
|
||||||
|
|
||||||
meta:set_string("time", 0)
|
meta:set_string("time", 0)
|
||||||
meta:set_string("output", dye_item_map[dye_list[1]:get_name()])
|
meta:set_string("output", output)
|
||||||
|
|
||||||
local fuel_stack = fuel_list[1]
|
local fuel_stack = fuel_list[1]
|
||||||
fuel_stack:take_item()
|
fuel_stack:take_item()
|
||||||
|
@ -86,7 +88,7 @@ function maidroid_tool.register_writer(nodename, options)
|
||||||
swap_node(pos, nodename .. "_active")
|
swap_node(pos, nodename .. "_active")
|
||||||
|
|
||||||
if on_activate ~= nil then -- call on_activate callback.
|
if on_activate ~= nil then -- call on_activate callback.
|
||||||
on_activate(pos)
|
on_activate(pos, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ minetest.register_craft{
|
||||||
minetest.register_craft{
|
minetest.register_craft{
|
||||||
output = "maidroid_tool:egg_writer",
|
output = "maidroid_tool:egg_writer",
|
||||||
recipe = {
|
recipe = {
|
||||||
{ "default:diamond", "default:diamond", "default:diamond"},
|
{ "default:diamond", "bucket:bucket_water", "default:diamond"},
|
||||||
{ "default:cobble", "default:steel_ingot", "default:cobble"},
|
{ "default:cobble", "default:steel_ingot", "default:cobble"},
|
||||||
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
|
{"default:steel_ingot", "default:cobble", "default:steel_ingot"},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
bucket
|
||||||
default
|
default
|
||||||
dye
|
dye
|
||||||
maidroid
|
maidroid
|
||||||
|
|
|
@ -3,35 +3,14 @@
|
||||||
-- https://github.com/tacigar/maidroid
|
-- https://github.com/tacigar/maidroid
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
|
|
||||||
local dye_item_map = {
|
do -- register egg writer
|
||||||
["dye:red"] = "maidroid:maidroid_mk1_egg",
|
|
||||||
}
|
|
||||||
|
|
||||||
local formspec = { -- want to change.
|
local dye_item_map = {
|
||||||
["inactive"] = "size[8,9]"
|
["dye:red"] = "maidroid:maidroid_mk1_egg",
|
||||||
.. default.gui_bg
|
}
|
||||||
.. default.gui_bg_img
|
|
||||||
.. default.gui_slots
|
|
||||||
.. "label[3.75,0;Egg]"
|
|
||||||
.. "list[current_name;main;3.5,0.5;1,1;]"
|
|
||||||
.. "label[2.75,2;Coal]"
|
|
||||||
.. "list[current_name;fuel;2.5,2.5;1,1;]"
|
|
||||||
.. "label[4.75,2;Dye]"
|
|
||||||
.. "list[current_name;dye;4.5,2.5;1,1;]"
|
|
||||||
.. "image[3.5,1.5;1,2;maidroid_tool_gui_arrow.png]"
|
|
||||||
.. "image[3.1,3.5;2,1;maidroid_tool_gui_meter.png^[transformR270]"
|
|
||||||
.. "list[current_player;main;0,5;8,1;]"
|
|
||||||
.. "list[current_player;main;0,6.2;8,3;8]",
|
|
||||||
|
|
||||||
["active"] = function(time)
|
local formspec = { -- want to change.
|
||||||
local arrow_percent = (100 / 40) * time
|
["inactive"] = "size[8,9]"
|
||||||
local merter_percent = 0
|
|
||||||
if time % 16 >= 8 then
|
|
||||||
meter_percent = (8 - (time % 8)) * (100 / 8)
|
|
||||||
else
|
|
||||||
meter_percent = (time % 8) * (100 / 8)
|
|
||||||
end
|
|
||||||
return "size[8,9]"
|
|
||||||
.. default.gui_bg
|
.. default.gui_bg
|
||||||
.. default.gui_bg_img
|
.. default.gui_bg_img
|
||||||
.. default.gui_slots
|
.. default.gui_slots
|
||||||
|
@ -41,53 +20,248 @@ local formspec = { -- want to change.
|
||||||
.. "list[current_name;fuel;2.5,2.5;1,1;]"
|
.. "list[current_name;fuel;2.5,2.5;1,1;]"
|
||||||
.. "label[4.75,2;Dye]"
|
.. "label[4.75,2;Dye]"
|
||||||
.. "list[current_name;dye;4.5,2.5;1,1;]"
|
.. "list[current_name;dye;4.5,2.5;1,1;]"
|
||||||
.. "image[3.5,1.5;1,2;maidroid_tool_gui_arrow.png^[lowpart:"
|
.. "image[3.5,1.5;1,2;maidroid_tool_gui_arrow.png]"
|
||||||
.. arrow_percent
|
.. "image[3.1,3.5;2,1;maidroid_tool_gui_meter.png^[transformR270]"
|
||||||
.. ":maidroid_tool_gui_arrow_filled.png]"
|
|
||||||
.. "image[3.1,3.5;2,1;maidroid_tool_gui_meter.png^[lowpart:"
|
|
||||||
.. meter_percent
|
|
||||||
.. ":maidroid_tool_gui_meter_filled.png^[transformR270]"
|
|
||||||
.. "list[current_player;main;0,5;8,1;]"
|
.. "list[current_player;main;0,5;8,1;]"
|
||||||
.. "list[current_player;main;0,6.2;8,3;8]"
|
.. "list[current_player;main;0,6.2;8,3;8]",
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
local tiles = {
|
["active"] = function(time)
|
||||||
["active"] = {
|
local arrow_percent = (100 / 40) * time
|
||||||
"default_stone.png",
|
local merter_percent = 0
|
||||||
},
|
if time % 16 >= 8 then
|
||||||
|
meter_percent = (8 - (time % 8)) * (100 / 8)
|
||||||
|
else
|
||||||
|
meter_percent = (time % 8) * (100 / 8)
|
||||||
|
end
|
||||||
|
return "size[8,9]"
|
||||||
|
.. default.gui_bg
|
||||||
|
.. default.gui_bg_img
|
||||||
|
.. default.gui_slots
|
||||||
|
.. "label[3.75,0;Egg]"
|
||||||
|
.. "list[current_name;main;3.5,0.5;1,1;]"
|
||||||
|
.. "label[2.75,2;Coal]"
|
||||||
|
.. "list[current_name;fuel;2.5,2.5;1,1;]"
|
||||||
|
.. "label[4.75,2;Dye]"
|
||||||
|
.. "list[current_name;dye;4.5,2.5;1,1;]"
|
||||||
|
.. "image[3.5,1.5;1,2;maidroid_tool_gui_arrow.png^[lowpart:"
|
||||||
|
.. arrow_percent
|
||||||
|
.. ":maidroid_tool_gui_arrow_filled.png]"
|
||||||
|
.. "image[3.1,3.5;2,1;maidroid_tool_gui_meter.png^[lowpart:"
|
||||||
|
.. meter_percent
|
||||||
|
.. ":maidroid_tool_gui_meter_filled.png^[transformR270]"
|
||||||
|
.. "list[current_player;main;0,5;8,1;]"
|
||||||
|
.. "list[current_player;main;0,6.2;8,3;8]"
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
["inactive"] = {
|
local tiles = {
|
||||||
"default_stone.png",
|
["active"] = {
|
||||||
},
|
"maidroid_tool_egg_writer_top.png",
|
||||||
}
|
"maidroid_tool_egg_writer_bottom.png",
|
||||||
|
"maidroid_tool_egg_writer_right.png",
|
||||||
|
"maidroid_tool_egg_writer_right.png^[transformFX",
|
||||||
|
{
|
||||||
|
backface_culling = false,
|
||||||
|
image = "maidroid_tool_egg_writer_front_active.png^[transformFX",
|
||||||
|
|
||||||
local node_box = {
|
animation = {
|
||||||
type = "fixed",
|
type = "vertical_frames",
|
||||||
fixed = {
|
aspect_w = 16,
|
||||||
{ -0.5, -0.375, -0.4375, 0.5, 0.3125, 0.4375},
|
aspect_h = 16,
|
||||||
{-0.4375, -0.4375, -0.5, 0.4375, 0.25, 0.5},
|
length = 1.5,
|
||||||
{-0.3125, -0.5, -0.3125, 0.3125, -0.4375, 0.3125},
|
},
|
||||||
{ -0.375, 0.3125, -0.375, -0.3125, 0.375, 0.375},
|
},
|
||||||
{ 0.3125, 0.3125, -0.375, 0.375, 0.375, 0.375},
|
{
|
||||||
{ -0.125, -0.5, -0.0625, 0.125, 0.375, 0.0625},
|
backface_culling = false,
|
||||||
},
|
image = "maidroid_tool_egg_writer_front_active.png",
|
||||||
}
|
|
||||||
|
|
||||||
local selection_box = {
|
animation = {
|
||||||
type = "fixed",
|
type = "vertical_frames",
|
||||||
fixed = {
|
aspect_w = 16,
|
||||||
{-0.4375, -0.4375, -0.4375, 0.4375, -0.4375, 0.4375},
|
aspect_h = 16,
|
||||||
},
|
length = 1.5,
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
maidroid_tool.register_writer("maidroid_tool:egg_writer", {
|
["inactive"] = {
|
||||||
description = "maidroid tool : egg writer",
|
"maidroid_tool_egg_writer_top.png",
|
||||||
formspec = formspec,
|
"maidroid_tool_egg_writer_bottom.png",
|
||||||
tiles = tiles,
|
"maidroid_tool_egg_writer_right.png",
|
||||||
node_box = node_box,
|
"maidroid_tool_egg_writer_right.png^[transformFX",
|
||||||
selection_box = selection_box,
|
"maidroid_tool_egg_writer_front.png^[transformFX",
|
||||||
duration = 40,
|
"maidroid_tool_egg_writer_front.png",
|
||||||
empty_itemname = "maidroid:empty_egg",
|
},
|
||||||
dye_item_map = dye_item_map,
|
}
|
||||||
})
|
|
||||||
|
local node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.4375, -0.3125, -0.4375, -0.375, 0.4375, 0.4375},
|
||||||
|
{-0.4375, -0.3125, -0.4375, 0.4375, 0.4375, -0.375},
|
||||||
|
{ 0.375, -0.3125, -0.4375, 0.4375, 0.4375, 0.4375},
|
||||||
|
{-0.4375, -0.3125, 0.375, 0.4375, 0.4375, 0.4375},
|
||||||
|
{-0.4375, -0.25, -0.375, 0.4375, 0.25, 0.375},
|
||||||
|
{ -0.5, 0, -0.5, 0.5, 0.125, 0.5},
|
||||||
|
{ -0.25, -0.5, -0.3125, 0.25, -0.3125, 0.3125},
|
||||||
|
{-0.3125, -0.5, -0.25, 0.3125, -0.3125, 0.25},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.4375, -0.5, -0.4375, 0.4375, 0.4375, 0.4375},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local function get_nearest_egg_entity(pos)
|
||||||
|
local all_objects = minetest.get_objects_inside_radius(pos, 1.0)
|
||||||
|
for _, object in ipairs(all_objects) do
|
||||||
|
if object:get_luaentity().name == "maidroid_tool:egg_entity" then
|
||||||
|
return object:get_luaentity()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_deactivate(pos)
|
||||||
|
local egg_entity = get_nearest_egg_entity(pos)
|
||||||
|
egg_entity:stop_move()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_activate(pos, output)
|
||||||
|
local egg_entity = get_nearest_egg_entity(pos)
|
||||||
|
egg_entity.object:set_properties{textures={"maidroid:empty_egg"}}
|
||||||
|
egg_entity:start_move(output)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_metadata_inventory_put_to_main(pos)
|
||||||
|
local center_position = {
|
||||||
|
x = pos.x, y = pos.y + 0.25, z = pos.z
|
||||||
|
}
|
||||||
|
local egg_entity = minetest.add_entity(center_position, "maidroid_tool:egg_entity")
|
||||||
|
local lua_entity = egg_entity:get_luaentity()
|
||||||
|
lua_entity:initialize(center_position)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_metadata_inventory_take_from_main(pos)
|
||||||
|
local egg_entity = get_nearest_egg_entity(pos)
|
||||||
|
egg_entity.object:remove()
|
||||||
|
end
|
||||||
|
|
||||||
|
maidroid_tool.register_writer("maidroid_tool:egg_writer", {
|
||||||
|
description = "maidroid tool : egg writer",
|
||||||
|
formspec = formspec,
|
||||||
|
tiles = tiles,
|
||||||
|
node_box = node_box,
|
||||||
|
selection_box = selection_box,
|
||||||
|
duration = 40,
|
||||||
|
on_activate = on_activate,
|
||||||
|
on_deactivate = on_deactivate,
|
||||||
|
empty_itemname = "maidroid:empty_egg",
|
||||||
|
dye_item_map = dye_item_map,
|
||||||
|
on_metadata_inventory_put_to_main = on_metadata_inventory_put_to_main,
|
||||||
|
on_metadata_inventory_take_from_main = on_metadata_inventory_take_from_main,
|
||||||
|
})
|
||||||
|
|
||||||
|
end -- register egg writer
|
||||||
|
|
||||||
|
do -- register a definition of an egg entity
|
||||||
|
local function on_activate(self, staticdata)
|
||||||
|
self.object:set_properties{textures={"maidroid:empty_egg"}}
|
||||||
|
self.object:set_properties{automatic_rotate = 1}
|
||||||
|
|
||||||
|
if staticdata ~= "" then
|
||||||
|
local data = minetest.deserialize(staticdata)
|
||||||
|
|
||||||
|
self.is_moving = data["is_moving"]
|
||||||
|
self.center_position = data["center_position"]
|
||||||
|
self.output = data["output"]
|
||||||
|
self.current_egg = data["current_egg"]
|
||||||
|
|
||||||
|
self.object:set_properties{textures={self.current_egg}}
|
||||||
|
self:initialize(self.center_position)
|
||||||
|
|
||||||
|
if self.is_moving then
|
||||||
|
self:start_move()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.object:set_properties{textures={"maidroid:empty_egg"}}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function start_move(self, output)
|
||||||
|
self.is_moving = true
|
||||||
|
self.output = output
|
||||||
|
end
|
||||||
|
|
||||||
|
local function stop_move(self)
|
||||||
|
self.object:set_properties{textures={self.output}}
|
||||||
|
self.is_moving = false
|
||||||
|
self.current_egg = self.output
|
||||||
|
self.output = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_staticdata(self)
|
||||||
|
local data = {
|
||||||
|
["is_moving"] = self.is_moving,
|
||||||
|
["center_position"] = self.center_position,
|
||||||
|
["output"] = self.output,
|
||||||
|
["current_egg"] = self.current_egg,
|
||||||
|
}
|
||||||
|
return minetest.serialize(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_step(self, dtime)
|
||||||
|
if self.angle >= 360 then
|
||||||
|
self.angle = 0
|
||||||
|
else
|
||||||
|
self.angle = self.angle + 2
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.is_moving then
|
||||||
|
local length = 0.15
|
||||||
|
local new_position = vector.add(self.center_position, {
|
||||||
|
x = length * math.cos(self.angle * math.pi / 180.0),
|
||||||
|
y = math.sin(self.angle * math.pi / 180.0) * 0.025,
|
||||||
|
z = length * math.sin(self.angle * math.pi / 180.0),
|
||||||
|
})
|
||||||
|
self.object:setpos(new_position)
|
||||||
|
else
|
||||||
|
local cur_position = self.object:getpos()
|
||||||
|
local new_position = {
|
||||||
|
x = cur_position.x,
|
||||||
|
y = self.center_position.y + math.sin(self.angle * math.pi / 180.0) * 0.025,
|
||||||
|
z = cur_position.z,
|
||||||
|
}
|
||||||
|
self.object:setpos(new_position)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function initialize(self, pos)
|
||||||
|
self.angle = 0
|
||||||
|
self.center_position = pos
|
||||||
|
local init_pos = vector.add(pos, {x = 0.15, y = 0, z = 0})
|
||||||
|
self.object:setpos(init_pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_entity("maidroid_tool:egg_entity", {
|
||||||
|
hp_max = 1,
|
||||||
|
visual = "wielditem",
|
||||||
|
visual_size = {x = 0.2, y = 0.2},
|
||||||
|
collisionbox = {0, 0, 0, 0, 0, 0},
|
||||||
|
physical = false,
|
||||||
|
on_activate = on_activate,
|
||||||
|
start_move = start_move,
|
||||||
|
stop_move = stop_move,
|
||||||
|
get_staticdata = get_staticdata,
|
||||||
|
on_step = on_step,
|
||||||
|
initialize = initialize,
|
||||||
|
output = "",
|
||||||
|
current_egg = "",
|
||||||
|
center_position = nil,
|
||||||
|
is_moving = false,
|
||||||
|
angle = 0,
|
||||||
|
})
|
||||||
|
end -- register egg entity
|
||||||
|
|
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_bottom.png
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 603 B |
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_bottom.xcf
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_bottom.xcf
Normal file
Binary file not shown.
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front.png
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 650 B |
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front.xcf
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front.xcf
Normal file
Binary file not shown.
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front_active.png
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front_active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 824 B |
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front_active.xcf
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_front_active.xcf
Normal file
Binary file not shown.
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_right.png
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 637 B |
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_right.xcf
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_right.xcf
Normal file
Binary file not shown.
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_top.png
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 728 B |
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_top.xcf
Normal file
BIN
maidroid_tool/textures/maidroid_tool_egg_writer_top.xcf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user