Advertisement
krock186

Minetest Mod: Add written book on join

May 5th, 2018
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local my_title = "I'm some kind of demonstation text"
  2. local my_contents = [[This is a demonstration
  3. for multiline contents
  4. the end.]]
  5.  
  6. -- For testing
  7. --minetest.register_on_joinplayer(function(player)
  8.  
  9. minetest.register_on_newplayer(function(player)
  10.     local inv = player:get_inventory()
  11.     local book = ItemStack("default:book_written")
  12.     book:get_meta():from_table({
  13.         title = my_title,
  14.         description = my_title,
  15.         owner = "#!SERVER!#",
  16.         text = my_contents,
  17.         page = 1,
  18.         page_max = math.ceil((#my_contents:gsub("[^\n]", "") + 1) / 14)
  19.     })
  20.     inv:add_item("main", book)
  21. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement