commit
2dd6e44c3c
11 changed files with 281 additions and 0 deletions
25
.github/workflows/pre-commit.yml
vendored
Normal file
25
.github/workflows/pre-commit.yml
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
name: pre-commit
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/setup-python@master
|
||||
|
||||
- name: install luarocks
|
||||
run: sudo apt-get install -y luarocks
|
||||
|
||||
- name: luacheck install
|
||||
run: luarocks install --local luacheck
|
||||
|
||||
- name: add luacheck path
|
||||
run: echo "$HOME/.luarocks/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install pre-commit
|
||||
run: pip3 install pre-commit
|
||||
|
||||
- name: Run pre-commit
|
||||
run: pre-commit run --all-files
|
||||
31
.luacheckrc
Normal file
31
.luacheckrc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
std = "lua51+luajit+minetest+envelopes"
|
||||
unused_args = false
|
||||
max_line_length = 120
|
||||
|
||||
stds.minetest = {
|
||||
read_globals = {
|
||||
"DIR_DELIM",
|
||||
"minetest",
|
||||
"core",
|
||||
"dump",
|
||||
"vector",
|
||||
"nodeupdate",
|
||||
"VoxelManip",
|
||||
"VoxelArea",
|
||||
"PseudoRandom",
|
||||
"ItemStack",
|
||||
"default",
|
||||
"table",
|
||||
"math",
|
||||
"string",
|
||||
}
|
||||
}
|
||||
|
||||
stds.envelopes = {
|
||||
globals = {
|
||||
"envelopes",
|
||||
},
|
||||
read_globals = {
|
||||
"canonical_name",
|
||||
},
|
||||
}
|
||||
19
.pre-commit-config.yaml
Normal file
19
.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.3.0
|
||||
hooks:
|
||||
- id: fix-byte-order-marker
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
|
||||
- id: mixed-line-ending
|
||||
args: [ --fix=lf ]
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: luacheck
|
||||
name: luacheck
|
||||
language: system
|
||||
entry: luacheck
|
||||
pass_filenames: false
|
||||
args: [-q,.]
|
||||
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 archfan
|
||||
|
||||
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.
|
||||
11
README.md
Normal file
11
README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# minetest-envelopes
|
||||
Envelope mod for Minetest. https://minetest.net/
|
||||
|
||||
# How to use
|
||||
Blank envelopes are crafted with 6 paper. Punch with a blank envelope to open the letter-wrting formspec, which
|
||||
allows you to specify an addressee, letter text, and an optional "Attn." field which will be displayed in the
|
||||
envelope description. Once writing is complete, the envelope is sealed by pressing the "Seal" button. The blank
|
||||
envelope is then replaced by a sealed envelope which shows the sender, addressee, and optionally the Attn. field in
|
||||
the description. If the addressee punches with the sealed envelope, it will become an opened envelope, which, once
|
||||
punched, shows a formspec with the text. While a sealed envelope is only openable by the addressee, an opened
|
||||
envelope can be read by anyone - thus, secret correspondence should be pulverized.
|
||||
148
init.lua
Normal file
148
init.lua
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
if minetest.get_translator then
|
||||
S = minetest.get_translator(minetest.get_current_modname())
|
||||
else
|
||||
-- Fallback for older Minetest versions
|
||||
S = function(str) return str end
|
||||
end
|
||||
|
||||
local f = string.format
|
||||
|
||||
local has_canonical_name = minetest.get_modpath("canonical_name")
|
||||
|
||||
minetest.register_craftitem("envelopes:envelope_blank", {
|
||||
description = S("Blank Envelope"),
|
||||
inventory_image = "envelopes_envelope_blank.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
minetest.show_formspec(user:get_player_name(), "envelopes:input",
|
||||
"size[5.5,5.5]" ..
|
||||
"field[2,0.5;3.5,1;addressee;"..S("Addressee")..";]" ..
|
||||
"label[0,0;"..S("Write a letter").."]" ..
|
||||
"textarea[0.5,1.5;5,3;text;"..S("Text")..";]" ..
|
||||
"field[3,4.8;2.5,1;attn;"..S("Attn. (Optional)")..";]" ..
|
||||
"button_exit[0.25,4.5;2,1;exit;"..S("Seal").."]")
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("envelopes:envelope_sealed", {
|
||||
description = S("Sealed Envelope"),
|
||||
inventory_image = "envelopes_envelope_sealed.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local user_name = user:get_player_name()
|
||||
local meta = itemstack:get_meta()
|
||||
local addressee = meta:get_string("receiver")
|
||||
|
||||
if has_canonical_name then
|
||||
addressee = canonical_name.get(addressee)
|
||||
end
|
||||
|
||||
if user_name == addressee then
|
||||
local open_env = ItemStack("envelopes:envelope_opened")
|
||||
local open_meta = open_env:get_meta()
|
||||
open_meta:set_string("sender", meta:get_string("sender"))
|
||||
open_meta:set_string("receiver", meta:get_string("receiver"))
|
||||
open_meta:set_string("text", meta:get_string("text"))
|
||||
local desc = S("Opened Envelope") .. "\n" .. S("To: @1", meta:get_string("receiver")) .. "\n" .. S("From: @1", meta:get_string("sender"))
|
||||
open_meta:set_string("description", desc)
|
||||
if meta:get_string("attn") ~= "" then
|
||||
open_meta:set_string("attn", meta:get_string("attn"))
|
||||
desc = desc .. "\n" .. S("Attn: @1", meta:get_string("attn"))
|
||||
open_meta:set_string("description", desc)
|
||||
end
|
||||
return open_env
|
||||
|
||||
else
|
||||
minetest.chat_send_player(user_name, S("The seal can only be opened by @1!", addressee))
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("envelopes:envelope_opened", {
|
||||
description = S("Opened Envelope"),
|
||||
inventory_image = "envelopes_envelope_opened.png",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
local meta = itemstack:get_meta()
|
||||
local sender = meta:get_string("sender")
|
||||
local receiver = meta:get_string("receiver")
|
||||
local text = meta:get_string("text")
|
||||
local attn = meta:get_string("attn") or ""
|
||||
local form =
|
||||
"size[5,5]" ..
|
||||
"label[0,0;" .. S("A letter from @1 to @2", sender, receiver)
|
||||
if attn ~= "" then
|
||||
form = form .. "\n" .. S("Attn: @1", attn)
|
||||
end
|
||||
form = form .. "\n" .. text .. "]" .. "button_exit[0,4;2,1;exit;"..S("Close").."]"
|
||||
minetest.show_formspec(user:get_player_name(), "envelope:display", form)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "envelopes:input" or not minetest.is_player(player) then
|
||||
return false
|
||||
end
|
||||
|
||||
local sender_name = player:get_player_name()
|
||||
|
||||
local addressee = (fields.addressee or ""):trim()
|
||||
local text = (fields.text or ""):trim()
|
||||
local attn = (fields.attn or ""):trim()
|
||||
|
||||
if addressee == "" or text == "" then
|
||||
minetest.chat_send_player(sender_name, S("Please fill out all required fields."))
|
||||
return true
|
||||
end
|
||||
|
||||
if has_canonical_name then
|
||||
addressee = canonical_name.get(addressee) or addressee
|
||||
end
|
||||
|
||||
if not minetest.player_exists(addressee) then
|
||||
minetest.chat_send_player(sender_name, S("Unknown addressee: @1", addressee))
|
||||
return true
|
||||
end
|
||||
|
||||
local inv = player:get_inventory()
|
||||
local letter = ItemStack("envelopes:envelope_sealed")
|
||||
local blank = ItemStack("envelopes:envelope_blank")
|
||||
local meta = letter:get_meta()
|
||||
|
||||
meta:set_string("sender", sender_name)
|
||||
meta:set_string("receiver", addressee)
|
||||
meta:set_string("text", text)
|
||||
|
||||
local desc = S("Sealed Envelope") .. "\n" .. S("To: @1", addressee) .. "\n" .. S("From: @1", sender_name)
|
||||
|
||||
if attn ~= "" then
|
||||
meta:set_string("attn", attn)
|
||||
desc = desc .. "\n" .. S("Attn: @1", attn)
|
||||
end
|
||||
|
||||
meta:set_string("description", desc)
|
||||
|
||||
if inv:room_for_item("main", letter) and inv:contains_item("main", blank) then
|
||||
inv:add_item("main", letter)
|
||||
inv:remove_item("main", blank)
|
||||
else
|
||||
minetest.chat_send_player(sender_name, S("Unable to create letter! Check your inventory space."))
|
||||
end
|
||||
|
||||
return true
|
||||
end)
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.register_craft({
|
||||
type = "shaped",
|
||||
output = "envelopes:envelope_blank 1",
|
||||
recipe = {
|
||||
{"", "", ""},
|
||||
{"default:paper", "default:paper", "default:paper"},
|
||||
{"default:paper", "default:paper", "default:paper"}
|
||||
}
|
||||
})
|
||||
end
|
||||
19
locale/envelopes.de.tr
Normal file
19
locale/envelopes.de.tr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# textdomain: envelopes
|
||||
|
||||
Blank Envelope=Leerer Umschlag
|
||||
Sealed Envelope=Versiegelter Umschlag
|
||||
Opened Envelope=Geöffneter Umschlag
|
||||
Write a letter=Brief schreiben
|
||||
Addressee=Empfänger
|
||||
Text=Text
|
||||
Attn. (Optional)=Betreff (Optional)
|
||||
Seal=Versiegeln
|
||||
Close=Schließen
|
||||
To: @1=An: @1
|
||||
From: @1=Von: @1
|
||||
Attn: @1=Betreff: @1
|
||||
The seal can only be opened by @1!=Das Siegel kann nur von @1 geöffnet werden!
|
||||
A letter from @1 to @2=Ein Brief von @1 an @2
|
||||
Please fill out all required fields.=Bitte fülle alle benötigten Felder aus.
|
||||
Unknown addressee: @1=Unbekannter Empfänger: @1
|
||||
Unable to create letter! Check your inventory space.=Brief konnte nicht erstellt werden! Überprüfe dein Inventar.
|
||||
7
mod.conf
Normal file
7
mod.conf
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
name = envelopes
|
||||
title = Envelopes
|
||||
description = Provides envelopes and sealed letters, which can only be opened by the addressee.
|
||||
author = archfan7411
|
||||
license = MIT
|
||||
version = 2022-10-25
|
||||
optional_depends = default, canonical_name
|
||||
BIN
textures/envelopes_envelope_blank.png
Normal file
BIN
textures/envelopes_envelope_blank.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 561 B |
BIN
textures/envelopes_envelope_opened.png
Normal file
BIN
textures/envelopes_envelope_opened.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 634 B |
BIN
textures/envelopes_envelope_sealed.png
Normal file
BIN
textures/envelopes_envelope_sealed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 569 B |
Loading…
Add table
Add a link
Reference in a new issue