Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. minetest.after(0, function()
  2.     spark_file = io.open(minetest.get_worldpath() .. "/sparks.txt", "w")
  3.     io.input(spark_file)
  4.     io.output(spark_file)
  5.  
  6.     spark_count = minetest.deserialize(io.read("*all"))
  7. end)
  8.  
  9. function save_sparks()
  10.     io.write(minetest.serialize(spark_count))
  11. end
  12.  
  13. minetest.register_chatcommand("sparks", {
  14.     func = function(name, param)
  15.  
  16.         if spark_count[name] == nil then
  17.             spark_count[name] = 25
  18.             minetest.chat_send_player(name, "You have been given " .. spark_count[name] .. " sparks to get you started.")
  19.         else
  20.             minetest.chat_send_player(name, "You have " .. spark_count[name] .. " sparks.")
  21.         end
  22.     end
  23. })
  24.  
  25. minetest.register_on_shutdown(function()
  26.     save_sparks()
  27.     io.close(spark_file)
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement