mirror of
https://github.com/minetest-mods/moreblocks.git
synced 2025-02-22 21:10:23 +01:00
tweak some things
This commit is contained in:
parent
56e709e1ec
commit
e8324f5bf1
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@ -14,6 +14,9 @@ jobs:
|
|||||||
- name: install luacheck via luarocks
|
- name: install luacheck via luarocks
|
||||||
run: luarocks install --local luacheck
|
run: luarocks install --local luacheck
|
||||||
|
|
||||||
|
- name: luacheck invsaw
|
||||||
|
run: $HOME/.luarocks/bin/luacheck --config ./invsaw/.luacheckrc -q ./invsaw
|
||||||
|
|
||||||
- name: luacheck moreblocks
|
- name: luacheck moreblocks
|
||||||
run: $HOME/.luarocks/bin/luacheck --config ./moreblocks/.luacheckrc -q ./moreblocks
|
run: $HOME/.luarocks/bin/luacheck --config ./moreblocks/.luacheckrc -q ./moreblocks
|
||||||
|
|
||||||
|
@ -164,7 +164,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
|
|
||||||
- Initial versioned release.
|
- Initial versioned release.
|
||||||
|
|
||||||
[Unreleased]: https://github.com/minetest-mods/moreblocks/compare/v2.2.0...HEAD
|
[Unreleased]: https://github.com/minetest-mods/moreblocks/compare/v3.0.0...HEAD
|
||||||
|
|
||||||
|
[3.0.0]: https://github.com/minetest-mods/moreblocks/compare/v2.2.0...v3.0.0
|
||||||
|
|
||||||
[2.2.0]: https://github.com/minetest-mods/moreblocks/compare/v2.1.0...v2.2.0
|
[2.2.0]: https://github.com/minetest-mods/moreblocks/compare/v2.1.0...v2.2.0
|
||||||
|
|
||||||
|
@ -41,11 +41,17 @@ Stairs+ registrations for various mods which were formerly done automatically as
|
|||||||
|
|
||||||
## invsaw
|
## invsaw
|
||||||
|
|
||||||
|
Adds a button in unified_inventory that allows you to use the circular saw interface if you are
|
||||||
|
playing creatively, or have a circular saw item in your inventory and have the right priv
|
||||||
|
(`interact`, by default).
|
||||||
|
|
||||||
|
Invsaw was taken from [cheapie's invsaw mod](https://forum.minetest.net/viewtopic.php?t=14736), which
|
||||||
|
itself borrowed heavily from an older version of this mod. Flux decided to just add it here because it
|
||||||
|
needed to be fully rewritten to be compatible w/ their modifications to the stairsplus API.
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
|
|
||||||
## for plaers
|
## for players
|
||||||
|
|
||||||
## for admins
|
## for admins
|
||||||
|
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
invsaw
|
|
||||||
======
|
|
||||||
|
|
||||||
This mod adds a button in unified_inventory that opens a formspec that works exactly like the
|
|
||||||
moreblocks circular saw. It requires that either the server is in creative mode, you have the
|
|
||||||
"creative" priv, or you have one or more circular saws (moreblocks:circular_saw) in your inventory.
|
|
||||||
|
|
||||||
Dependencies: moreblocks, unified_inventory
|
|
||||||
|
|
||||||
Contains large amounts of code based on Calinou's moreblocks mod, and a texture based on some textures
|
|
||||||
from the same mod.
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
local server_is_creative = minetest.settings:get_bool("creative_mode", false)
|
||||||
|
|
||||||
function invsaw.has_saw_in_inventory(player)
|
function invsaw.has_saw_in_inventory(player)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
return inv:contains_item("main", invsaw.settings.saw_item)
|
return inv:contains_item("main", invsaw.settings.saw_item)
|
||||||
@ -5,6 +7,7 @@ end
|
|||||||
|
|
||||||
function invsaw.can_use_saw(player)
|
function invsaw.can_use_saw(player)
|
||||||
return (
|
return (
|
||||||
|
server_is_creative or
|
||||||
minetest.check_player_privs(player, invsaw.settings.creative_priv) or
|
minetest.check_player_privs(player, invsaw.settings.creative_priv) or
|
||||||
minetest.check_player_privs(player, invsaw.settings.priv)
|
minetest.check_player_privs(player, invsaw.settings.priv)
|
||||||
)
|
)
|
||||||
@ -12,6 +15,7 @@ end
|
|||||||
|
|
||||||
function invsaw.allow_use_saw(player)
|
function invsaw.allow_use_saw(player)
|
||||||
return (
|
return (
|
||||||
|
server_is_creative or
|
||||||
minetest.check_player_privs(player, invsaw.settings.creative_priv) or
|
minetest.check_player_privs(player, invsaw.settings.creative_priv) or
|
||||||
(minetest.check_player_privs(player, invsaw.settings.priv) and invsaw.has_saw_in_inventory(player))
|
(minetest.check_player_privs(player, invsaw.settings.priv) and invsaw.has_saw_in_inventory(player))
|
||||||
)
|
)
|
||||||
|
@ -10,22 +10,20 @@ local function on_priv_change(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function override_on_priv_change(old)
|
||||||
|
return function(name, cause)
|
||||||
|
on_priv_change(name)
|
||||||
|
if old then
|
||||||
|
old(name, cause)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.registered_privileges[priv] then
|
if minetest.registered_privileges[priv] then
|
||||||
local def = minetest.registered_privileges[priv]
|
local def = minetest.registered_privileges[priv]
|
||||||
local old_on_grant = def.on_grant
|
def.on_grant = override_on_priv_change(def.on_grant)
|
||||||
local old_on_revoke = def.on_revoke
|
def.on_revoke = override_on_priv_change(def.on_revoke)
|
||||||
def.on_grant = function(name, cause)
|
|
||||||
on_priv_change(name)
|
|
||||||
if old_on_grant then
|
|
||||||
old_on_grant(name, cause)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
def.on_revoke = function(name, cause)
|
|
||||||
on_priv_change(name)
|
|
||||||
if old_on_revoke then
|
|
||||||
old_on_revoke(name, cause)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
minetest.register_privilege(priv, {
|
minetest.register_privilege(priv, {
|
||||||
description = "Allow use of the circular saw in inventory",
|
description = "Allow use of the circular saw in inventory",
|
||||||
@ -38,20 +36,9 @@ end
|
|||||||
|
|
||||||
if minetest.registered_privileges[creative_priv] then
|
if minetest.registered_privileges[creative_priv] then
|
||||||
local def = minetest.registered_privileges[creative_priv]
|
local def = minetest.registered_privileges[creative_priv]
|
||||||
local old_on_grant = def.on_grant
|
def.on_grant = override_on_priv_change(def.on_grant)
|
||||||
local old_on_revoke = def.on_revoke
|
def.on_revoke = override_on_priv_change(def.on_revoke)
|
||||||
def.on_grant = function(name, cause)
|
|
||||||
on_priv_change(name)
|
|
||||||
if old_on_grant then
|
|
||||||
old_on_grant(name, cause)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
def.on_revoke = function(name, cause)
|
|
||||||
on_priv_change(name)
|
|
||||||
if old_on_revoke then
|
|
||||||
old_on_revoke(name, cause)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
minetest.register_privilege(creative_priv, {
|
minetest.register_privilege(creative_priv, {
|
||||||
description = "Allow use of the inventory saw creatively",
|
description = "Allow use of the inventory saw creatively",
|
||||||
|
7
luacheck.sh
Normal file
7
luacheck.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
luacheck --config ./invsaw/.luacheckrc -q ./invsaw
|
||||||
|
luacheck --config ./moreblocks/.luacheckrc -q ./moreblocks
|
||||||
|
luacheck --config ./stairsplus/.luacheckrc -q ./stairsplus
|
||||||
|
luacheck --config ./stairsplus_legacy/.luacheckrc -q ./stairsplus_legacy
|
||||||
|
|
@ -200,7 +200,15 @@ function station.initialize_inventory(inv)
|
|||||||
inv:set_size("stairsplus:input", 1)
|
inv:set_size("stairsplus:input", 1)
|
||||||
inv:set_size("stairsplus:micro", 1)
|
inv:set_size("stairsplus:micro", 1)
|
||||||
inv:set_size("stairsplus:recycle", 1)
|
inv:set_size("stairsplus:recycle", 1)
|
||||||
inv:set_size("stairsplus:output", 6 * 9)
|
inv:set_size("stairsplus:output", 7 * 7)
|
||||||
|
|
||||||
|
-- get rid of old lists
|
||||||
|
for _, listname in ipairs({"input", "micro", "recycle", "output"}) do
|
||||||
|
if inv:get_size(listname) > 0 then
|
||||||
|
inv:set_list(("stairsplus:%s"):format(listname), inv:get_list(listname))
|
||||||
|
inv:set_size(listname, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function station.on_construct(pos, shape_groups, build_formspec, update_infotext)
|
function station.on_construct(pos, shape_groups, build_formspec, update_infotext)
|
||||||
@ -271,6 +279,9 @@ function api.register_station(name, shape_groups, def)
|
|||||||
|
|
||||||
def._stairsplus_shape_groups = shape_groups
|
def._stairsplus_shape_groups = shape_groups
|
||||||
|
|
||||||
|
def.groups = table.copy(def.groups or {})
|
||||||
|
def.groups.stairsplus_station = 1
|
||||||
|
|
||||||
minetest.register_node(name, def)
|
minetest.register_node(name, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ local formspec_style = stairsplus.resources.formspec_style
|
|||||||
function circular_saw.build_formspec(meta, inv)
|
function circular_saw.build_formspec(meta, inv)
|
||||||
local inv_location = get_location_string(inv)
|
local inv_location = get_location_string(inv)
|
||||||
return ([[
|
return ([[
|
||||||
size[12,10]
|
size[12,11]
|
||||||
%s
|
%s
|
||||||
label[0,0;%s]
|
label[0,0;%s]
|
||||||
list[%s;stairsplus:input;1.7,0;1,1;]
|
list[%s;stairsplus:input;1.7,0;1,1;]
|
||||||
@ -25,8 +25,8 @@ function circular_saw.build_formspec(meta, inv)
|
|||||||
field[0.3,3.5;1,1;max_offered;%s:;%i]
|
field[0.3,3.5;1,1;max_offered;%s:;%i]
|
||||||
button[1,3.2;1.7,1;Set;%s]
|
button[1,3.2;1.7,1;Set;%s]
|
||||||
|
|
||||||
list[%s;stairsplus:output;2.8,0;9,6;]
|
list[%s;stairsplus:output;2.8,0;7,7;]
|
||||||
list[current_player;main;1.5,6.25;8,4;]
|
list[current_player;main;1.5,7.25;8,4;]
|
||||||
|
|
||||||
listring[%s;stairsplus:output]
|
listring[%s;stairsplus:output]
|
||||||
listring[current_player;main]
|
listring[current_player;main]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user