]> git.lizzy.rs Git - Crafter.git/commitdiff
Add book prototype
authoroilboi <47129783+oilboi@users.noreply.github.com>
Tue, 7 Apr 2020 21:19:32 +0000 (17:19 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Tue, 7 Apr 2020 21:19:32 +0000 (17:19 -0400)
README.md
menu/icon.png [new file with mode: 0644]
mods/book/init.lua [new file with mode: 0644]
mods/book/textures/attributes.txt [new file with mode: 0644]
mods/book/textures/book.png [new file with mode: 0644]
mods/book/textures/book_written.png [new file with mode: 0644]
mods/books/init.lua [deleted file]
mods/main/settings.lua
mods/player/init.lua

index d1d614170ceedb6139ac7e6a64be1e6a85e8b726..de15acc1e996fe4feb8a90b784c3943613b749c2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
 
 > Designed for Minetest 5.2.0
 
+>Built using textures from <a href="https://forum.minetest.net/viewtopic.php?t=16407">Mineclone 2</a> 
 ---
 
 # ALPHA STATE CHANGELOG
diff --git a/menu/icon.png b/menu/icon.png
new file mode 100644 (file)
index 0000000..c54f0cf
Binary files /dev/null and b/menu/icon.png differ
diff --git a/mods/book/init.lua b/mods/book/init.lua
new file mode 100644 (file)
index 0000000..27dede3
--- /dev/null
@@ -0,0 +1,110 @@
+--book is item
+--craftable
+--save metadata of text
+--reload text
+--write to make permenant
+
+local open_book_gui = function(itemstack, user)
+       local meta = itemstack:get_meta()
+       local book_text = meta:get_string("book.book_text")
+       if book_text == "" then
+               book_text = "Text here"
+       end
+       local book_title = meta:get_string("book.book_title")
+       if book_title == "" then
+               book_title = "Title here"
+       end
+       
+       book_writing_formspec = "size[9,8.75]"..
+               "background[-0.19,-0.25;9.41,9.49;gui_hb_bg.png]"..
+               "style[book.book_text,book.book_title;textcolor=black;border=false;noclip=false]"..
+               "textarea[0.3,0;9,0.5;book.book_title;;"..book_title.."]"..
+               "textarea[0.3,0.3;9,9;book.book_text;;"..book_text.."]"..
+               "button[-0.2,8.3;1,1;book.book_write;write]"..
+               "button[8.25,8.3;1,1;book.book_ink;ink  ]"
+       minetest.show_formspec(user:get_player_name(), "book.book_gui", book_writing_formspec)
+end
+
+local open_book_inked_gui = function(itemstack, user)
+       local meta = itemstack:get_meta()
+       local book_text = meta:get_string("book.book_text")
+       
+       local book_title = meta:get_string("book.book_title")
+       
+       book_writing_formspec = "size[9,8.75]"..
+               "background[-0.19,-0.25;9.41,9.49;gui_hb_bg.png]"..
+               "style[book.book_text,book.book_title;textcolor=black;border=false;noclip=false]"..
+               "textarea[0.3,0;9,0.5;book.book_title;;"..book_title.."]"..
+               "textarea[0.3,0.3;9,9;book.book_text;;"..book_text.."]"..
+               "button_exit[4,8.3;1,1;close;close]"
+               
+       minetest.show_formspec(user:get_player_name(), "book.book_gui", book_writing_formspec)
+end
+
+minetest.register_on_player_receive_fields(function(player, formname, fields)
+       if not formname == "book.book_gui" then return end
+       
+       if fields["book.book_write"] and fields["book.book_text"] and fields["book.book_text"] then
+               local itemstack = ItemStack("book:book")
+               local meta = itemstack:get_meta()
+               meta:set_string("book.book_text", fields["book.book_text"])
+               meta:set_string("book.book_title", fields["book.book_title"])   
+               meta:set_string("description", fields["book.book_title"])
+               
+               player:set_wielded_item(itemstack)
+               minetest.close_formspec(player:get_player_name(), "book.book_gui")
+       elseif fields["book.book_ink"] and fields["book.book_text"] and fields["book.book_text"] then
+               local itemstack = ItemStack("book:book_written")
+               local meta = itemstack:get_meta()
+               meta:set_string("book.book_text", fields["book.book_text"])
+               meta:set_string("book.book_title", fields["book.book_title"])   
+               meta:set_string("description", fields["book.book_title"])
+               
+               player:set_wielded_item(itemstack)
+               minetest.close_formspec(player:get_player_name(), "book.book_gui")
+       end
+end)
+
+
+
+minetest.register_craftitem("book:book",{
+               description = "Book",
+               groups = {book = 1, written = 0},
+
+               inventory_image = "book.png",
+               
+               on_place = function(itemstack, user, pointed_thing)
+                       print("make books placable on the ground")
+                       open_book_gui(itemstack, user)
+               end,
+
+               on_secondary_use = function(itemstack, user, pointed_thing)
+                       open_book_gui(itemstack, user)
+               end,
+})
+
+minetest.register_craftitem("book:book_written",{
+               description = "Book",
+               groups = {book = 1, written = 1},
+
+               inventory_image = "book_written.png",
+               
+               on_place = function(itemstack, user, pointed_thing)
+                       print("make books placable on the ground")
+                       open_book_inked_gui(itemstack, user)
+               end,
+
+               on_secondary_use = function(itemstack, user, pointed_thing)
+                       open_book_inked_gui(itemstack, user)
+               end,
+})
+
+minetest.register_craft({
+       output = "book:book",
+       recipe = {
+               {"main:wood","weather:snowball","main:wood"},
+               {"main:wood","weather:snowball","main:wood"},
+               {"main:wood","weather:snowball","main:wood"},
+       }
+})
+--book book book
diff --git a/mods/book/textures/attributes.txt b/mods/book/textures/attributes.txt
new file mode 100644 (file)
index 0000000..23a1ead
--- /dev/null
@@ -0,0 +1 @@
+book - https://github.com/minetest/minetest_game/blob/master/mods/default/textures/default_book.png
\ No newline at end of file
diff --git a/mods/book/textures/book.png b/mods/book/textures/book.png
new file mode 100644 (file)
index 0000000..e7dea0d
Binary files /dev/null and b/mods/book/textures/book.png differ
diff --git a/mods/book/textures/book_written.png b/mods/book/textures/book_written.png
new file mode 100644 (file)
index 0000000..9d336e9
Binary files /dev/null and b/mods/book/textures/book_written.png differ
diff --git a/mods/books/init.lua b/mods/books/init.lua
deleted file mode 100644 (file)
index 67373c9..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
---book is item
---craftable
---save metadata of text
---reload text
---write to make permenant
-
-
index 1133e588980211d7ff5a93be994b0cb1505f9a56..c4c03c07a0b3d97b5287527464ee31ac60fa9917 100644 (file)
@@ -17,11 +17,17 @@ minetest.register_on_mods_loaded(function()
                        local groups = def.groups
                        groups["dig_immediate"] = 3
                end
+               local stack_max = minetest.registered_items[name].stack_max
+               if stack_max == 99 then
+                       stack_max = 1000
+               end
                minetest.override_item(name, {
-                       stack_max = 1000,
+                       stack_max = stack_max,
                })
        end
        for name,_ in pairs(minetest.registered_craftitems) do
+               local stack_max = minetest.registered_items[name].stack_max
+               print(stack_max)
                minetest.override_item(name, {
                        stack_max = 1000,
                })
index 6d638718ea67dbebb9d0561a78de8d07eb7e2437..ca904a2ce324268b4c2eebb47acba6c253b431ff 100644 (file)
@@ -11,6 +11,10 @@ minetest.register_on_joinplayer(function(player)
                --alignment = {x=-1,y=0},
                offset = {x=-180, y=19},
        })
+       minetest.chat_send_player(player:get_player_name(), minetest.colorize("red", "PLEASE STAY SAFE DURING THE CORONAVIRUS OUTBREAK"))
+       minetest.chat_send_player(player:get_player_name(), minetest.colorize("blue", "PLEASE STAY SAFE DURING THE CORONAVIRUS OUTBREAK"))
+       minetest.chat_send_player(player:get_player_name(), minetest.colorize("yellow", "PLEASE STAY SAFE DURING THE CORONAVIRUS OUTBREAK"))
+       minetest.chat_send_player(player:get_player_name(), minetest.colorize("white", "PLEASE STAY SAFE DURING THE CORONAVIRUS OUTBREAK"))
 end)
 
 --hurt sound