Add book prototype
This commit is contained in:
parent
11d9f4b47a
commit
851177f7b7
@ -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
|
||||
|
BIN
menu/icon.png
Normal file
BIN
menu/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 751 B |
110
mods/book/init.lua
Normal file
110
mods/book/init.lua
Normal file
@ -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
|
1
mods/book/textures/attributes.txt
Normal file
1
mods/book/textures/attributes.txt
Normal file
@ -0,0 +1 @@
|
||||
book - https://github.com/minetest/minetest_game/blob/master/mods/default/textures/default_book.png
|
BIN
mods/book/textures/book.png
Normal file
BIN
mods/book/textures/book.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
mods/book/textures/book_written.png
Normal file
BIN
mods/book/textures/book_written.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -1,7 +0,0 @@
|
||||
--book is item
|
||||
--craftable
|
||||
--save metadata of text
|
||||
--reload text
|
||||
--write to make permenant
|
||||
|
||||
|
@ -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,
|
||||
})
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user