Primo commit

master
Marco 2020-06-17 01:02:13 +02:00
parent f2e290b38a
commit 503ecc5016
10 changed files with 107 additions and 0 deletions

5
init.lua Normal file
View File

@ -0,0 +1,5 @@
magic_compass = {}
dofile(minetest.get_modpath("magic_compass") .. "/items.lua")
dofile(minetest.get_modpath("magic_compass") .. "/privs.lua")
dofile(minetest.get_modpath("magic_compass") .. "/serializer.lua")

50
items.lua Normal file
View File

@ -0,0 +1,50 @@
local S = minetest.get_translator("magic_compass")
minetest.register_tool("magic_compass:compass", {
description = S("Compass"),
inventory_image = "magiccompass_compass.png",
groups = {oddly_breakable_by_hand = "2"},
on_place = function() end,
on_drop = function() end,
on_use = function(itemstack, user, pointed_thing)
minetest.show_formspec(user:get_player_name(), "magic_compass:GUI", magic_compass.get_formspec(user))
end
})
function magic_compass.get_formspec()
local rows = math.floor(#magic_compass.items / 5) + 1
local size = 5 * rows
local formspec = {
"size[6," .. 1.5 * rows .. "]"
}
--APPUNTI: 1 in altezza e 1 in larghezza come distanza
for i = 1, size do
local i_name = magic_compass.items[i]
if i_name then
table.insert(formspec, i+1, "item_image_button[0.5,0.33;1,1;"..i_name..";"..i_name..";]")
else
table.insert(formspec, i+1, "item_image_button["..0.5 + (i-1)..",0.33;1,1;;;]")
end
end
return table.concat(formspec,"")
end
--[[minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info)
minetest.chat_send_player(player:get_player_name(), "Azione = " .. action)
end)
]]--

View File

@ -0,0 +1,8 @@
# version 0.0.BETA
# author(s): Zughy
# reviewer(s):
# textdomain: magic_compass
# compass.lua
Compass=Bussola

8
locale/template.txt Normal file
View File

@ -0,0 +1,8 @@
# version 0.0.BETA
# author(s):
# reviewer(s):
# textdomain: magic_compass
# compass.lua
Compass=

3
locations/1_quake.txt Normal file
View File

@ -0,0 +1,3 @@
Quake
magiccompass_quake.png
-3.5, 3.0, -20.5

1
mod.conf Normal file
View File

@ -0,0 +1 @@
name = magic_compass

1
privs.lua Normal file
View File

@ -0,0 +1 @@
minetest.register_privilege("magiccompass_admin", {})

31
serializer.lua Normal file
View File

@ -0,0 +1,31 @@
magic_compass.items = {}
local locations_dir = minetest.get_modpath("magic_compass") .. "/locations"
local locations_content = minetest.get_dir_list(locations_dir)
for _, file_name in pairs(locations_content) do
-- estrapolo le info dall'oggetto
local file = io.open(locations_dir .. "/" .. file_name, "r")
local data = string.split(file:read("*all"), "\n")
file:close()
local i_name = data[1]
local i_texture = data[2]
local i_pos = data[3]
-- creo l'oggetto
minetest.register_tool("magic_compass:" .. i_name, {
description = i_name .. "\n\n" .. minetest.colorize("#a0938e", i_pos),
inventory_image = i_texture,
groups = {oddly_breakable_by_hand = "2"}
})
table.insert(magic_compass.items, "magic_compass:" .. i_name)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B