Advertisement
Scarjit

Boiller Calc for Railcraft

Aug 7th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local temp = 20
  2. local fuel = 0
  3. local hp = true
  4. local hpname = "HP"
  5. local size = 36
  6. local ticks = 0
  7. local hplp_div = 0
  8. local maxtemp = 1000
  9. local heatstep = 0.05
  10. local fuelvalue = {1000, 1600, 1600, 3200, 6400, 3200, 32000, 96000}
  11. local fuelname = {"Bucket of Lava", "Charcoal", "Forestry Peat", "Coal", "Coal Coke", "Creosote Oil", "Forestry Bio Fuel", "Buildcraft Fuel"}
  12.  
  13. --user input
  14. print("Which Fuel will you use?")
  15. for i = 1,#fuelname do
  16.     print(i..") "..fuelname[i])
  17. end
  18. local fuelindex = tonumber(io.read())
  19.  
  20. print("What size of Boiler will you use? (1,8,12,18,27,36)")
  21. size = tostring(io.read())
  22.  
  23. local answer = ""
  24. while not ((answer == "h") or (answer == "H") or (answer == "l") or (answer == "L")) do
  25.     print("(H)igh or (L)ow Pressure?")
  26.     answer = io.read()
  27. end
  28. if (answer == "h") or (answer == "H") then hp = true else hp = false end
  29.  
  30. if hp then maxtemp = 1000 else maxtemp = 500 end
  31. if hp then hplp_div = 8 else hplp_div = 16 end
  32. while temp < maxtemp do
  33.     --calculate fuel for tick
  34.     local deltafuel = ((6.4 - size * 0.08) / hplp_div) * size * (1 + 8 * (1 - temp / maxtemp))
  35.     fuel = fuel + deltafuel
  36.     --calculate heat change
  37.     local heatchange = heatstep
  38.     if temp < .25*maxtemp then
  39.         heatchange = heatchange + heatstep
  40.     end
  41.     if temp < .5*maxtemp then
  42.         heatchange = heatchange + heatstep
  43.     end
  44.     if temp < .75*maxtemp then
  45.         heatchange = heatchange + heatstep
  46.     end
  47.     heatchange = heatchange / size
  48.     temp = temp + heatchange
  49.     --advance ticks
  50.     ticks = ticks + 1
  51.     --print("tick "..ticks.." temp: "..temp.." C fuel used: "..fuel)
  52. end
  53.  
  54. local constantfuel = ((6.4 - size * 0.08) / hplp_div) * size * 20 * 3600 / fuelvalue[fuelindex]
  55.  
  56. if hp then hpname = size.."HP" else hpname = size.."LP" end
  57. print(hpname.." takes "..tostring(ticks/20).." seconds ("..tostring(ticks).." ticks) and "..tostring(fuel/fuelvalue[fuelindex]).." "..fuelname[fuelindex].." to heat up.")
  58. print("It will require "..tostring(constantfuel).." "..fuelname[fuelindex].." per hour once at max heat.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement