From c25b78924a105d861139746e1de14c2115faf80c Mon Sep 17 00:00:00 2001 From: kacperks Date: Mon, 21 Nov 2022 22:55:04 +0100 Subject: [PATCH] dialogs added --- mods/poop/init.lua | 85 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 8 deletions(-) diff --git a/mods/poop/init.lua b/mods/poop/init.lua index a66057a..b4426f4 100644 --- a/mods/poop/init.lua +++ b/mods/poop/init.lua @@ -1,3 +1,76 @@ +currentPage = 1 + +minetest.register_item(":", { -- Hand +type = "none", +wield_image = "Poop.png", +wield_scale = {x=1.5,y=2,z=4.5}, +range = 5, +tool_capabilities = { + max_drop_level = 0, + full_punch_interval = 0.4, + + groupcaps = + { + oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.70}, uses=0}, + snappy = {times={[3]=0, [2]=0, [1]=0}, uses=0, maxlevel=3}, + crumbly = {times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3}, + cracky = {times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3}, + choppy = {times={[1]=0, [2]=0, [3]=0}, uses=0, maxlevel=3}, + }, + damage_groups = {fleshy = 3, snappy = 2}, +} +}) +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 >= 4 then + minetest.close_formspec(player:get_player_name(), "story:story_formspec") + -- teleport player to 10 9.5 18 + player:setpos({x=10, y=9.5, z=18}) + 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) +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] = "Welcome To ShittingSim! Very Advanced, Educational, and Cultural Minetest Game!" +storyText[2] = "So the story is simple. You are eating so many pickles and beans and drinking milk then you feel heavly that you have to take a shit." +storyText[3] = "You accidently use your flux capacitor and time travel to the future city where you are shitting all over the place." +storyText[4] = "You have to run from future robocops and pack 100 shits into boxes! Good Luck!" +function getStoryFormspec(number) + storyFormspec = + { + "formspec_version[4]", + "size[18, 16]", + "bgcolor[brown]", + "position[0.5, 0.5]", + "style_type[button;bgcolor=yellow;textcolor=green]", + "hypertext[1, 12.5; 12, 5;;" .. 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 is_game_started = false is_game_finished = false @@ -81,14 +154,7 @@ function pakuj_guwno() end minetest.register_node("poop:box", { description = "cardboard box", - tiles = { - "box_top_closed.png", - "box_top_closed.png", - "box_long_side.png", - "box_long_side.png", - "box_short_side.png", - "box_short_side.png" - }, + tiles = {"box_top_closed.png","box_top_closed.png", "box_long_side.png", "box_long_side.png", "box_long_side.png", "box_long_side.png"}, drop = 'poop:box', legacy_mineral = true, @@ -294,6 +360,9 @@ minetest.register_craftitem("poop:pooper", { }) minetest.register_on_joinplayer(function(player) + -- teleport to 0,0,0 + player:setpos({x=0, y=0, z=0}) + minetest.show_formspec(player:get_player_name(), "story:story_formspec", table.concat(getStoryFormspec(1), "\n")) player:get_inventory():set_list("main", {}) player:setpos({x=0, y=10, z=0})