Advertisement
Guest User

Mintest nice String player list

a guest
Nov 30th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. function publishplayerlist()
  2. result = "";
  3.  for _,player in ipairs(minetest.get_connected_players())   do
  4.      result = result .. player:get_player_name() .. ", "
  5.  end
  6.  playerlistfilename = minetest.get_modpath("utils") .. "/currentplayers.txt"
  7.  
  8. -- this following command is under comment ... because not nice ...
  9.  --os.execute("/bin/echo '" .. result .. "' > " .. playerlistfilename)
  10. -- here a nicer way .. Thanks to the friends of IRC freenode #minetest friends
  11. local file = io.open(minetest.get_modpath("utils") .. "/currentplayers.txt", "w")
  12. file, err = io.open(filename, "w");
  13.  if (not file) then
  14.     -- write to log error ... do not shutdown server , if this crap append
  15.     print(dump(err))
  16.  else
  17.     file:write(result)
  18.     file:close()
  19.  end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement