- Sky
- Blueberry
- Slate
- Blackcurrant
- Watermelon
- Strawberry
- Orange
- Banana
- Apple
- Emerald
- Chocolate
- Charcoal
Dustmuz
-
Content Count
13 -
Joined
-
Last visited
Posts posted by Dustmuz
-
-
i am using OC with a mekanism induction matrix.
but as soon as the number is higher than 2.147.483.647 - the program "halts", because the number is to big.
Is there a way to allow it to have even larger numbers??
as the getEnergy() function of the matrix returns 2.147.483.647 - but nothing higher
i would hate to resort to using computercraft if i can avoid it -
Thanks alot for these examples :)
should get me going :)
if i run into trouble, i will be back :D
-
i couldnt agree more with that.
OC has a ton more possibilities and is integrated with most mods.from the code above, i have added a total of 9 TE resonant energy cells.
1x Extreme reactor (only as last resort, tweaked config so it used 50x the fuel)
8x magmatic dynamo's for main power (cant be controlled with CC - so using a redstone output for this)
2x bio fuel generators (cant be controlled with CC - so using a redstone output for this)from what i've been able to gather, OC can has methods for both mods (TE and industrialforegoing) also a good reason to use OC
This is the code i use for my Extreme reactor and powerstorage
Above here, is all the peripheral wraps, and os.load(ButtonAPI) and a few other "irrelevant" things, nothing that is crucial to the code. Mon, is just the monitor connected to the computer. mon.clear() mon.setCursorPos(2,1) mon.setTextColor(blue) mon.write("Menphis's Power Bank Monitor") mon.setCursorPos(2,4) mon.write("Total Energy Capacity: "..TotalCapMill.." Mill") local function Power() while true do teCell1en = Cell1.getEnergyStored() teCell2en = Cell2.getEnergyStored() teCell3en = Cell3.getEnergyStored() teCell4en = Cell4.getEnergyStored() teCell5en = Cell5.getEnergyStored() teCell6en = Cell6.getEnergyStored() teCell7en = Cell7.getEnergyStored() teCell8en = Cell8.getEnergyStored() teCell9en = Cell9.getEnergyStored() EnergyStored = teCell1en + teCell2en + teCell3en + teCell4en + teCell5en + teCell6en + teCell7en + teCell8en + teCell9en EnergyStoredMill = math.floor(EnergyStored / 1000000) if EnergyStored > 100000 then mon.setCursorPos(2,3) mon.clearLine() mon.setTextColor(green) mon.write("Total Energy Stored: "..EnergyStoredMill.." Mill") elseif EnergyStored < 100000 then mon.setCursorPos(2,3) mon.clearLine() mon.setTextColor(red) mon.write("Total Energy Stored: "..EnergyStored) end mon.setTextColor(white) sleep(2) end end local function ProducedPower() while true do mon.setCursorPos(2,6) mon.setTextColor(red) local Prod = math.floor(Reac.getEnergyProducedLastTick()) mon.write("Produced RF: "..Prod) mon.setTextColor(white) sleep(2) end end local function Temp() while true do mon.setTextColor(green) mon.setCursorPos(2,8) local CaseTemp = math.floor(Reac.getCasingTemperature()) local FuelTemp = math.floor(Reac.getFuelTemperature()) mon.write("Case Temp: "..CaseTemp.." Celcius") mon.setCursorPos(2,9) mon.write("Fuel Temp: "..FuelTemp.." Celcius") mon.setTextColor(white) sleep(2) end end local function button() while true do local event = {t:handleEvents()} if event[1] == "button_click" then t:toggleButton(event[2]) end end end local function rfGen(bool) if bool == true then Reac.setActive(true) else Reac.setActive(false) end end default.label = "Button1" default[1] = "OFF" t:add(default,function(bool) rfGen(bool) return "ON", "OFF" end ,30,1,33,1,red,green,black,black) t:draw() while true do parallel.waitForAny(Temp,ProducedPower,Power,button,rfgen) end
The code for controlling the 4 IC2 Reactors
term.setTextColor(blue) print("Reactor Status") term.setTextColor(red) print("Reactor 1: "..r1active) print("Reactor 2: "..r2active) print("Reactor 3: "..r3active) print("Reactor 4: "..r4active) while true do local event, button, MouseX, MouseY = os.pullEvent("mouse_click") if (MouseX >= 12 and MouseX <= 13) and MouseY == 2 then if r1active == "off" then rs.setOutput("top",true) r1active = "on" pos(1,2) term.clearLine() term.setTextColor(green) term.write("Reactor 1: "..r1active) elseif r1active == "on" then rs.setOutput("top",false) r1active = "off" pos(1,2) term.clearLine() term.setTextColor(red) term.write("Reactor 1: "..r1active) end elseif (MouseX >= 12 and MouseX <= 13) and MouseY == 3 then if r2active == "off" then rs.setOutput("left",true) r2active = "on" pos(1,3) term.clearLine() term.setTextColor(green) term.write("Reactor 2: "..r2active) elseif r2active == "on" then rs.setOutput("left",false) r2active = "off" pos(1,3) term.clearLine() term.setTextColor(red) term.write("Reactor 2: "..r2active) end elseif (MouseX >= 12 and MouseX <= 13) and MouseY == 4 then if r3active == "off" then rs.setOutput("back",true) r3active = "on" pos(1,4) term.clearLine() term.setTextColor(green) term.write("Reactor 3: "..r3active) elseif r3active == "on" then rs.setOutput("back",false) r3active = "off" pos(1,4) term.clearLine() term.setTextColor(red) term.write("Reactor 3: "..r3active) end elseif (MouseX >= 12 and MouseX <= 13) and MouseY == 5 then if r4active == "off" then rs.setOutput("front",true) r4active = "on" pos(1,5) term.clearLine() term.setTextColor(green) term.write("Reactor 4: "..r4active) elseif r4active == "on" then rs.setOutput("front",false) r4active = "off" pos(1,5) term.clearLine() term.setTextColor(red) term.write("Reactor 4: "..r4active) end end end
the 2 code snippets above, is the ones that i need to have running.
as you can see. firs one, that controls the reactor and such, has 4 functions running at the same time, and then another one for the IC2 -
and im back again :(
i've tried playing around with this, and as you say.
It's not just plug and play.
tried reading up on it, and that only confused me even more.
i can get very simple scripts to run, but as soon as i try and do something that pulls info from other blocks, it just stops working.
i ended up just adding in CC again, to be able to do this.
Problem with OC, is that theres not much info to get, anywhere. not even here..
A better description/tutorials on some of the "advanced" stuff, would be very helpfull, and why (from what i see on servers) most people still use CC over OC.
the learning curve for OC, is like climbing to the moon on a ladder.
-
2 hours ago, Molinko said:
Basically the api is more flexible..
local function counter(num) local i = num or 0 while i < 25 do print(i) os.sleep(1) i = i + 1 end end local threadA = thread.create(counter, 1) local threadB = thread.create(counter, 5) --# Normally these will start and continue running asap. However, you --# can block the program from exiting early by using the 'waitForAll' and 'waitForAny' methods i.e thread.waitForAny({threadA, threadB})
Hi again
i actually just made this up.
from what i gather, from the code snippets of the wiki - but it only shows
Start
End
the threads are never run.local thread = require("thread") local component = require("component") local gpu = component.gpu local event = require("event") local colors = require("colors") local term = require("term") gpu.setResolution(120,30) local TEcell1 = component.proxy("98a5d647-be62-4c6a-ba60-749715173e73") local TEcell2 = component.proxy("af0e927a-3235-4f67-ag46-dcd5aed640f8") local TEcell3 = component.proxy("ef7fa5d2-aa29-4258-a573-23d8e73d9ab2") print("start") local t1 = thread.create(function() while true do --cell1 gpu.setBackground(colors.Blue) local maxEnergy = TEcell1.getMaxEnergyStored() gpu.fill(10,9,110,10," ") local cellStored1 = TEcell1.getEnergyStored() local perc = math.floor((cellStored1/maxEnergy)*100) gpu.setBackground(colors.green) gpu.fill(10,9,perc,10," ") term.setCursor(10,8) term.clearLine() print("Resonant Cell: "..perc) end end) local t2 = thread.create(function() while true do --cell2 gpu.setBackground(colors.Blue) local maxEnergy = TEcell2.getMaxEnergyStored() gpu.fill(10,9,110,10," ") local cellStored2 = TEcell2.getEnergyStored() local perc = math.floor((cellStored2/maxEnergy)*100) gpu.setBackground(colors.green) gpu.fill(10,14,perc,15," ") term.setCursor(10,13) term.clearLine() print("Resonant Cell: "..perc) end end) thread.waitForAny({t1, t2}) print("end")
i'm gonna try moving the functions out of the thread.create() as you do in your example, and see if that actually helps..
if it does, then the snippets on the wiki, might have to be changed or explained better at least
EDIT: after messing about a little.
your code works fine, but as soon as try manipulating the screen with the below code inside your function - nothing happens. it just finishes.
if i try and run the code without doing it in a thread. it workslocal maxEnergy = TEcell1.getMaxEnergyStored()local cellStored1 = TEcell1.getEnergyStored()local perc = math.floor((cellStored1/maxEnergy)*100)term.clearLine()term.setCursor(10,13)term.write("Resonant Cell: "..perc)gpu.setBackground(blue)gpu.fill(perc+1,9,100-perc,2," ")gpu.setBackground(black)gpu.setBackground(green)gpu.fill(10,14,perc,2," ")gpu.setBackground(black)local thread = require("thread") local component = require("component") local gpu = component.gpu local event = require("event") local colors = require("colors") local term = require("term") gpu.setResolution(120,30) local TEcell1 = component.proxy("98a5d647-be62-4c6a-ba60-749715173e73") local TEcell2 = component.proxy("af0e927a-3235-4f67-ag46-dcd5aed640f8") local TEcell3 = component.proxy("ef7fa5d2-aa29-4258-a573-23d8e73d9ab2") local function counter(num) local i = num or 0 while i < 25 do --cell1 local maxEnergy = TEcell1.getMaxEnergyStored() local cellStored1 = TEcell1.getEnergyStored() local perc = math.floor((cellStored1/maxEnergy)*100) term.clearLine() term.setCursor(10,8) term.write("Resonant Cell: "..perc) gpu.setBackground(blue) gpu.fill(perc+1,9,100-perc,2," ") gpu.setBackground(black) gpu.setBackground(green) gpu.fill(10,9,perc,2," ") gpu.setBackground(black) end end local function counter1(num) local i = num or 0 while i < 25 do --cell1 local maxEnergy = TEcell1.getMaxEnergyStored() local cellStored1 = TEcell1.getEnergyStored() local perc = math.floor((cellStored1/maxEnergy)*100) term.clearLine() term.setCursor(10,13) term.write("Resonant Cell: "..perc) gpu.setBackground(blue) gpu.fill(perc+1,14,100-perc,2," ") gpu.setBackground(black) gpu.setBackground(green) gpu.fill(10,14,perc,2," ") gpu.setBackground(black) end end local threadA = thread.create(counter, 1) local threadB = thread.create(counter1, 1) --# Normally these will start and continue running asap. However, you --# can block the program from exiting early by using the 'waitForAll' and 'waitForAny' methods i.e thread.waitForAny({threadA, threadB})
-
10 minutes ago, Molinko said:
You want threads. The API is better than the parallel API in my opinion. https://ocdoc.cil.li/api:thread
Thanks.. i'll read up on that, and see if i can make heads and tales of it
-
I like this idea..
Only "problem" i see so far, is the payment system.
It would need to see what player has which fluxgate, and deposit the coins into that fluxgate. but i dont know if OC can recognize a player.
And instead of doing diamond to coins, and coins to RF (i think thats what you are trying at least)
Why not go directly from Diamonds to RF?or does coins only give a certain amount of time, instead of RF?
If you have Thermal expansion, you could even expand on that coin idea, as it can make coins.once i figure out how to run multiple functions/routines at the same time, i might actually give this a shot
-
Hello.
i'm rather new to OC. and missing my Parallel API from CC.
i'm trying to run 4 different functions at the same time, they are writing to different parts of the screen (power monitor)
Is there a way to do this, and what should i read up upon.
personally, i think that the OC wiki, is lacking a great deal, when it comes to examples, and in general explaning things, when youre trying to learn.
it covers the absoute basic of building the computer, and thats about where the usefullness stops - for me at least. its in no way helpfull :( which i find a bit sad, as it should be the goto place :)
so a short code snippet of how you could run multiple functions at the same time would be helpfull. -
Goto
in Programming
havent thought of it this way.
thanks a lot for the input
-
Goto
in Programming
i know this is an old thread.
but its actually exactly what i'm looking for
i have the following codelocal function timer() seconds = 0 while true do ::startover:: if reactor.getActive() == true then while true do seconds = seconds + 1 if seconds == 60 then minutes + 1 seconds = 0 end if minutes == 60 then hours + 1 minutes = 0 end center(2,"Time Running: "hours..":"..minutes..":"..seconds) sleep(1) if reactor.getActive == false then goto startover end end end end end
But as Ingie says, it should be avoided if possible (first time i actually want to use it, as i dont see another way around atm..
but might just be me..
but the code should be pretty self explanitory, when it comes to what it does.it should be noted, that i HAVENT tested the code ingame yet, as i'm writing it while at work.
-
Really nice program
thanks a lot for this
Im starting to use OC now that CC havent moved to 1.10.2 yet.
this helped me get the methods from the components i need..
now i just need to learn the rest hehe -
i just started using OC, and i'm very used to CC and lua 5.1
but have one major problem i cant find in the wiki or here so far
How do i print out a list of commands i can use on a peripheral..
in CC i would just do this
local file = fs.open("config","w")file.writeLine(textutils.serialize(peripheral.getMethods()))file.close()
how would i do something like this in OC??
i like to try things out myself, but so far, im pretty god damn lost on this mod.
Large numbers - greater than 2.147.483.647
in Programming
Posted
i just found it weird, that the "same" method on computercraft is using 64 bit integers.
so i was hoping that there was a way around it with OC