Advertisement
Guest User

Untitled

a guest
Nov 25th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. local json = require ("dkjson")
  2.  
  3. resetWorld = {}
  4.  
  5. function resetWorld.load(fileName)
  6. local file = assert(io.open(fileName, 'r'), 'Error loading file: world.json');
  7. local content = file:read("*all");
  8. file:close();
  9. return json.decode(content, 1, nil);
  10. end
  11.  
  12. function resetWorld.save(fileName, data, keyOrderArray)
  13. local content = json.encode(data, { indent = true, keyorder = keyOrderArray });
  14. local file = assert(io.open(fileName, 'w+b'), 'Error loading file: world.json');
  15. file:write(content);
  16. file:close();
  17. end
  18.  
  19. resetWorld.config = resetWorld.load("/home/max/Games/development/test-0.6.1/keepers/CoreScripts/data/world/reset.json")
  20.  
  21. if(resetWorld.config.doReset == true) then
  22. tempWorld = resetWorld.load("/home/max/Games/development/test-0.6.1/keepers/CoreScripts/data/world/world.json")
  23.  
  24. tempWorld.customVariables = {}
  25. tempWorld.factionReputation = {}
  26. tempWorld.factionRanks = {}
  27. tempWorld.topics = {"solstheim","dark brotherhood","apelles matius","the mainland"}
  28. tempWorld.factionExpulsion = {}
  29. tempWorld.kills = {}
  30. -- table.insert() "torasa aram"=1, "scamp_creeper"=1, "mudcrab_unique"=1
  31. tempWorld.journal = [{
  32. "type"=0,
  33. "index"=10,
  34. "quest"="bm_rumors",
  35. "actorRefId"="imperial guard"
  36. },{
  37. "type"=0,
  38. "index"=50,
  39. "quest"="bm_rumors",
  40. "actorRefId"="imperial guard"
  41. },{
  42. "type"=0,
  43. "index"=10,
  44. "quest"="tr_dbattack",
  45. "actorRefId"="db_assassin1b"
  46. },{
  47. "type"=0,
  48. "index"=30,
  49. "quest"="tr_dbattack",
  50. "actorRefId"="imperial guard"
  51. }]
  52.  
  53.  
  54.  
  55.  
  56. resetWorld.save("/home/max/Games/development/test-0.6.1/keepers/CoreScripts/data/world/world.json", tempWorld)
  57. resetWorld.config.doReset = false
  58. resetWorld.save("/home/max/Games/development/test-0.6.1/keepers/CoreScripts/data/world/reset.json", resetWord.config)
  59. end
  60.  
  61. return resetWorld
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement