This commit is contained in:
commit
5c61b1aa93
19 changed files with 479 additions and 0 deletions
17
.github/workflows/luacheck.yml
vendored
Normal file
17
.github/workflows/luacheck.yml
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
name: luacheck
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: apt
|
||||
run: sudo apt-get install -y luarocks
|
||||
- name: luacheck install
|
||||
run: luarocks install --local luacheck
|
||||
- name: luacheck run
|
||||
run: $HOME/.luarocks/bin/luacheck ./
|
||||
22
.luacheckrc
Normal file
22
.luacheckrc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
globals = {
|
||||
"minetest",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
-- Builtin
|
||||
"vector", "ItemStack",
|
||||
"dump", "DIR_DELIM", "VoxelArea", "Settings",
|
||||
"PcgRandom",
|
||||
|
||||
-- MTG
|
||||
"default", "sfinv", "creative",
|
||||
|
||||
-- Deps
|
||||
"md2f"
|
||||
}
|
||||
40
README.md
Normal file
40
README.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# minenews
|
||||
|
||||
Localized and simple server news for Minetest servers. Original version by Shara
|
||||
RedCat, forked and improved by Ronoaldo.
|
||||
|
||||
[](https://content.minetest.net/packages/ronoaldo/minenews/)
|
||||
|
||||

|
||||
|
||||
This mod displays a formspec when the player joins. To set the news text to
|
||||
display, make a file named news_*lang_code*.md in your world directory for each
|
||||
locale you plan to support. The mod will fallback to a news.md file if no
|
||||
localized version is found.
|
||||
|
||||
The contents of this file will be displayed to the player, interpreted as
|
||||
Markdown. When changing the contents of the file, there is no need to restart
|
||||
the server for it to update in game so you can also test quickly the display.
|
||||
|
||||
Players can also type `/news` to display the formspec at any time.
|
||||
|
||||
Players with the `news_bypass` privilege will not see the formspec when they
|
||||
sign in, but can still use the `/news` command.
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
||||
Sample news dialog in English:
|
||||
|
||||

|
||||
|
||||
And a translated news file shown for the user if the language is set to `pt_BR`:
|
||||
|
||||

|
||||
|
||||
# License
|
||||
|
||||
Code for this mod is released under MIT (https://opensource.org/licenses/MIT).
|
||||
|
||||
This mod uses textures from Bootstrap Icons, also licensed under MIT
|
||||
(https://opensource.org/licenses/MIT).
|
||||
3
img/chat-text-fill.svg
Normal file
3
img/chat-text-fill.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-text-fill" viewBox="0 0 16 16">
|
||||
<path d="M16 8c0 3.866-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.584.296-1.925.864-4.181 1.234-.2.032-.352-.176-.273-.362.354-.836.674-1.95.77-2.966C.744 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7zM4.5 5a.5.5 0 0 0 0 1h7a.5.5 0 0 0 0-1h-7zm0 2.5a.5.5 0 0 0 0 1h7a.5.5 0 0 0 0-1h-7zm0 2.5a.5.5 0 0 0 0 1h4a.5.5 0 0 0 0-1h-4z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 473 B |
BIN
img/open-graph.png
Normal file
BIN
img/open-graph.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
BIN
img/open-graph.xcf
Normal file
BIN
img/open-graph.xcf
Normal file
Binary file not shown.
133
init.lua
Normal file
133
init.lua
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
--[[
|
||||
Minenews Mod by The-fast-the-curious
|
||||
https://github.com/The-fast-the-curious/minenews
|
||||
License: MIT
|
||||
|
||||
This mod displays server news to players on login, configurable via a markdown file.
|
||||
--]]
|
||||
|
||||
-- Register bypass priv
|
||||
minetest.register_privilege("news_bypass", {
|
||||
description = "Skip the news display on login.",
|
||||
give_to_singleplayer = false
|
||||
})
|
||||
|
||||
-- Create formspec from text file
|
||||
-- Returns the formspec string on success, or nil if news file is not found or empty
|
||||
local function get_formspec(name)
|
||||
-- Lookup player language preference
|
||||
local player_info = minetest.get_player_information(name)
|
||||
local lang = player_info.lang_code
|
||||
if lang == "" then
|
||||
lang = "en"
|
||||
end
|
||||
-- Lookup news file to display, trying by language first, with a default news.md
|
||||
-- fallback.
|
||||
local news_filename = minetest.get_worldpath().."/news_"..lang..".md"
|
||||
local news_file = io.open(news_filename, "r")
|
||||
if not news_file then
|
||||
news_filename = minetest.get_worldpath().."/news.md"
|
||||
news_file = io.open(news_filename, "r")
|
||||
end
|
||||
|
||||
local news = ""
|
||||
if news_file then
|
||||
news = news_file:read("*a")
|
||||
news_file:close()
|
||||
end
|
||||
|
||||
-- If no news content is found (file doesn't exist or is empty), return nil
|
||||
-- to prevent showing an empty formspec.
|
||||
if news == "" then
|
||||
if news_file then -- Only log if a file existed but was empty
|
||||
minetest.log("verbose", "News file found for player "..name.." but it is empty. No formspec will be shown.")
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
minetest.log("verbose", "Displaying news to player "..name.." in "..lang.." from file "..news_filename)
|
||||
|
||||
-- Settings
|
||||
local fg_color = minetest.settings:get("minenews.fg_color") or "#AFAFAF"
|
||||
local bg_color = minetest.settings:get("minenews.bg_color") or "#34343400"
|
||||
local header_color = minetest.settings:get("minenews.header_color") or "#CFCFCF"
|
||||
local mono_color = minetest.settings:get("minenews.mono_color") or "#6ED2CF"
|
||||
local discord_link = minetest.settings:get("minenews.discord_invite") or ""
|
||||
|
||||
-- Display the formspec for the server news
|
||||
local news_fs = "formspec_version[5]"..
|
||||
"size[24,16]"..
|
||||
"noprepend[]"..
|
||||
"bgcolor["..bg_color.."]"..
|
||||
"button_exit[20.8,14.8;3,1;close;OK]"
|
||||
|
||||
if discord_link ~= "" then
|
||||
news_fs = news_fs..
|
||||
"image[0.2,14.8;1,1;minenews_icon_chat_white.png]"..
|
||||
"field[1.3,14.8;19.2,1;discord_invite;;"..discord_link.."]"
|
||||
end
|
||||
|
||||
-- Render the file as markdown
|
||||
local settings = {
|
||||
background_color = bg_color,
|
||||
font_color = fg_color,
|
||||
heading_1_color = header_color,
|
||||
heading_2_color = header_color,
|
||||
heading_3_color = header_color,
|
||||
heading_4_color = header_color,
|
||||
heading_5_color = header_color,
|
||||
heading_6_color = header_color,
|
||||
heading_1_size = "26",
|
||||
heading_2_size = "22",
|
||||
heading_3_size = "18",
|
||||
heading_4_size = "18",
|
||||
heading_5_size = "18",
|
||||
heading_6_size = "18",
|
||||
code_block_mono_color = mono_color,
|
||||
code_block_font_size = 14,
|
||||
mono_color = mono_color,
|
||||
block_quote_color = mono_color,
|
||||
}
|
||||
news_fs = news_fs..md2f.md2f(0.2, 0.5, 23.6, 13.8, news, "news", settings)
|
||||
minetest.log("verbose", "Formspec => "..news_fs)
|
||||
return news_fs
|
||||
end
|
||||
|
||||
-- Show news formspec on player join, unless player has bypass priv
|
||||
local function on_joinplayer(player)
|
||||
local name = player:get_player_name()
|
||||
if player:get_hp() <= 0 or minetest.get_player_privs(name).news_bypass then
|
||||
return
|
||||
end
|
||||
|
||||
-- Get the formspec first
|
||||
local news_fs = get_formspec(name)
|
||||
|
||||
-- Only show the formspec if it's not nil
|
||||
if news_fs then
|
||||
minetest.show_formspec(name, "news", news_fs)
|
||||
end
|
||||
end
|
||||
-- Register callback
|
||||
minetest.register_on_joinplayer(on_joinplayer)
|
||||
|
||||
-- Command to display server news at any time
|
||||
minetest.register_chatcommand("news", {
|
||||
description = "Shows server news to the player",
|
||||
func = function (name)
|
||||
-- Get the formspec first
|
||||
local news_fs = get_formspec(name)
|
||||
|
||||
-- Only show the formspec if it's not nil
|
||||
if news_fs then
|
||||
minetest.show_formspec(name, "news", news_fs)
|
||||
else
|
||||
-- Optional: Give the player feedback that there is no news
|
||||
minetest.chat_send_player(name, "There is no news to display at the moment.")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- Exported API
|
||||
minenews = {}
|
||||
minenews.on_joinplayer = on_joinplayer
|
||||
28
license.txt
Normal file
28
license.txt
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
License: MIT
|
||||
Mod by: Shara RedCat
|
||||
|
||||
---
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Shara RedCat
|
||||
Copyright (c) 2021 Ronoaldo JLP
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
7
mod.conf
Normal file
7
mod.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
name = minenews
|
||||
title = Localized Server News
|
||||
description = Display localized server news when a player joins
|
||||
depends = markdown2formspec
|
||||
|
||||
release = 12102
|
||||
author = ronoaldo
|
||||
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 123 KiB |
BIN
screenshot_pt.png
Normal file
BIN
screenshot_pt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 137 KiB |
17
scripts/test.sh
Normal file
17
scripts/test.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
export WORLD=$HOME/.minetest/worlds/minenews-dev
|
||||
export LOGS=$(mktemp "$WORLD/debug.txt")
|
||||
|
||||
rm -rvf $WORLD
|
||||
mkdir -p $WORLD/worldmods
|
||||
cp -r scripts/world/* $WORLD/
|
||||
cp -r ./ $WORLD/worldmods/minenews
|
||||
|
||||
if [ x"$1" = x"pt" ]; then
|
||||
echo -e '\nlanguage = pt_BR' >> $WORLD/minetest.conf
|
||||
fi
|
||||
|
||||
exec minetest --verbose --config $WORLD/minetest.conf --world $WORLD --go
|
||||
15
scripts/world/minetest.conf
Normal file
15
scripts/world/minetest.conf
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
autosave_screensize = false
|
||||
clickable_chat_weblinks = true
|
||||
creative_mode = false
|
||||
enable_console = false
|
||||
enable_damage = true
|
||||
fixed_map_seed = minenews
|
||||
fog_start = 0.4
|
||||
fov = 96
|
||||
mg_name = v7
|
||||
mgv7_spflags = caverns,floatlands,ridges,mountains
|
||||
screen_h = 1080
|
||||
screen_w = 1920
|
||||
server_announce = false
|
||||
viewing_range = 512
|
||||
minenews.discord_invite=https://discord.gg/my-custom-link
|
||||
89
scripts/world/news.md
Normal file
89
scripts/world/news.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||

|
||||
|
||||
# **Welcome to Mercurio Server!**
|
||||
-------------------------------
|
||||
|
||||
The server is designed to be friendly and enjoyable! Please:
|
||||
|
||||
```
|
||||
* Do not destroy other player's properties
|
||||
* Do not appropriate other player's items.
|
||||
* No dating allowed.
|
||||
* No forms of discrimination are tolerated.
|
||||
```
|
||||
|
||||
-------------------------------
|
||||
|
||||

|
||||
|
||||
|
||||
# **Server Update March 13, 2022**
|
||||
|
||||

|
||||
|
||||
Server was updated this week to add two new mods! New vehicles to drive around
|
||||
and 11 new elements, ores and equipments. Special thanks to player **bramos**,
|
||||
**farribeiro** and **joseanastacio** who suggeted the mods and helped with testing!
|
||||
|
||||
## Hilights
|
||||
|
||||
### New vhicles
|
||||
Added APercy's automobiles modpack, adding three new cars for us
|
||||
to drive: coupe, buggy and roadster.
|
||||
|
||||
### Extra ores!
|
||||
Added Xtraores (by David), adding 11 new minerals, swords, tools
|
||||
and armor. More rare minerals are only obtainable bellow the layer -11000, so get
|
||||
your pickaxle ready!
|
||||
|
||||

|
||||
|
||||
|
||||
# **Server Update March 07, 2022**
|
||||
|
||||

|
||||
|
||||
Sever was updated this week with small fixes for the February update, and with
|
||||
the notable addition of three new mods: Tubelib, Techpack and Drawers.
|
||||
|
||||
## Hilights
|
||||
|
||||
**New modpack Techpack**: This mod adds several items to the game, allowing for
|
||||
unmatched automation! Level up your farming!
|
||||
|
||||
**New mod Drawers**: This mod adds a great ammount of new storage items. I mean,
|
||||
*several* new storage items. Upgrade your wharehouses!
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
# **Server Update February 12, 2022**
|
||||
|
||||

|
||||
|
||||
Server was updated with several mods to their new versions.
|
||||
|
||||
## Highlights
|
||||
|
||||
**New version of APercy planes**: Mods now use *airutils* in common, including
|
||||
for repairs and base flight logic.
|
||||
|
||||
**New version of Draconis mod**: The Draconis mod has been updated to version 1.2.
|
||||
One of the main news is that in this new version the furnace can actually be
|
||||
heated and used to produce the improved ore, tool and armor! We also have new
|
||||
features in the behavior of wild dragons and a new interface for managing the
|
||||
tamed dragon.
|
||||
|
||||

|
||||
|
||||
|
||||
# **Tips and Tricks**
|
||||
|
||||
Follow these tips and suggestions to enhance your gameplay:
|
||||
|
||||
Use `protectors`, `protector blocks` and the `area` delimiters to avoid unwanted
|
||||
breakage of your builds! Remember some kids play here as well so better be safe
|
||||
than sorry!
|
||||
|
||||
You can use the `search` dommand to find useful information about the world!
|
||||
89
scripts/world/news_pt_BR.md
Normal file
89
scripts/world/news_pt_BR.md
Normal file
|
|
@ -0,0 +1,89 @@
|
|||

|
||||
|
||||
# **Bem-vindo ao Servidor Mercurio!**
|
||||
-------------------------------
|
||||
|
||||
O servidor foi projetado para ser amigável e agradável! Por favor:
|
||||
|
||||
```
|
||||
* Não destrua as propriedades de outros jogadores
|
||||
* Não se aproprie de itens de outros jogadores.
|
||||
* Nenhum namoro permitido.
|
||||
* Nenhuma forma de discriminação é tolerada.
|
||||
```
|
||||
|
||||
-------------------------------
|
||||
|
||||

|
||||
|
||||
|
||||
# **Atualização do servidor em 13 de março de 2022**
|
||||
|
||||

|
||||
|
||||
O servidor foi atualizado esta semana para adicionar dois novos mods! Novos veículos para circular
|
||||
e 11 novos elementos, minérios e equipamentos. Agradecimentos especiais ao jogador **bramos**,
|
||||
**farribeiro** e **joseanastacio** que sugeriram os mods e ajudaram nos testes!
|
||||
|
||||
## Destaques
|
||||
|
||||
### Novos veículos
|
||||
Adicionado o modpack de automóveis do APercy, adicionando três novos carros para nós
|
||||
para dirigir: cupê, buggy e roadster.
|
||||
|
||||
### Minérios extras!
|
||||
Adicionado Xtraores (por David), adicionando 11 novos minerais, espadas, ferramentas
|
||||
e armadura. Minerais mais raros só podem ser obtidos abaixo da camada -11000, então pegue
|
||||
sua picareta pronta!
|
||||
|
||||

|
||||
|
||||
|
||||
# **Atualização do servidor em 07 de março de 2022**
|
||||
|
||||

|
||||
|
||||
O servidor foi atualizado esta semana com pequenas correções para a atualização de fevereiro e com
|
||||
a notável adição de três novos mods: Tubelib, Techpack e Drawers.
|
||||
|
||||
## Destaques
|
||||
|
||||
**Novo modpack Techpack**: Este mod adiciona vários itens ao jogo, permitindo
|
||||
automação incomparável! Aumente o nível da sua agricultura!
|
||||
|
||||
**Novas gavetas de mod**: Este mod adiciona uma grande quantidade de novos itens de armazenamento. Quero dizer,
|
||||
*vários* novos itens de armazenamento. Atualize seus armazéns!
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
# **Atualização do servidor em 12 de fevereiro de 2022**
|
||||
|
||||

|
||||
|
||||
Servidor foi atualizado com vários mods para suas novas versões.
|
||||
|
||||
## Destaques
|
||||
|
||||
**Nova versão dos aviões APercy**: Mods agora usam *airutils* em comum, incluindo
|
||||
para reparos e lógica básica de voo.
|
||||
|
||||
**Nova versão do mod Draconis**: O mod Draconis foi atualizado para a versão 1.2.
|
||||
Uma das principais novidades é que nesta nova versão o forno pode realmente ser
|
||||
aquecido e usado para produzir minério, ferramenta e armadura melhorados! Também temos novos
|
||||
recursos no comportamento de dragões selvagens e uma nova interface para gerenciar o
|
||||
dragão domesticado.
|
||||
|
||||

|
||||
|
||||
|
||||
# **Dicas e truques**
|
||||
|
||||
Siga estas dicas e sugestões para melhorar sua jogabilidade:
|
||||
|
||||
Use `protectors`, `protector blocks` e os delimitadores `area` para evitar
|
||||
quebra de suas construções! Lembre-se de que algumas crianças brincam aqui também, então é melhor estar seguro
|
||||
do que desculpe!
|
||||
|
||||
Você pode usar o comando `search` para encontrar informações úteis sobre o mundo!
|
||||
6
scripts/world/world.mt
Normal file
6
scripts/world/world.mt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
world_name = MinenewsDev
|
||||
gameid = minetest
|
||||
enable_damage = true
|
||||
creative_mode = true
|
||||
server_announce = false
|
||||
load_mod_markdown2formspec = true
|
||||
13
settingtypes.txt
Normal file
13
settingtypes.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Changes the color of the background container of the rendered form.
|
||||
minenews.bg_color (Background color for the generated formspec) string #34343400
|
||||
|
||||
# Changes the color of the rendered text font.
|
||||
minenews.fg_color (Font color for the generated formspec) string #AFAFAF
|
||||
|
||||
# Changes the color of the Heading elements (h1, h2, ..., h6) when rendered.
|
||||
minenews.header_color (Header font color) string #CFCFCF
|
||||
|
||||
# Use this to let players more easily copy-paste the invitation link.
|
||||
# Minetest currently do not support showing clickable links in the GUI,
|
||||
# so this works as a workaround.
|
||||
minenews.discord_link (If present, shows a Discord invitation link at the bottom in a text field) string
|
||||
BIN
textures/minenews_icon_chat.png
Normal file
BIN
textures/minenews_icon_chat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1,022 B |
BIN
textures/minenews_icon_chat_white.png
Normal file
BIN
textures/minenews_icon_chat_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue