Closed SeniorFight closed 9 years ago
Loadfile, dofile, require, io, fs, and coroutines have been implemented as far as I am aware, though some may exist only in OpenOS. They are mentioned in the documentation. If you need them in your custom OS you can either copy/paste them or write your own implementations. I'm not super familiar with lua, but coroutines in many engines do not run in the background. They run on the main thread blocking other code execution, and pass execution back to the main program when they yield. I believe this is the intended function of coroutines, but if you need them to sleep in the background you could probably get around that using the Event API (maybe a timer), or yielding until enough time has elapsed by checking computer.uptime()
from the Computer API.
Turtles? This isn't ComputerCraft!
@fnuecke Well you rekt me.
But explain me dis:
error(tostring( 5 * 5 ))
returns an error, not blue screen saying '25' ...
@SeniorFight Why wouldn't it be normal? The blue screens are 'made' from errors at "hardware"(power etc.)/EEPROM/init.lua level, so if one appears it usually means that something derped hard, errors in programs are caught by OpenOS and printed w/o crashig entire computer
@magik6k i know it but we can edit what bluescreens says. and it doesn't say what I expected (I cant divide nor multiply any numbers)...
error(tostring( 5 * 5 ))
works exactly as expected for me. First I created a program edit err.lua
and pasted the code error(tostring( 5 * 5 ))
, pressing Ctrl+S, then Ctrl+W to save and close, I run the program err
. I receive the expected output err.lua:1: 25
, which indicates at line 1 of err.lua, I threw an error that gave the message 25
. I then tried running the code again in the lua program, to show that infact I used the same command you mentioned, and then modified it to demonstrate the expected change. Are you getting different results than in this picture?
@Hotrian I meant in init.lua without OpenOS system. Because I am making my own operating system from scratch (of course basing on OpenOS, as I am not a genious impllenting basic LUA that got erased for some magic reason... like the most basic import command that made my mind blew up because it's something-must-be but nope, they deleted it)
Difference between OpenComputers and ComputerCraft:
ComputerCraft = shit crafting, easy OS creation and nice implented functions, so no mind blowing.
Opencomputers = epic features, realistic crafting, modules, lovely robots and drones, shitty implented functions so your mind will blew up if you try to make your own OS, unless you copy/pasta the entire code or rewrite it by yourself. + low documentation on the wiki makes me rage because I need to decompile the mod to get some "hidden basic" functions, ex. the kernel.
Well you rekt me.
Uh, I did? Either way, still need clarification on which tooltips you meant, specifically (i.e. for which items).
unless you copy/pasta the entire code or rewrite it by yourself
Which is what every so-called "OS" for CC ever is doing, pretty much. Except they don't have to copy it explicitly, because it's hard-coded and cannot be changed trivially. So yay flexibility, I guess?
low documentation on the wiki [...] "hidden basic" functions
You probably just failed finding this page on the wiki, well-hidden in the tutorials section? While I cannot but agree the wiki's built-in search is utter bullcrap (use google with site:ocdoc.cil.li
) I think the documentation itself is relatively complete.
actually, in CC you cannot really create custom OSes, because you always run on top of CraftOS. If anything you have a custom frontend or a hypervisor (only way around this is to patch the computercraft jar). In OpenComputers a custom OS can get about as low as possible. This allows you to fully manage custom file systems yourself and many other things.
Secondly, seriously, why would you decompile OpenComputers. Just grab the source code and resource files from this repository.
@SeniorFight you don't need to decompile the mod as it is open source. The entirety of the mod is available. The kernel is handled by machine.lua and the default bios which can be crafted is bios.lua. The math functions, tostring, error, etc are loaded by the machine.lua here, which then loads the bios, which then loads the OS. You should have no problem using these functions in your own OS. Infact, there is an article on the wiki here that specifically talks about custom OSes. The custom libraries mentioned on the lua API page here is a list of the libraries exclusive to OpenOS, that you'll have to copy and paste or reimplement. Some users want to customize their OS to the extent that the entire OS is either stripped down or reimplemented, and for those who wish to use the default libraries they are easy to copy over.
I ninja u all.
i actually saw your comment pop up while i was typing and i was like "fuck this, why is this guy always faster"
Stole the link I was gonna use(and did) too :(
Just got to the PC, too, such timing!
@fnuecke
It was my error, because I forgot that:
read(handle, [NOT math.huge, but how much memory I have]) so i had like half of my script and it was prompting true = nil =_= I am an idiot
BUT about the descriptions, in latest NON Dev 1.4.4a you released:
Inventory Upgrade - are u kiddin me? only upgrades the robot's inventory? no? then fix the desc please
Inventory Controller Upgrade
Navigation Upgrade
Solar Generator Upgrade
Tank Upgrade
Tank Controller Upgrade
Tractor Beam Upgrade
AND SO ON...
All of them have only the word "ROBOT" but still this upgrade WORKS for drones. Just saying that You should update their description to make a "global", not only robot, so it's more polished than now.
And goodness you're so active and you read what people do you're awesome fnuecke ;_;
Rekt Me: you responded TO ALL my questions/features list. That's something that makes you awesome.
For everything's sake, I beg you:
TYADSFD:
Tell me You Added Sign I/O For Drones
I consider this issue as closed - you allready rekt me @fnuecke on top, still to polish the game you need to fix the descriptions of (only some) modules.
You made great work. Now I go continue my GUI Based OS... Allready on framework stage.
Still for my custom filesystem, as I never did that, and I suppose you're a genius in this:
setmetatable what's this? i can't understand from official LUA documentations. You use setmetatable to mae a nice effect like in CC:
local file = fs.open(path, "w") file : write("abc")
file : close()
in my filesystem it's like this:
local file = vetafs.open(path, "w") vetafs.write(file, "hi") vetafs.close(file)
Also how to make the readLine to work properly, as mine is:
vetafs.readLine = function(handle) local line = "" local data = nil repeat local data = vetafs.read(handle, 1) if data and data ~= "\n" then line = line .. (data or "") else data = nil end until not data return line or nil end
still returns the "funny" char at end of line.
Because \
and n
are two characters and you're only reading one from the buffer at a time? Together they represent newline
@SeniorFight read the Object Oriented Programming guide, it explains it. Also you may want to put your code in a code block (put a triple backtick followed by a lua
in the line before it annother triple backtick after it - for more details see githubs markdown guide) and indent it
Also, @Hotrian Since when is \n
2 characters. its 0x0A
- 1 byte.
local data = vetafs.read(handle, 1) if data and data ~= "\n" then
I was referring to this, which I took to compare a single char to two, but I guess I am wrong
\n
is an escape sequence to denote a LF char
read the Object Oriented Programming guide, it explains it.
thank you, it's the thing that I was missing for so long...
But I'm pretty sure his data physically contains the characters \ and n separately. If it did not, he would not see
the "funny" char at end of line.
Unless I am misinterpreting. Also unless this is automagically converted at some point
@SeniorFight please note that its more than that one page. click the arrow at bottom to cycle pages
@Kilobyte22 Thank you for this, and yes thanks for noticing me the pages (i didn't see it, just found the most important thing in the world: self variable).
Please take programming questions to the forums. The issue tracker is for bugs / feature discussion.
I would love this feature:
Geolyzer Upgrade : (tier 3 for example) to gather data from turtle/drone center position.
Drones Tier 3 : allowing better memory (tier 2, 2.5), processor (tier 2), more "complexity" thanks to better processors. Of course 2x more energy.
Auto-compat for other mods : Big Reactors has "computer ports" for reactors/turbines. Why not just implent it automaticly?
Tablets with solar panels : when holding, allow getting recharged even if offline, like drones and turtles do.
Descriptions fix : some upgrades works for both drones and turtles, but the description is only for the turtles (robots).
Coroutine not consuming time : allows run processes inside coroutines, without pausing the entire script. Example:
print("Not pausing") coroutine.resume(coroutine.create(function() os.sleep(20) print("Sleeped 20 seconds") end)) print("I continue without sleeping 20 seconds...")
Portable microprocessors : it's like an C4 activator, you right click and it executes primitive function in it's BIOS (EEPROM).
Integrated loadfile, dofile, require, io and fs - Just for easier operating system developping, because it's something that LUA has by default (in some cases).
Programmable CPU (optional) - allows programming the CPU core, so we can set the tmp file, how fast it has to work (yes, add a speed for processes so an tier 1 CPU can't work as fast as tier 3).
Tier 4 for everything : emerald style, even more of everything
a MUST-BE for me, SSDs: hard drives, very fast read/write speed, very costly and low memory capacity. Removing the fact, like in real life, that writing huge amounts of data will make them decay.
Sorry for my bad english, but I think it's good enough for you.