krock186

Minetest Mod: Add written book on join

May 5th, 2018
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×