This commit is contained in:
flux 2022-11-27 10:27:09 -08:00
parent 0e797a847d
commit 51451c97c8
4 changed files with 32 additions and 20 deletions

View file

@ -2,7 +2,7 @@ name: pre-commit
on: [push, pull_request, workflow_dispatch]
jobs:
build:
check:
runs-on: ubuntu-latest
steps:
@ -12,11 +12,17 @@ jobs:
- name: install luarocks
run: sudo apt-get install -y luarocks
- name: add luarocks path
run: echo "$HOME/.luarocks/bin" >> $GITHUB_PATH
- name: luacheck install
run: luarocks install --local luacheck
- name: add luacheck path
run: echo "$HOME/.luarocks/bin" >> $GITHUB_PATH
- name: install cargo
run: sudo apt-get install -y cargo
- name: install stylua
run: cargo install stylua
- name: Install pre-commit
run: pip3 install pre-commit

View file

@ -5,7 +5,6 @@ repos:
- id: fix-byte-order-marker
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
args: [ --fix=lf ]
@ -15,5 +14,12 @@ repos:
name: luacheck
language: system
entry: luacheck
pass_filenames: false
args: [-q,.]
pass_filenames: true
types: [ file, lua ]
args: [ -q ]
- id: stylua
name: stylua
language: system
entry: stylua
pass_filenames: true
types: [ file, lua ]

View file

@ -38,7 +38,6 @@ minetest.register_chatcommand("run_in_book", {
function minetest.chat_send_player(name2, message)
if name == name2 then
table.insert(received_messages, minetest.strip_colors(futil.strip_translation(message)))
else
old_chat_send_player(name2, message)
end
@ -53,14 +52,16 @@ minetest.register_chatcommand("run_in_book", {
local text = table.concat(received_messages, "\n")
local written_book = ItemStack("default:book_written")
written_book:get_meta():from_table({fields = {
title = param,
owner = name,
description = S("\"@1\" by @2", param, name),
text = text,
page = 1,
page_max = math.ceil((#text:gsub("[^\n]", "") + 1) / 14)
}})
written_book:get_meta():from_table({
fields = {
title = param,
owner = name,
description = S('"@1" by @2', param, name),
text = text,
page = 1,
page_max = math.ceil((#text:gsub("[^\n]", "") + 1) / 14),
},
})
player:set_wielded_item(written_book)

View file

@ -3,29 +3,28 @@ local modpath = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
assert(
type(futil.version) == "number" and futil.version >= os.time({year = 2022, month = 10, day = 24}),
type(futil.version) == "number" and futil.version >= os.time({ year = 2022, month = 10, day = 24 }),
"please update futil"
)
book_runner = {
author = "flux",
license = "AGPL_v3",
version = os.time({year = 2022, month = 9, day = 30}),
version = os.time({ year = 2022, month = 9, day = 30 }),
fork = "flux",
modname = modname,
modpath = modpath,
S = S,
has = {
},
has = {},
log = function(level, messagefmt, ...)
return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...)))
end,
dofile = function(...)
return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua")
return dofile(table.concat({ modpath, ... }, DIR_DELIM) .. ".lua")
end,
}