First attempt

This commit is contained in:
AliasAlreadyTaken 2024-04-01 08:39:05 +02:00
parent d6521f8cf8
commit 8a8cd88012
30 changed files with 123 additions and 229 deletions

View File

@ -1,21 +1,38 @@
# yl_template
# yl_googly_eyes
## Purpose
This mod is not meant to bring functionality by itself, but to serve as a template you can base your mod on.
This mod makes everything better if you add googly eyes to it.
## Download
Get it from https://gitea.your-land.de/your-land/yl_template
Get it from https://gitea.your-land.de/your-land/yl_googly_eyes
## Installation
Being a template, you shouldn't install the mod itself. Your mod could look like this:
Copy the "yl_googly_eyes" folder to your mod folder and enable it in your world.mt.
## Usage
Craft yourself googly eyes, put them on trees, houses, ships and mountains and drive everyone mad.
## Supported versions
If you run yl_vpn_check, but something is wrong, please [file a bug](https://gitea.your-land.de/your-land/yl_googly_eyes/issues/new). PRs also welcome.
There is no reason to believe it doesn't work anywhere, but you never know.
## Uninstall
Remove it from your mod folder or deactivate it in your world.mt
Mods that depend on it will cease to work, if the mod is removed without proper replacement.
## License
MIT
## Thank you
* Simson (Alias' cat)

28
blockdefinitions.lua Normal file
View File

@ -0,0 +1,28 @@
local directions = {"blink", "down", "left", "right", "mid", "up"}
-- single
for _, direction in pairs(directions) do
local name = "single_" .. direction
core.log("action",name)
yl_googly_eyes.register_eye(name)
end
-- pair
for _, direction in pairs(directions) do
local name = "pair_" .. direction .. "_square"
core.log("action",name)
yl_googly_eyes.register_eye(name)
end
local directions_roundpair = {"blink", "cross", "mid"}
for _, direction in pairs(directions_roundpair) do
local name = "pair_" .. direction .. "_round"
core.log("action",name)
yl_googly_eyes.register_eye(name)
end
-- animated

View File

@ -1,19 +0,0 @@
local chatcommand_cmd = "admin_example"
local chatcommand_definition = {
params = "<name> <privilege>", -- Short parameter description
description = "Example description", -- Full description
privs = {[yl_template.settings.admin_priv] = true}, -- Require the "privs" privilege to run
func = function(name, param)
local success = true
if success then
return true, "Sucess message"
else
return false, "Fail message"
end
end
-- Called when command is run. Returns boolean success and text output.
-- Special case: The help message is shown to the player if `func`
-- returns false without a text output.
}
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)

View File

@ -1,19 +0,0 @@
local chatcommand_cmd = "player_example"
local chatcommand_definition = {
params = "<name> <privilege>", -- Short parameter description
description = "Example description", -- Full description
privs = {privs = true}, -- Require the "privs" privilege to run
func = function(name, param)
local success = true
if success then
return true, "Sucess message"
else
return false, "Fail message"
end
end
-- Called when command is run. Returns boolean success and text output.
-- Special case: The help message is shown to the player if `func`
-- returns false without a text output.
}
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)

View File

@ -1,2 +0,0 @@
dofile(yl_template.modpath .. "chatcommand_admin.lua")
dofile(yl_template.modpath .. "chatcommand_player.lua")

View File

@ -1,10 +0,0 @@
-- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken.
yl_template.settings = {}
yl_template.settings.external_value = "mod_default" or minetest.settings:get("yl_template.external_value") or "default"
yl_template.settings.save_path = "yl_template" or minetest.settings:get("yl_template.save_path") or "default"
yl_template.settings.admin_priv = "admin_priv" or minetest.settings:get("yl_template.admin_priv") or "server"

View File

@ -1,4 +1,2 @@
This file holds a couple of editors notes regarding the mod.
Todo's can be noted here, known issues, the path to ressources or general annotations.
There is a certain lack of googly eyes in Minetest. Let's fix that.

View File

