Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- INCLUDE: engineSetup as startup
- local filehandle0 = fs.open("startup", "w")
- filehandle0.flush()
- filehandle0.writeLine([==[local funs = require("lib/funs")
- -- local settingsFile = fs.open("conf.txt", "w")
- -- settingsFile.writeLine( "startmotor=" );
- funs.setupSettings({
- ["startmotor"] = "",
- ["stressmeter"] = "",
- ["enginespeedmeter"] = "",
- ["outputspeedmeter"] = "",
- ["outputspeedcontroller"] = ""
- })
- local settings = funs.readSettings()
- local startmotor = peripheral.wrap(settings.startmotor)
- local stressmeter = peripheral.wrap(settings.stressmeter)
- local engine_speedometer = peripheral.wrap(settings.enginespeedmeter)
- while true do
- local currentStress = 0
- local maxStress = 0
- local currentSpeed = 0
- if stressmeter ~= nil then
- -- print("Current stress / Max stress: " .. stressmeter.getKineticStress("top") .. "/" .. stressmeter.getKineticCapacity("top"))
- currentStress = stressmeter.getKineticStress("top")
- maxStress = stressmeter.getKineticCapacity("top")
- end
- if engine_speedometer ~= nil then
- -- print("Current speed: " .. engine_speedometer.getKineticSpeed("top"))
- currentSpeed = engine_speedometer.getKineticSpeed("top")
- end
- funs.cls()
- print("Current/max stress: " .. currentStress .. "/" .. maxStress)
- print("Current speed: " .. currentSpeed)
- end]==])
- filehandle0.close()
- -- END INCLUDE: engineSetup
- -- INCLUDE: lib/funs as lib/funs.lua
- local filehandle1 = fs.open("lib/funs.lua", "w")
- filehandle1.flush()
- filehandle1.writeLine([==[local funs = {}
- function funs.split (inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- function funs.readSettings()
- -- print("read settings")
- local settingsFile = fs.open("config.txt", "r")
- local settingsObject = {}
- local line = settingsFile.readLine()
- while line ~= nil do
- -- print("Read: " .. line)
- lineSplit = funs.split(line, "=")
- local ls1 = lineSplit[1]
- local ls2 = lineSplit[2]
- if ls2 == nil then ls2 = "" end
- print("Data: " .. ls1 .. ": " .. ls2)
- settingsObject[ls1] = ls2
- line = settingsFile.readLine()
- end
- return settingsObject
- end
- function funs.setupSettings(settingsList)
- if fs.exists("config.txt") == false then
- local file = fs.open("config.txt", "w")
- file.flush()
- for name, dValue in pairs(settingsList) do
- file.writeLine(name .. "=" .. dValue)
- end
- file.close()
- end
- end
- function funs.cls()
- term.setBackgroundColour(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- end
- return funs
- ]==])
- filehandle1.close()
- -- END INCLUDE: lib/funs
- shell.run("startup")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement