functions.lua 693 B

123456789101112131415161718192021222324252627
  1. function teleport.load()
  2. local file = io.open(minetest.get_worldpath() .. '/teleport_systems', 'r')
  3. if file then
  4. teleport.data = minetest.deserialize(file:read('*a'))
  5. file:close()
  6. else
  7. teleport.data = {}
  8. end
  9. end
  10. function teleport.save()
  11. local file = io.open(minetest.get_worldpath() .. '/teleport_systems', 'w')
  12. file:write(minetest.serialize(teleport.data))
  13. file:close()
  14. end
  15. function teleport.find_stations()
  16. local stations = teleport.data
  17. local results = {}
  18. for strpos, data in pairs(stations) do
  19. local obj = data.name..'|'..strpos
  20. table.insert(results, obj)
  21. end
  22. table.sort(results)
  23. teleport.other_stations = results
  24. end