@ -1,13 +0,0 @@
local timer = 0
local gs = function(dtime)
timer = timer + dtime
if timer <= yl_template.config.interval then
return
end
timer = 0
-- do stuff
end
minetest.register_globalstep(gs)

View File

@ -5,31 +5,24 @@
-- Changelog
local mod_start_time = core.get_us_time()
core.log("action", "[MOD] yl_template loading")
core.log("action", "[MOD] yl_googly_eyes loading")
yl_template = {}
yl_template.error = {}
yl_template.modstorage = core.get_mod_storage()
yl_template.modpath = core.get_modpath("yl_template") .. DIR_DELIM
yl_template.worldpath = core.get_worldpath() .. DIR_DELIM
yl_googly_eyes = {}
yl_googly_eyes.error = {}
--yl_googly_eyes.modstorage = core.get_mod_storage()
yl_googly_eyes.modpath = core.get_modpath("yl_googly_eyes") .. DIR_DELIM
--yl_googly_eyes.worldpath = core.get_worldpath() .. DIR_DELIM
yl_template.information = {}
yl_template.information.version = "0.0.1"
yl_template.information.author = "AliasAlreadyTaken"
yl_template.information.license = "MIT"
yl_template.information.name = "yl_template"
yl_template.information.source = "https://gitea.your-land.de/your-land/yl_template"
yl_template.information.additional = "Additional information"
yl_googly_eyes.information = {}
yl_googly_eyes.information.version = "0.0.1"
yl_googly_eyes.information.author = "AliasAlreadyTaken"
yl_googly_eyes.information.license = "MIT"
yl_googly_eyes.information.name = "Adds various googly eyes"
yl_googly_eyes.information.source = "https://gitea.your-land.de/your-land/yl_googly_eyes"
yl_googly_eyes.information.additional = "Adds various googly eyes."
dofile(yl_template.modpath .. "config.lua")
dofile(yl_template.modpath .. "setup.lua")
dofile(yl_template.modpath .. "privs.lua")
dofile(yl_template.modpath .. "internal.lua")
dofile(yl_template.modpath .. "api.lua")
dofile(yl_template.modpath .. "distinct_feature.lua")
dofile(yl_template.modpath .. "overwrite_feature.lua")
dofile(yl_template.modpath .. "globalsteps.lua")
dofile(yl_template.modpath .. "chatcommands.lua")
dofile(yl_googly_eyes.modpath .. "internal.lua")
dofile(yl_googly_eyes.modpath .. "blockdefinitions.lua")
local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000
core.log("action", "[MOD] yl_template loaded in [" .. mod_end_time .. "s]")
core.log("action", "[MOD] yl_googly_eyes loaded in [" .. mod_end_time .. "s]")

View File

@ -1,53 +1,58 @@
-- The functions and variables in this file are only for use in the mod itself. Those that do real work should be local and wrapped in public functions
local debug = true
local function say(text)
if yl_template.debug then
core.log("action", "[MOD] yl_template : " .. text)
end
end
local function save_path(file)
return yl_template.worldpath .. file .. ".json"
end
local function save_json(filename, content)
if type(filename) ~= "string" or type(content) ~= "table" then
return false
end
local savepath = save_path(filename)
local savecontent = minetest.write_json(content)
return minetest.safe_file_write(savepath, savecontent)
end
local function load_json(filename) -- returns the saved dialog
local savepath = save_path(filename)
local file, err = io.open(savepath, "r")
if err then
return {}
end
io.input(file)
local savecontent = io.read()
local content = minetest.parse_json(savecontent)
io.close(file)
if type(content) ~= "table" then
content = {}
local function on_place(itemstack, placer, pointed_thing)
if not minetest.is_player(placer) then
return minetest.item_place(itemstack, placer, pointed_thing)
end
return content
local look_dir = placer:get_look_dir()
if not vector.check(look_dir) then
return minetest.item_place(itemstack, placer, pointed_thing)
end
local facedir = minetest.dir_to_facedir(look_dir)
local aim_dir = pointed_thing.under - pointed_thing.above
local param2
if aim_dir.x == -1 then
param2 = 15
elseif aim_dir.x == 1 then
param2 = 17
elseif aim_dir.y == -1 then
param2 = facedir
elseif aim_dir.y == 1 then
param2 = 20 + ((2 - facedir) % 4)
elseif aim_dir.z == -1 then
param2 = 6
elseif aim_dir.z == 1 then
param2 = 8
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end
-- Public functions wrap the private ones, so they can be exchanged easily
function yl_template.load(filename, ...)
return load_json(filename, ...)
function yl_googly_eyes.register_eye(name)
minetest.register_node(":yl_googly_eyes:" .. name, {
description = "Googly Eyes!",
-- _doc_items_create_entry = false,
drawtype = "nodebox",
use_texture_alpha = "blend",
tiles = {"yl_googly_eyes_" .. name .. ".png"},
is_ground_content = false,
inventory_image = "yl_googly_eyes_" .. name .. ".png",
wield_image = "yl_googly_eyes_" .. name .. ".png",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
climbable = false,
sunlight_propagates = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.4375, -0.5, 0.5, -0.4375, 0.5}
},
groups = {choppy = 3},
on_place = on_place
})
end
function yl_template.save(filename, content, ...)
return save_json(filename, content, ...)
end
-- Each time the server loads, the animated ones have a different style of looking

View File

@ -1,7 +1,4 @@
name = yl_template
description = A template with best practices
depends = default
optional_depends = moreblocks
name = yl_googly_eyes
description = Adds various googly eyes.
author = AliasAlreadyTaken
release = 202106161537
title = Template
title = Googly Eyes

View File

@ -1,58 +0,0 @@
local priv_name = "example"
local priv_definition = {
description = "Can do example task",
-- Privilege description
give_to_singleplayer = false,
-- Whether to grant the privilege to singleplayer.
give_to_admin = true,
-- Whether to grant the privilege to the server admin.
-- Uses value of 'give_to_singleplayer' by default.
on_grant = function(name, granter_name)
-- logging
if not granter_name then
granter_name = "MOD"
end
if not name then
name = "ERROR"
end
if not priv_name then
priv_name = "ERROR"
end
core.log(
"action",
"[MOD] yl_template: User " .. granter_name .. " granted user " .. name .. " priv " .. priv_name
)
end,
-- Called when given to player 'name' by 'granter_name'.
-- 'granter_name' will be nil if the priv was granted by a mod.
on_revoke = function(name, revoker_name)
-- logging
if not revoker_name then
revoker_name = "MOD"
end
if not name then
name = "ERROR"
end
if not priv_name then
priv_name = "ERROR"
end
core.log(
"action",
"[MOD] yl_template: User " .. revoker_name .. " revoked user " .. name .. " priv " .. priv_name
)
end
-- Called when taken from player 'name' by 'revoker_name'.
-- 'revoker_name' will be nil if the priv was revoked by a mod.
-- Note that the above two callbacks will be called twice if a player is
-- responsible, once with the player name, and then with a nil player
-- name.
-- Return true in the above callbacks to stop register_on_priv_grant or
-- revoke being called.
}
minetest.register_privilege(priv_name, priv_definition)

View File

@ -1 +0,0 @@
dofile(yl_template.modpath .. "priv_example.lua")

View File

@ -1,6 +0,0 @@
[category]
# First line: Name the settings
# Second line: Say what it does, how to use it, what it changes
# Third line: Is it optional? What's the default value? Does it expect a certain set of values?
yl_template.external_value (Description of the setting) string "default_value"

View File

@ -1,16 +0,0 @@
local function run_once()
local dl = minetest.get_dir_list(yl_template.worldpath, true)
local create = true
for _, v in ipairs(dl) do
if v == yl_template.settings.save_path then
create = false
end
end
if create then
minetest.mkdir(yl_template.worldpath .. DIR_DELIM .. yl_template.settings.save_path)
end
end
run_once()

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B