83 lines
3.5 KiB
Lua
Raw Normal View History

2022-11-21 16:12:22 -05:00
local modpath = minetest.get_modpath("story")
local currentPage = 0
storyText = {}
storyText[0] = "Click next to continue. Do NOT close the formspec by pressing the Escape key, or the game may break. To my knowledge, this is impossible to solve with the current Lua API."
storyText[1] = "Your name is Vyacheslav Mikhaylov and you live in the Eastern European country of Absurdistan..."
storyText[2] = "The government of your country has a long history of corruption and oppressing its citizens."
storyText[3] = "It didn't bother you much until last week when you were watching the news on TV..."
storyText[4] = "The government started forcefully drafting people into the military."
storyText[5] = "You were among the first people to get their draft notice in the mail."
storyText[6] = "You were devastated when you realized that you'll be sent away to die in a war that doesn't even concern you."
storyText[7] = "\"I've got nothing to lose at this point, how about I teach those damn bastards a lesson.\", you thought to yourself."
storyText[8] = "Click \"Next\" to generate the world."
story = {}
function getStoryFormspec(number)
storyFormspec =
{
"formspec_version[4]",
"size[18, 16]",
"bgcolor[#3A41EA]",
"position[0.5, 0.5]",
"style_type[button;bgcolor=#1010FF;textcolor=yellow]",
"hypertext[1, 12.5; 12, 5;;<global halign=center color=yellow size=20 font=Regular>" .. storyText[number] .. "]\n",
"image[1, .2; 16, 12;" .. number .. ".png]",
"button[13, 12.3; 4, 1;back;Back]",
"button[13, 13.6; 4, 1;next;Next]",
"button[13, 14.9; 4, 1;exit;Quit]"
}
return storyFormspec
end
minetest.register_on_joinplayer(function(player)
minetest.show_formspec(player:get_player_name(), "story:story_formspec", table.concat(getStoryFormspec(0), "\n"))
music = minetest.sound_play("4K", {
gain = 0,
pitch = 1.2,
loop = true,
})
minetest.sound_fade(music, .1, 1)
2022-11-21 20:43:08 -05:00
player:get_inventory():add_item("main", "more_fire:pipebomb 48")
player:get_inventory():add_item("main", "more_fire:firebomb 48")
minetest.setting_set("time_speed", 0)
minetest.set_timeofday(5000)
2022-11-21 16:12:22 -05:00
end)
2022-11-21 20:06:10 -05:00
2022-11-21 16:12:22 -05:00
minetest.register_on_newplayer(function(ObjectRef)
2022-11-21 20:06:10 -05:00
minetest.place_schematic({x = 0, y = -1, z = 0}, minetest.get_modpath("story") .. "/schems/citymap-v2.mts", "0", nil, true)
2022-11-21 16:12:22 -05:00
ObjectRef:set_pos({x = 20, y = 0, z = 20})
2022-11-21 20:06:10 -05:00
end)
2022-11-21 16:12:22 -05:00
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "story:story_formspec" then
return
end
if formname == "story:story_formspec" then
if fields.next then
if currentPage >= 8 then
minetest.close_formspec(player:get_player_name(), "story:story_formspec")
return
end
currentPage = currentPage + 1 -- Fuck Lua and its lack of arithmetic assignment operators
minetest.show_formspec(player:get_player_name(), "story:story_formspec", table.concat(getStoryFormspec(currentPage), "\n"))
elseif fields.back and currentPage >= 0 then
currentPage = currentPage - 1 -- Fuck Lua and its lack of arithmetic assignment operators
minetest.show_formspec(player:get_player_name(), "story:story_formspec", table.concat(getStoryFormspec(currentPage), "\n"))
elseif fields.exit then
--minetest.kick_player(player:get_player_name(), "Fuck you in particular")
minetest.request_shutdown("The game has crashed due to the citizen's neglience.\n This incident will be reported.")
elseif fields.quit then
minetest.after(0.2, function() minetest.show_formspec(player:get_player_name(), "story:story_formspec", table.concat(getStoryFormspec(currentPage), "\n")) end)
end
end
end)