- Sky
- Blueberry
- Slate
- Blackcurrant
- Watermelon
- Strawberry
- Orange
- Banana
- Apple
- Emerald
- Chocolate
- Charcoal
-
Content Count
451 -
Joined
-
Last visited
-
Days Won
35
Everything posted by Molinko
-
I'd bet that the io object is just a table and there's some metamethod stuff going on. So, testing for the field 'stdin' is actually nil. Maybe try simply 'io.read' or 'term.read' and testing the return value(s)
-
I'll try to keep this simple.. That said, I'm too lazy to bug test it.. local component = require 'component' local function readEnergy() local sumEnergy = 0 for address, ctype in component.list('ic2_te_mfsu') do local amount = component.invoke(address, 'getEnergy') sumEnergy = sumEnergy + amount end return sumEnergy end local stored = 0 while true do stored = readEnergy() print('stored energy:', stored) -- not pretty. os.sleep(.5) end
-
Firstly you're mixing up file:read and file:write.. One writes to the file and the other reads. local config = {} for line in io.lines "/path/to/config.txt" do table.insert(config, line) end print(config[3]) -- # 3rd line in your config -- # this is probably the simplest way but there are others. To read a specific line in a file you'd have to know the exact offset of bytes until the information you're trying to read.
-
It writes to the current line of a new file, so in this case it'd be the 1st line. To read the first line just open the file in read mode ` file = io.open("myfile", "r") Ip = file:read("*l") file:close() ` *l reads 1 line from a file 1 reads one byte from a file
-
file = io.open("/path/to/config.txt", "w") file:write(newIP) file:close()
-
Bummer.. I guess because user input is not strictly a file it's not behaving the way I expected.. perhaps you'll have to roll your own user input with event.pull..
-
I could be wrong about io.read... perhaps post your code so I can see what's going on.
-
Io.read should yield the thread until enter is hit or the arg to it is satisfied ie after 2 characters. setCursorBlink will only set the blink mode of the cursor
-
To limit the number of characters read you can pass a number to io.read. i.e `io.read(2)` As for the cursor blinking and overwriting your input box you can either make your input box larger or turn the cursor blinking off with `term.setCursorBlink(false)`
-
The lib you're looking for are cursor.lua & full_cursor.lua but I'm not sure these will do what you're seeking to accomplish I just remember hearing about them... Also my example was done in a way that it could be modified to control the windows(and thus the cursors) of other processes. If you just want to access the current processes window it may be simpler with the tty lib. local tty = require "tty" local event = require "event" local kb = require "keyboard" local window = tty.window local handle = event.listen("touch", function(_, _, x, y) window.x = x window.y = y
-
Was this any help? I forgot, but there is actually a cursor library in the later versions of openos that you might want to check out.. I haven't used it and I'm not familiar with it at all but that might be a better solution.
-
okay so its a bit tricky cause i dont know what exactly you're trying to pull but ill give it a shot... local term = require "term" local kb = require "keyboard" local event = require "event" local process = require "process" local component = require "component" local window = term.internal.open() -- # creates a full screen window. optionally provide (dx, dy, width, height) term.bind(component.gpu, window) -- # bind the primary gpu to the window we made local proc = process.info() -- # get an instance of this process' details local handle = event.listen("touch", function(_, _, x, y) --
-
Each process in openos has its own instance of a cursor. It's stored in the window property of a process I believe.. try assigning to the processes window cursor as term.setCursor will only set the cursor of the process calling it... I can't test any code ATM so you may have some exploring to do
-
Are you trying to move the cursor of another program like 'edit' or something?? I'm a bit lost. Perhaps post all your code
-
Are you using term.setCursor??
-
I'm not super familiar with AE but I think you need an export bus and a robot or drone with an inventory controller
-
If event.listen is after a continuous loop then it wont be called until that block is finished. To use event.listen it should be called before the loop starts. Note: the loop will have to yield somehow via either event.pull or os.sleep or computer.pullSignal. while (some_condition) do doSomething(data) os.sleep(5) doSomethingElse(more, data) end event.listen('some_event', listener) -- # this will not run until `some_condition` above returns false or there is an error event.listen('some_event', listener) while (some_condition) do doSomething(data) os.sleep(5) -- # if an even
-
Dude... Stahhhppppp.
-
How to write files from outside the directory?
Molinko replied to SuperSamir's question in Programming
How big is the serialized table and what kind of values are in the table? Are there recursive entries or functions in the table? -
How to write files from outside the directory?
Molinko replied to SuperSamir's question in Programming
Possible. Maybe. But definitely not practical. You would use the network card along with client and host programs on each machine. Computers dont have access to each others components so any communication can be done over a network. You can write a program on one machine to request access and write data over a network connection and another program on another machine to answer requests and read/write data from that connection. Im not really sure of another way to perform this. Perhaps others can chime in. -
How to write files from outside the directory?
Molinko replied to SuperSamir's question in Programming
I don't believe one computer can edit another computers files unless they are connected via some sort of client program over a network which you would have to write. io.write it's for writing to running processes or files in the same machine -
How to write files from outside the directory?
Molinko replied to SuperSamir's question in Programming
I'm having a hard time understanding your question. Can you be more descriptive of want you want to achieve? -
So there are two ways to do this. The first is a little more complex. You can simply have two screens and one gpu and switch which screen the gpu is bound to and draw. The second and probably better way is to have two gpus, one for each screen. -- # 2 screens 1 gpu local component = require "component" local prim_screen = component.gpu.getScreen() local sec_screen -- # get the second(non primary or unbound) screen address from the dev fs local f = assert(io.open "/dev/components/by-type/screen/1/address") sec_screen = f:read "*a" -- # read the file which has the component address f:close(
-
I'm afraid it's not possible. The max screen resolution is 160x50. But you could use multiple screens for extra real estate