Advertisement
Newwy

Untitled

Feb 5th, 2018
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. print("-----------------------------------")
  2. print("--------- Reactor Output ----------")
  3. print("----- Optimization Controller -----")
  4. print("-----------------------------------")
  5. print("")
  6.  
  7. minInsertion = 0
  8. maxInsertion = 100
  9. URL = "http://br.sidoh.org/api/simulate?definition="
  10.  
  11. print("Input json stringified reactor defintion: ")
  12. def = io.read()
  13.  
  14. def = string.gsub(def, ""controlRodInsertion":%d+", "replaceMentPos")
  15.  
  16. print("Steam output wanted:")
  17. output = io.read()
  18.  
  19. searchingForInsertionPoints = true
  20. curInsertion = 100
  21.  
  22. while searchingForInsertionPoints do
  23. asdf = string.gsub(def, "replaceMentPos", ""controlRodInsertion":" .. curInsertion)
  24. retStr = http.get(URL .. asdf).readAll()
  25. -- retStr = "asdfasdf;lkj;alksjdf"output":1234"
  26. --get output
  27. for stmOutStr in string.gmatch(retStr, ""output":%d+") do
  28. steam = string.match(stmOutStr, "%d*")
  29. print(curInsertion)
  30. print(steam)
  31. end
  32. --compare
  33. curInsertion = curInsertion - 1
  34. if curInsertion == -1 then
  35. searchingForInsertionPoints = false
  36. end
  37. os.sleep(1.5)
  38.  
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement