Added memory tool, improved recipes format to allow for multiple crafts, updated readme

master
entuland 2019-02-02 22:10:32 +01:00
parent d777debbe9
commit e456eb54ab
5 changed files with 121 additions and 30 deletions

View File

@ -16,6 +16,10 @@ A thin wrapper around a very useful library to deal with Matrices:
[matrix] https://github.com/entuland/lua-matrix
# Important
From version 1.3 recipes for all crafts can be customized in `custom.recipes.lua` - anytime you're upgrading this mod verify `default/recipes.lua` for new crafts or a different file format and update `custom.recipes.lua` accordingly.
# Main features
- for `facedir` and `colorfacedir` nodes:
@ -82,6 +86,14 @@ The `push` interaction area is not limited to the edges you can see in the Testi
Nodes that don't occupy a full cube (such as slabs and stairs) can still be rotated properly, it's enough that you pay attention to the direction of the part you're pointing at - the "stomp" parts of the stairs, for example, will behave as the "top" face, the "rise" parts will behave as the "front" face. With the Rhotator Screwdriver there never really is a "top" or a "front" or whatever: the only thing that matters is the face you're pointing at.
# Rotation memory and the Memory Tool
Anytime you rotate a node with the Rhotator Screwdriver the resulting rotation gets stored, and any subsequent nodes you'll place will be rotated according to that rotation (assuming you have rotation memory on).
In addition to the [Chat commands](#chat-commands) you can use the Memory Tool to toggle memory on and off and to copy rotation from supported nodes.
In the Memory Tool the letters `TG` stand for `toggle memory`, using the left click, the letters `CP` stand for `copy rotation`, using the right click.
# Crafting
Rhotator Screwdriver: a stick and a copper ingot;
@ -92,7 +104,11 @@ Rhotator Screwdriver Alt: two sticks and a copper ingot;
![Rhotator Screwdriver Alt crafting](/screenshots/rhotator-alt-recipe.png)
Rhotator Testing Cube: a Rhotator Screwdriver and any wool block
Rhotator Memory Tool: again two sticks and a copper ingot, in a different pattern;
![Rhotator Memory Tool crafting](/screenshots/rhotator-memory-recipe.png)
Rhotator Testing Cube: any of the screwdriver tools and any wool block
![Rhotator Testing Cube crafting](/screenshots/rhotator-cube-recipe.png)

View File

@ -4,16 +4,47 @@
-- the original versions are in "default/recipes.lua"
return {
["rhotator:screwdriver"] = {
{"default:copper_ingot"},
{"group:stick"},
},
["rhotator:screwdriver_alt"] = {
{"default:copper_ingot", "group:stick"},
{"group:stick", ""},
},
["rhotator:cube"] = {
{"group:wool"},
{"rhotator:screwdriver"},
},
{
output = "rhotator:screwdriver",
recipe = {
{"default:copper_ingot"},
{"group:stick"},
},
},
{
output = "rhotator:screwdriver_alt",
recipe = {
{"default:copper_ingot", "group:stick"},
{"group:stick", ""},
},
},
{
output = "rhotator:memory",
recipe = {
{"group:stick"},
{"default:copper_ingot"},
{"group:stick"},
},
},
{
output = "rhotator:cube",
recipe = {
{"group:wool"},
{"rhotator:screwdriver"},
},
},
{
output = "rhotator:cube",
recipe = {
{"group:wool"},
{"rhotator:screwdriver_alt"},
},
},
{
output = "rhotator:cube",
recipe = {
{"group:wool"},
{"rhotator:memory"},
},
},
}

View File

@ -454,13 +454,55 @@ local function interact(player, pointed_thing, click)
end
local function primary_callback(itemstack, player, pointed_thing)
interact(player, pointed_thing, PRIMARY_BTN)
return itemstack
interact(player, pointed_thing, PRIMARY_BTN)
return itemstack
end
local function secondary_callback(itemstack, player, pointed_thing)
interact(player, pointed_thing, SECONDARY_BTN)
return itemstack
interact(player, pointed_thing, SECONDARY_BTN)
return itemstack
end
local function toggle_memory_callback(itemstack, player, pointed_thing)
local playername = player:get_player_name()
local key = "memory_" .. playername
local memory = storage:get_int(key) == 1
if memory then
storage:set_int(key, 0)
memory = false
else
storage:set_int(key, 1)
memory = true
end
notify(playername, "Memory is " .. (memory and "on" or "off"))
return itemstack
end
local function copy_rotation_callback(itemstack, player, pointed_thing)
local playername = player:get_player_name()
if pointed_thing.type ~= "node" then
return
end
local pos = pointed_thing.under
local node = minetest.get_node(pointed_thing.under)
local nodedef = minetest.registered_nodes[node.name]
if not nodedef then
notify.error(player, "Unsupported node type: " .. node.name)
return
end
local paramtype2 = nodedef.paramtype2
if paramtype2 ~= "facedir" and paramtype2 ~= "colorfacedir" then
notify.warning(player, "Unsupported node type: " .. node.name .. " - cannot copy rotation")
return
end
local rotation = node.param2 % 32 -- get first 5 bits
facedir_memory[playername] = rotation
notify(player, "Copied rotation from node: " .. node.name)
return itemstack
end
minetest.register_tool("rhotator:screwdriver", {
@ -477,6 +519,13 @@ minetest.register_tool("rhotator:screwdriver_alt", {
on_place = primary_callback,
})
minetest.register_tool("rhotator:memory", {
description = "Rhotator Memory Tool\nLeft-click toggles rotation memory\nRight-click copies rotation from pointed node",
inventory_image = "rhotator-memory.png",
on_use = toggle_memory_callback,
on_place = copy_rotation_callback,
})
minetest.register_node("rhotator:cube", {
drawtype = "mesh",
mesh = "rhotocube.obj",
@ -489,29 +538,24 @@ minetest.register_node("rhotator:cube", {
local full_recipes_filename = custom_or_default("rhotator", mod_path, "recipes.lua")
if not full_recipes_filename then
error("[rhotator] unable to find " .. mod_path .. "/custom.recipes.lua")
error("[rhotator] unable to find " .. mod_path .. "/custom.recipes.lua")
end
local recipes = dofile(full_recipes_filename);
if type(recipes) ~= "table" then
error("[rhotator] malformed file " .. mod_path .. "/custom.recipes.lua")
error("[rhotator] malformed file " .. mod_path .. "/custom.recipes.lua")
end
local expected_recipes = { "rhotator:screwdriver", "rhotator:screwdriver_alt", "rhotator:cube" }
for _, itemname in ipairs(expected_recipes) do
if type(recipes[itemname]) == "table" then
minetest.register_craft({
output = itemname,
recipe = recipes[itemname],
})
end
for _, item in ipairs(recipes) do
if type(item) == "table" and type(item.output) == "string" and type(item.recipe) == "table" then
minetest.register_craft(item)
end
end
minetest.register_on_placenode(rhotator_on_placenode)
minetest.register_chatcommand("rhotator", {
description = "memory [on|off]: displays or sets rotation memory for newly placed blocks",
func = rhotator.command
description = "memory [on|off]: displays or sets rotation memory for newly placed blocks",
func = rhotator.command
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B