This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
perkelekurat's profile picture

Permanent redstone change

Started by perkelekurat, 12 May 2012 - 11:21 AM
perkelekurat #1
Posted 12 May 2012 - 01:21 PM
Hello. I wrote a small and easy program, which controls status of IC2 nuclear reactor using redstone ("on" when redstone disabled/"off" when redstone enabled). For example, I disable reactor ("core stop" command). Everything works true, but when I restart the singleplayer, redstone returns to 0. How can I save changes of redstone permanently?

[attachment=224:reactorstart.png]
libraryaddict #2
Posted 12 May 2012 - 01:38 PM
Save the state into a file.
Eg I like to do this.

if fs.exists("State") then
  dofile("State")
end

function writeState()
  PMan = io.open("State", "w")
  PMan:write("rs.setOutput("..[["]].."back"..[["]]..", "..rs.getInput("back")..")")
  PMan:close()
end

Then run writeState() every time it changes
perkelekurat #3
Posted 12 May 2012 - 03:10 PM
Thanks for help.