Compare commits
10 Commits
4767519f27
...
efd85fdc6e
Author | SHA1 | Date | |
---|---|---|---|
|
efd85fdc6e | ||
|
e8274a45f0 | ||
|
77269b864d | ||
|
184b290634 | ||
|
02951241de | ||
|
8d0a9bc42a | ||
|
902ed93831 | ||
|
d02b2d8d74 | ||
|
32c8a02f5a | ||
|
36c899364b |
10
.github/workflows/luacheck.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
name: luacheck
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
luacheck:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Luacheck
|
||||
uses: lunarmodules/luacheck@master
|
41
.gitignore
vendored
@ -1,41 +0,0 @@
|
||||
# Compiled Lua sources
|
||||
luac.out
|
||||
|
||||
# luarocks build files
|
||||
*.src.rock
|
||||
*.zip
|
||||
*.tar.gz
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.os
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
*.def
|
||||
*.exp
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
6
.luacheckrc
Normal file
@ -0,0 +1,6 @@
|
||||
unused_args = false
|
||||
|
||||
read_globals = {
|
||||
"minetest",
|
||||
"ItemStack"
|
||||
}
|
101
init.lua
@ -15,7 +15,7 @@ bulletin_boards.player_state = {}
|
||||
bulletin_boards.board_def = {}
|
||||
|
||||
local path = minetest.get_worldpath() .. "/bulletin_boards.lua"
|
||||
local f, e = loadfile(path);
|
||||
local f, _ = loadfile(path);
|
||||
if f then
|
||||
bulletin_boards.global_boards = f()
|
||||
else
|
||||
@ -58,7 +58,7 @@ local function find_next(board, start_index)
|
||||
index = index + 1
|
||||
if index > bulletin_max then
|
||||
index = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return index
|
||||
end
|
||||
@ -71,7 +71,7 @@ local function find_prev(board, start_index)
|
||||
index = index - 1
|
||||
if index < 1 then
|
||||
index = bulletin_max
|
||||
end
|
||||
end
|
||||
end
|
||||
return index
|
||||
end
|
||||
@ -92,21 +92,21 @@ local function find_most_cullable(board_name)
|
||||
local player_name = bulletin.owner
|
||||
local count = (player_count[player_name] or 0) + 1
|
||||
max_count = math.max(count, max_count)
|
||||
player_count[player_name] = count
|
||||
player_count[player_name] = count
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if total <= culling_min then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local max_players = {}
|
||||
for player_name, count in pairs(player_count) do
|
||||
if count == max_count then
|
||||
max_players[player_name] = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local most_cullable_index
|
||||
local most_cullable_timestamp
|
||||
for i = 1, bulletin_max do
|
||||
@ -118,7 +118,7 @@ local function find_most_cullable(board_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return most_cullable_index, most_cullable_timestamp
|
||||
end
|
||||
|
||||
@ -136,7 +136,7 @@ local function show_board(player_name, board_name)
|
||||
local formspec = {}
|
||||
local board = get_board(board_name)
|
||||
local current_time = minetest.get_gametime()
|
||||
|
||||
|
||||
local intervals = (current_time - board.last_culled)/culling_interval
|
||||
local cull_count, remaining_cull_time = math.modf(intervals)
|
||||
while cull_count > 0 do
|
||||
@ -149,20 +149,21 @@ local function show_board(player_name, board_name)
|
||||
end
|
||||
end
|
||||
board.last_culled = current_time - math.floor(culling_interval * remaining_cull_time)
|
||||
|
||||
|
||||
local def = bulletin_boards.board_def[board_name]
|
||||
local desc = def.desc
|
||||
local desc = minetest.formspec_escape(def.desc)
|
||||
local tip
|
||||
if def.cost then
|
||||
local stack = ItemStack(def.cost)
|
||||
tip = S("Post your bulletin here for the cost of @1 @2", stack:get_count(), get_item_desc(stack))
|
||||
desc = desc .. S(", Cost: @1 @2", stack:get_count(), get_item_desc(stack))
|
||||
else
|
||||
tip = S("Post your bulletin here")
|
||||
end
|
||||
|
||||
|
||||
formspec[#formspec+1] = "size[8,8.5]"
|
||||
.. "container[0,0]"
|
||||
.. "label[3.25,-0.25;"..minetest.formspec_escape(desc).."]"
|
||||
.. "label[0.0,-0.25;"..desc.."]"
|
||||
.. "container_end[]"
|
||||
.. "container[0,0.5]"
|
||||
local i = 0
|
||||
@ -176,7 +177,7 @@ local function show_board(player_name, board_name)
|
||||
short_title = short_title:sub(1, short_title_size) .. "..."
|
||||
end
|
||||
local img = bulletin.icon or ""
|
||||
|
||||
|
||||
formspec[#formspec+1] =
|
||||
"image_button["..x..",".. y*1.2 ..";1,1;"..img..";button_"..i..";]"
|
||||
.."label["..x..","..y*1.2-0.35 ..";"..minetest.formspec_escape(short_title).."]"
|
||||
@ -203,7 +204,7 @@ local function show_bulletin(player, board_name, index)
|
||||
local bulletin = board[index] or {}
|
||||
local player_name = player:get_player_name()
|
||||
bulletin_boards.player_state[player_name] = {board=board_name, index=index}
|
||||
|
||||
|
||||
local tip
|
||||
local has_cost
|
||||
if def.cost then
|
||||
@ -215,15 +216,15 @@ local function show_bulletin(player, board_name, index)
|
||||
tip = S("Post bulletin with this icon")
|
||||
has_cost = true
|
||||
end
|
||||
|
||||
|
||||
local admin = minetest.check_player_privs(player, "server")
|
||||
|
||||
|
||||
local formspec = {"size[8,8]"
|
||||
.."button[0.2,0;1,1;prev;"..S("Prev").."]"
|
||||
.."button[6.65,0;1,1;next;"..S("Next").."]"}
|
||||
local esc = minetest.formspec_escape
|
||||
if ((bulletin.owner == nil or bulletin.owner == player_name) and has_cost) or admin then
|
||||
formspec[#formspec+1] =
|
||||
formspec[#formspec+1] =
|
||||
"field[1.5,0.75;5.5,0;title;"..S("Title:")..";"..esc(bulletin.title or "").."]"
|
||||
.."textarea[0.5,1.15;7.5,7;text;"..S("Contents:")..";"..esc(bulletin.text or "").."]"
|
||||
.."label[0.3,7;"..S("Post:").."]"
|
||||
@ -235,7 +236,7 @@ local function show_bulletin(player, board_name, index)
|
||||
.."tooltip[delete;"..S("Delete this bulletin").."]"
|
||||
.."label["..(#icons+1)*0.75-0.25 ..",7;"..S("Delete:").."]"
|
||||
elseif bulletin.owner then
|
||||
formspec[#formspec+1] =
|
||||
formspec[#formspec+1] =
|
||||
"label[1.4,0.5;"..S("Posted by @1", bulletin.owner).."]"
|
||||
.."tablecolumns[color;text]"
|
||||
.."tableoptions[background=#00000000;highlight=#00000000;border=false]"
|
||||
@ -258,7 +259,7 @@ end
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "bulletin_boards:board" then return end
|
||||
local player_name = player:get_player_name()
|
||||
for field, state in pairs(fields) do
|
||||
for field, _ in pairs(fields) do
|
||||
if field:sub(1, #"button_") == "button_" then
|
||||
local i = tonumber(field:sub(#"button_"+1))
|
||||
local state = bulletin_boards.player_state[player_name]
|
||||
@ -266,8 +267,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
show_bulletin(player, state.board, i)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- interpret clicks on the bulletin
|
||||
@ -275,17 +276,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "bulletin_boards:bulletin" then return end
|
||||
local player_name = player:get_player_name()
|
||||
local state = bulletin_boards.player_state[player_name]
|
||||
if not state then return end
|
||||
if not state then return end
|
||||
local board = get_board(state.board)
|
||||
local def = bulletin_boards.board_def[state.board]
|
||||
if not board then return end
|
||||
|
||||
|
||||
-- no security needed on these actions
|
||||
if fields.back then
|
||||
bulletin_boards.player_state[player_name] = nil
|
||||
show_board(player_name, state.board)
|
||||
end
|
||||
|
||||
|
||||
if fields.prev then
|
||||
local next_index = find_prev(board, state.index)
|
||||
show_bulletin(player, state.board, next_index)
|
||||
@ -308,19 +309,19 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
-- someone's done something funny. Don't be accusatory, though - could be a race condition
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if fields.delete then
|
||||
board[state.index] = nil
|
||||
fields.title = ""
|
||||
save_boards()
|
||||
end
|
||||
|
||||
|
||||
local player_inventory = minetest.get_inventory({type="player", name=player_name})
|
||||
local has_cost = true
|
||||
if def.cost then
|
||||
has_cost = player_inventory:contains_item("main", def.cost)
|
||||
end
|
||||
|
||||
|
||||
if fields.text ~= "" and (has_cost or admin) then
|
||||
for field, _ in pairs(fields) do
|
||||
if field:sub(1, #"save_") == "save_" then
|
||||
@ -363,7 +364,7 @@ local base_icons = {
|
||||
local function generate_random_board(rez, count, icons)
|
||||
icons = icons or base_icons
|
||||
local tex = {"([combine:"..rez.."x"..rez}
|
||||
for i = 1, count do
|
||||
for _ = 1, count do
|
||||
tex[#tex+1] = ":"..math.random(1,rez-32)..","..math.random(1,rez-32)
|
||||
.."="..icons[math.random(1,#icons)]
|
||||
end
|
||||
@ -378,7 +379,9 @@ local function register_board(board_name, board_def)
|
||||
local tile = background.."^"..generate_random_board(98, 7, board_def.icons).."^"..foreground
|
||||
local bulletin_board_def = {
|
||||
description = board_def.desc,
|
||||
groups = {choppy=1},
|
||||
groups = {choppy=1, axey=1, handy=1},
|
||||
_mcl_hardness = 0.8,
|
||||
_mcl_blast_resistance = 1,
|
||||
tiles = {tile},
|
||||
inventory_image = tile,
|
||||
paramtype = "light",
|
||||
@ -396,7 +399,7 @@ local function register_board(board_name, board_def)
|
||||
local player_name = clicker:get_player_name()
|
||||
show_board(player_name, board_name)
|
||||
end,
|
||||
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", board_def.desc or "")
|
||||
@ -436,4 +439,38 @@ minetest.register_craft({
|
||||
{"default:copper_ingot", "default:copper_ingot", "default:copper_ingot"},
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if minetest.get_modpath("mcl_core") then
|
||||
register_board("bulletin_boards:wood", {
|
||||
desc = S("Public Bulletin Board"),
|
||||
cost = "mcl_core:paper",
|
||||
icons = base_icons,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bulletin_boards:wood",
|
||||
recipe = {
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
{'group:wood', 'mcl_core:paper', 'group:wood'},
|
||||
{'group:wood', 'group:wood', 'group:wood'},
|
||||
},
|
||||
})
|
||||
|
||||
if minetest.get_modpath("mcl_copper") then
|
||||
register_board("bulletin_boards:copper", {
|
||||
desc = S("Copper Board"),
|
||||
cost = "mcl_copper:copper_ingot",
|
||||
foreground = "bulletin_boards_frame_copper.png",
|
||||
icons = base_icons,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "bulletin_boards:copper",
|
||||
recipe = {
|
||||
{"mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot"},
|
||||
{"mcl_copper:copper_ingot", 'mcl_core:paper', "mcl_copper:copper_ingot"},
|
||||
{"mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot"},
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
18
locale/bulletin_boards.de.tr
Normal file
@ -0,0 +1,18 @@
|
||||
# textdomain: bulletin_boards
|
||||
Post your bulletin here for the cost of @1 @2=Schlage deinen Eintrag für @1 @2 an
|
||||
, Cost: @1 @2=, kostet: @1 @2
|
||||
Post your bulletin here=Schlage deinen Eintrag hier an
|
||||
@1@nPosted by @2@n@3 days ago=@1@nGepostet von @2@nvor @3 Tagen
|
||||
Post bulletin with this icon at the cost of @1 @2=Schlägt den Eintrag mit diesem Bild für @1 @2 an
|
||||
Post bulletin with this icon=Eintrag mit diesem Bild anschlagens
|
||||
Prev=Vorher
|
||||
Next=Nächste
|
||||
Title:=Titel:
|
||||
Contents:=Inhalt:
|
||||
Post:=Anschlagen:
|
||||
Delete this bulletin=Lösche diesen Eintrag
|
||||
Delete:=Löschen:
|
||||
Posted by @1=Angeschlagen von @1
|
||||
Back to Board=Zurück zum Brett
|
||||
Public Bulletin Board=Öffentliche Anschlagtafel
|
||||
Copper Board=Kupfernes Brett
|
18
locale/bulletin_boards.es.tr
Normal file
@ -0,0 +1,18 @@
|
||||
# textdomain: bulletin_boards
|
||||
Post your bulletin here for the cost of @1 @2=Publica tu boletín aqui al precio de @1 @2
|
||||
, Cost: @1 @2=, Precio: @1 @2
|
||||
Post your bulletin here=Publica tu boletín aqui
|
||||
@1@nPosted by @2@n@3 days ago=@1@nPublicado por @2 hace @n@3 días
|
||||
Post bulletin with this icon at the cost of @1 @2=Publicar este boletín con este ícono al precio de @1 @2
|
||||
Post bulletin with this icon=Publicar un boletín con este ícono
|
||||
Prev=Prev
|
||||
Next=Sig
|
||||
Title:=Título:
|
||||
Contents:=Contenidos:
|
||||
Post:=Publicar:
|
||||
Delete this bulletin=Borrar este boletín
|
||||
Delete:=Borrar:
|
||||
Posted by @1=Publicado por @1
|
||||
Back to Board=Volver al tablón
|
||||
Public Bulletin Board=Tablón publico de anuncios
|
||||
Copper Board=Tablón de Cobre
|
@ -1,87 +0,0 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-01-21 19:38-0700\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: init.lua:158
|
||||
msgid "Post your bulletin here for the cost of @1 @2"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:160
|
||||
msgid "Post your bulletin here"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:186
|
||||
msgid ""
|
||||
"@1\n"
|
||||
"Posted by @2\n"
|
||||
"@3 days ago"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:212
|
||||
msgid "Post bulletin with this icon at the cost of @1 @2"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:215
|
||||
msgid "Post bulletin with this icon"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:222
|
||||
msgid "Prev"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:223
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:227
|
||||
msgid "Title:"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:228
|
||||
msgid "Contents:"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:229
|
||||
msgid "Post:"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:235
|
||||
#: init.lua:247
|
||||
msgid "Delete this bulletin"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:236
|
||||
#: init.lua:248
|
||||
msgid "Delete:"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:239
|
||||
msgid "Posted by @1"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:244
|
||||
msgid "Back to Board"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:410
|
||||
msgid "Public Bulletin Board"
|
||||
msgstr ""
|
||||
|
||||
#: init.lua:416
|
||||
msgid "Copper Board"
|
||||
msgstr ""
|
18
locale/template.txt
Normal file
@ -0,0 +1,18 @@
|
||||
# textdomain: bulletin_boards
|
||||
Post your bulletin here for the cost of @1 @2=
|
||||
, Cost: @1 @2=
|
||||
Post your bulletin here=
|
||||
@1@nPosted by @2@n@3 days ago=
|
||||
Post bulletin with this icon at the cost of @1 @2=
|
||||
Post bulletin with this icon=
|
||||
Prev=
|
||||
Next=
|
||||
Title:=
|
||||
Contents:=
|
||||
Post:=
|
||||
Delete this bulletin=
|
||||
Delete:=
|
||||
Posted by @1=
|
||||
Back to Board=
|
||||
Public Bulletin Board=
|
||||
Copper Board=
|
@ -1,6 +0,0 @@
|
||||
@echo off
|
||||
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
|
||||
cd ..
|
||||
set LIST=
|
||||
for /r %%X in (*.lua) do set LIST=!LIST! %%X
|
||||
..\intllib\tools\xgettext.bat %LIST%
|
4
mod.conf
@ -1,3 +1,3 @@
|
||||
name=bulletin_boards
|
||||
name = bulletin_boards
|
||||
description = Allows creation of global bulletin boards where players can post public messages
|
||||
optional_depends = default
|
||||
optional_depends = default, mcl_core, mcl_copper
|
Before Width: | Height: | Size: 802 B After Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 832 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |