2021-07-11 13:42:12 +02:00
|
|
|
local modname = minetest.get_current_modname()
|
|
|
|
local S = minetest.get_translator(modname)
|
|
|
|
|
2022-03-07 02:52:23 +01:00
|
|
|
local contributors_file_name = minetest.get_modpath(modname) .. "/CONTRUBUTOR_LIST.txt"
|
|
|
|
|
|
|
|
local file = io.open(contributors_file_name)
|
|
|
|
local contributors = {}
|
|
|
|
if not file then
|
|
|
|
minetest.log("error", "[" .. modname .. "] Can't read contributors from " .. contributors_file_name)
|
|
|
|
else
|
|
|
|
local contributor_list = file:read("*a")
|
|
|
|
file:close()
|
|
|
|
for contributor in contributor_list:gmatch("[^\r\n]+") do
|
|
|
|
table.insert(contributors, contributor)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-04 19:13:46 +02:00
|
|
|
mcl_credits = {
|
|
|
|
players = {},
|
2021-10-26 13:08:07 +02:00
|
|
|
description = S("A faithful Open Source clone of Minecraft"),
|
2022-03-07 02:52:23 +01:00
|
|
|
people = {
|
|
|
|
{S("Creator of MineClone"), 0x0A9400, {
|
|
|
|
"davedevils",
|
|
|
|
}},
|
|
|
|
{S("Creator of MineClone 2"), 0xFBF837, {
|
|
|
|
"Wuzzy",
|
|
|
|
}},
|
|
|
|
{S("Creators of MineClone 5"), 0x52FF00,
|
|
|
|
contributors
|
|
|
|
},
|
|
|
|
{S("Special thanks"), 0x00E9FF, {
|
|
|
|
"celeron55 for creating Minetest",
|
|
|
|
"Jordach for the jukebox music compilation from Big Freaking Dig",
|
|
|
|
"The workaholics who spent way too much time writing for the Minecraft Wiki. It's an invaluable resource for creating this game",
|
|
|
|
"Notch and Jeb for being the major forces behind Minecraft",
|
|
|
|
}}
|
|
|
|
}
|
2021-04-04 19:13:46 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:55:21 +02:00
|
|
|
local function add_hud_element(def, huds, y)
|
|
|
|
def.alignment = {x = 0, y = 0}
|
|
|
|
def.position = {x = 0.5, y = 0}
|
|
|
|
def.offset = {x = 0, y = y}
|
|
|
|
def.z_index = 1001
|
|
|
|
local id = huds.player:hud_add(def)
|
|
|
|
table.insert(huds.ids, id)
|
|
|
|
huds.moving[id] = y
|
|
|
|
return id
|
|
|
|
end
|
|
|
|
|
2021-04-04 19:13:46 +02:00
|
|
|
function mcl_credits.show(player)
|
|
|
|
local name = player:get_player_name()
|
|
|
|
if mcl_credits.players[name] then
|
|
|
|
return
|
|
|
|
end
|
2021-04-06 11:55:21 +02:00
|
|
|
local huds = {
|
|
|
|
new = true, -- workaround for MT < 5.5 (sending hud_add and hud_remove in the same tick)
|
|
|
|
player = player,
|
|
|
|
moving = {},
|
|
|
|
ids = {
|
|
|
|
player:hud_add({
|
|
|
|
hud_elem_type = "image",
|
2021-07-10 19:32:01 +02:00
|
|
|
text = "credits_bg.png",
|
2021-04-06 11:55:21 +02:00
|
|
|
position = {x = 0, y = 0},
|
|
|
|
alignment = {x = 1, y = 1},
|
|
|
|
scale = {x = -100, y = -100},
|
|
|
|
z_index = 1000,
|
|
|
|
}),
|
|
|
|
player:hud_add({
|
|
|
|
hud_elem_type = "text",
|
2021-07-11 13:42:12 +02:00
|
|
|
text = S("Sneak to skip"),
|
2021-04-06 11:55:21 +02:00
|
|
|
position = {x = 1, y = 1},
|
|
|
|
alignment = {x = -1, y = -1},
|
|
|
|
offset = {x = -5, y = -5},
|
|
|
|
z_index = 1001,
|
|
|
|
number = 0xFFFFFF,
|
2021-07-10 17:12:41 +02:00
|
|
|
}),
|
|
|
|
player:hud_add({
|
|
|
|
hud_elem_type = "text",
|
2021-07-11 13:42:12 +02:00
|
|
|
text = " "..S("Jump to speed up (additionally sprint)"),
|
2021-07-10 17:12:41 +02:00
|
|
|
position = {x = 0, y = 1},
|
|
|
|
alignment = {x = 1, y = -1},
|
|
|
|
offset = {x = -5, y = -5},
|
|
|
|
z_index = 1002,
|
|
|
|
number = 0xFFFFFF,
|
|
|
|
}),
|
2021-04-06 11:55:21 +02:00
|
|
|
},
|
2021-04-04 19:13:46 +02:00
|
|
|
}
|
2021-04-06 11:55:21 +02:00
|
|
|
add_hud_element({
|
|
|
|
hud_elem_type = "image",
|
|
|
|
text = "mineclone2_logo.png",
|
|
|
|
scale = {x = 1, y = 1},
|
|
|
|
}, huds, 300, 0)
|
|
|
|
add_hud_element({
|
|
|
|
hud_elem_type = "text",
|
|
|
|
text = mcl_credits.description,
|
|
|
|
number = 0x757575,
|
|
|
|
scale = {x = 5, y = 5},
|
|
|
|
}, huds, 350, 0)
|
|
|
|
local y = 450
|
|
|
|
for _, group in ipairs(mcl_credits.people) do
|
|
|
|
add_hud_element({
|
|
|
|
hud_elem_type = "text",
|
|
|
|
text = group[1],
|
|
|
|
number = group[2],
|
|
|
|
scale = {x = 3, y = 3},
|
|
|
|
}, huds, y, 0)
|
|
|
|
y = y + 25
|
|
|
|
for _, name in ipairs(group[3]) do
|
|
|
|
y = y + 25
|
|
|
|
add_hud_element({
|
|
|
|
hud_elem_type = "text",
|
|
|
|
text = name,
|
|
|
|
number = 0xFFFFFF,
|
|
|
|
scale = {x = 1, y = 1},
|
|
|
|
}, huds, y, 0)
|
|
|
|
end
|
|
|
|
y = y + 200
|
|
|
|
end
|
|
|
|
huds.icon = add_hud_element({
|
|
|
|
hud_elem_type = "image",
|
|
|
|
text = "mineclone2_icon.png",
|
|
|
|
scale = {x = 1, y = 1},
|
|
|
|
}, huds, y)
|
|
|
|
mcl_credits.players[name] = huds
|
2021-04-04 19:13:46 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function mcl_credits.hide(player)
|
|
|
|
local name = player:get_player_name()
|
2021-04-06 11:55:21 +02:00
|
|
|
local huds = mcl_credits.players[name]
|
|
|
|
if huds then
|
|
|
|
for _, id in pairs(huds.ids) do
|
2021-04-04 19:13:46 +02:00
|
|
|
player:hud_remove(id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
mcl_credits.players[name] = nil
|
|
|
|
end
|
|
|
|
|
2021-04-06 11:55:21 +02:00
|
|
|
minetest.register_on_leaveplayer(function(player)
|
|
|
|
mcl_credits.players[player:get_player_name()] = nil
|
|
|
|
end)
|
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
for _, huds in pairs(mcl_credits.players) do
|
|
|
|
local player = huds.player
|
2021-07-10 17:12:41 +02:00
|
|
|
local control = player:get_player_control()
|
|
|
|
if not huds.new and control.sneak then
|
2021-04-06 11:55:21 +02:00
|
|
|
mcl_credits.hide(player)
|
|
|
|
else
|
|
|
|
local moving = {}
|
|
|
|
local any
|
|
|
|
for id, y in pairs(huds.moving) do
|
2021-07-11 13:11:22 +02:00
|
|
|
y = y - 1
|
2021-07-11 13:42:12 +02:00
|
|
|
|
2021-07-11 13:11:22 +02:00
|
|
|
if control.jump then
|
|
|
|
y = y - 2
|
|
|
|
if control.aux1 then
|
|
|
|
y = y - 5
|
2021-07-10 17:12:41 +02:00
|
|
|
end
|
|
|
|
end
|
2021-10-26 13:08:07 +02:00
|
|
|
|
2021-04-06 11:55:21 +02:00
|
|
|
if y > -100 then
|
|
|
|
if id == huds.icon then
|
|
|
|
y = math.max(400, y)
|
|
|
|
else
|
|
|
|
any = true
|
|
|
|
end
|
|
|
|
player:hud_change(id, "offset", {x = 0, y = y})
|
|
|
|
moving[id] = y
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not any then
|
|
|
|
mcl_credits.hide(player)
|
|
|
|
end
|
|
|
|
huds.moving = moving
|
|
|
|
end
|
|
|
|
huds.new = false
|
2021-04-04 19:13:46 +02:00
|
|
|
end
|
|
|
|
end)
|