write "lua" in console then ----------- if fs.exists("/power")==false then print("Program does not exist!") elseif fs.exists("/power")==true then print("Program does exist but can't be opened somehow") else print("Unknown error!") end
- ComputerCraft | Programmable Computers for Minecraft
- → TechnicalCoding's Content
TechnicalCoding's Content
There have been 32 items by TechnicalCoding (Search limited from 29-March 23)
#253107 shell.run() - No such program
Posted by TechnicalCoding on 06 June 2016 - 01:05 AM in Ask a Pro
#253113 shell.run() - No such program
Posted by TechnicalCoding on 06 June 2016 - 01:33 AM in Ask a Pro
#253243 shell.run() - No such program
Posted by TechnicalCoding on 07 June 2016 - 12:39 PM in Ask a Pro
Wanjia, on 06 June 2016 - 02:44 PM, said:
TechnicalCoding, on 06 June 2016 - 01:05 AM, said:
write "lua" in console then ----------- if fs.exists("/power")==false then print("Program does not exist!") elseif fs.exists("/power")==true then print("Program does exist but can't be opened somehow") else print("Unknown error!") end
Then go into a NEW computer and write
pastebin get (pastebin url code) GetPowerBacknow if that was successfull it will download it, then you can rename it to power with
rename GetPowerBack powerI hope this works!
#255069 read() add string into read before writing
Posted by TechnicalCoding on 29 June 2016 - 02:48 AM in Ask a Pro
KingofGamesYami, on 29 June 2016 - 01:02 AM, said:
Not exactly an description, but I want it to contain itself, basicly I am using a while loop to make it go over and over again, and for each time it has to repeat I want it to contain the string it had before the it kind of overlap itself, so basicly just using itself (or duplicate it) to make it just contain itself again..
#255065 read() add string into read before writing
Posted by TechnicalCoding on 29 June 2016 - 12:43 AM in Ask a Pro
EXAMPLE
---------------------------
I have an username variable which use read, they get 3 attempts trying to figure out right details but I want that after first attempt I want the same username to appear to second so no one needs to rewrite the username.
Any ideas? Thanks
#264389 OOP objects in LUA
Posted by TechnicalCoding on 03 February 2017 - 10:17 PM in Ask a Pro
Kouksi44, on 03 February 2017 - 03:08 PM, said:
*shameless self promotion*
I wrote a library that should have everything you showed in your example, defining classes, making members public/private etc.
You might want to check it out if you are interested in how it works.
Interesting, where can I have a look?
#264345 OOP objects in LUA
Posted by TechnicalCoding on 02 February 2017 - 10:51 PM in Ask a Pro
For example in PHP I'd do
<?php class button { public clickEvent; public posX; public posY; private removeEvent; public function __contruct ( x, y, text, fg, bg ) { /* Code here */ } /* ETC */ public function clicked(...){...} public function removed(...){...} } $btn = []; $btn[] = new button ( 1, 1, 'Hello world', colors.blue, colors.white ); ?>
But how would I do this in LUA without having tons of functions that requires to do functonname (table, btn, parameters
Thanks in advance!
#254469 Need ideas for operating system
Posted by TechnicalCoding on 22 June 2016 - 12:58 AM in Programs
Some ideas to more stuff to add in? I really need more ideas..
EDIT: I also have encryption for passwords.
EDIT2: Current ideas: webserver, webbrowser, webChat, web code extension, new gui, download from other pages than pastebin, download zip files and extract them, also upload folders to server with ftp connection (will be uploaded to my website
UPDATES
GitHub project - will require logging in to git hub from CC, there might be a secure way to do this in as creating assignment file and deleting it afterwards when process is done!
#254471 Need ideas for operating system
Posted by TechnicalCoding on 22 June 2016 - 01:13 AM in Programs
KingofGamesYami, on 22 June 2016 - 01:11 AM, said:
#253305 Multitasking in same shell menu
Posted by TechnicalCoding on 08 June 2016 - 07:04 AM in Ask a Pro
Is it possible?
I have an small example of multitasking which I wonder is possible.
local message = read() -- Now it normaly would wait for a response for the read function, -- but is it possible to make it do functions before the function -- recieve any data? ex. ---------------------------------- local message = read() -- V This will happen when its waiting for response. while message = false then -- Do something end -- In the while statement I guess there would be something else ofcourse, but how? -- V Will happen when its getting response for read() if message=="String" then -- Do something end -- Is it possible?
#253664 List all folders but no files from a directory in program
Posted by TechnicalCoding on 12 June 2016 - 09:26 PM in Ask a Pro
I have been searching for hours please help
#264342 Hacking an OS
Posted by TechnicalCoding on 02 February 2017 - 10:14 PM in Ask a Pro
I am currently working on an Advanced operating system and I would happily be doing a collab with you!
I am also very experienced in web languages and will create a appstore for my OS, also I will use online login forms and register forms so the user can connect to the forums and socket servers. And include graphical content such as a draw function to create boxes,
another of my current project is similar to cshtml or asp.net, basically create luahtml, so basically you will be able to use html, and create script tags where lua code will be executed. And a lot of custom events and clickable guis, etc.
Please add me on skype: technicalcoding
if you want to collaborate with me
#254845 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 26 June 2016 - 01:29 PM in Ask a Pro
MKlegoman357, on 22 June 2016 - 09:09 PM, said:
TechnicalCoding, on 22 June 2016 - 06:54 PM, said:
Lyqyd, on 22 June 2016 - 04:55 PM, said:
But this will not detect whether the letter written should be upper case or not (by holding shift button or caps lock). Also, numbers won't work. And if someone will be using a keyboard with a different layout then they won't be able to write anything. You should simply remove the event filter and use both: "key" and "char" events. Using the "key" event for backspace and enter and "char" event for any text characters. Oh, and there's also the "paste" event which you could add support for.
#254506 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 03:51 PM in Ask a Pro
NOTE: I have made these variables shortened from term
c = term.setTextColor
b = term.setBackgroundColor
cp = term.setCursorPos
z = colors
while true do local event, key = os.pullEvent("key") if key == 28 then break elseif key == 14 then local xpos1, ypos1 = term.getCursorPos() if xpos1 > x then cp(xpos1 - 1, ypos1) b(z.black) write(" ") cp(xpos1 - 1, ypos1) end else write(tostring(key)) --- I want this to output the character that belongs to the keycode entered, this do only output the keycode end end
TechnicalCoding, on 22 June 2016 - 04:50 PM, said:
By adding this line after local e,key = os.pullEvent("key")
local k = keys.getName(key)then use "k" instead of key
which now means i can do
if k=="character" THEN
That is how i fixed the problem! Hope everyone can get a use of it!
#254514 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 04:28 PM in Ask a Pro
#254531 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 06:54 PM in Ask a Pro
Lyqyd, on 22 June 2016 - 04:55 PM, said:
#254513 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 04:20 PM in Ask a Pro
Xelostar, on 22 June 2016 - 04:15 PM, said:
if key == keys.enter then ... elseif key == keys.backspace then ... end
or something like that.
This do not work.. ;( sadly
Xelostar, on 22 June 2016 - 04:15 PM, said:
if key == keys.enter then ... elseif key == keys.backspace then ... end
or something like that.
I know how I could use read() function, but that would be too much code in one single line + a mess!
#254508 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 04:03 PM in Ask a Pro
#254519 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 04:50 PM in Ask a Pro
By adding this line after local e,key = os.pullEvent("key")
local k = keys.getName(key)then use "k" instead of key
which now means i can do
if k=="character" THEN
#254510 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 04:07 PM in Ask a Pro
#254516 Converting KEYCODE into CHARACTER
Posted by TechnicalCoding on 22 June 2016 - 04:39 PM in Ask a Pro
Incinirate, on 22 June 2016 - 04:32 PM, said:
TechnicalCoding, on 22 June 2016 - 04:20 PM, said:
Xelostar, on 22 June 2016 - 04:15 PM, said:
if key == keys.enter then ... elseif key == keys.backspace then ... end
or something like that.
This do not work.. ;( sadly
Xelostar, on 22 June 2016 - 04:15 PM, said:
if key == keys.enter then ... elseif key == keys.backspace then ... end
or something like that.
I know how I could use read() function, but that would be too much code in one single line + a mess!
Also just FYI you could just use only key events by creating a reverse lookup table, it's actually very simple:
local lookup = {} for k,v in pairs(keys) do lookup[v] = k end
That way you can just do this:
e,key = os.pullEvent("key") local char = lookup[key] if char=="g" then --do stuff elseif char=="backspace" then --do other stuff end
#264396 ComputerCraft did a miss
Posted by TechnicalCoding on 04 February 2017 - 12:43 AM in Ask a Pro
#264390 ComputerCraft did a miss
Posted by TechnicalCoding on 03 February 2017 - 10:38 PM in Ask a Pro
oos.graphic.btn = function ( obj, string, settings ) if not type ( obj ) == 'table' then -- This is where it misses, because at the bottom you'll see that I put in a string, but for me it fails to see that obj is not a table. oos.functions.throw ( ERROR, 'SELF expects a table, not' .. type ( obj ) ); return false; end end -- ( OpenOS: Debug ) -- oos.graphic.btn ( 'This is not a table', 'Button Content', { ["width"] = 16, ["height"] = 3, ["offsetY"] = 1, ["offsetX"] = 1, ["foregroundColor"] = colors.white, ["backgroundColor"] = colors.red } );
Does anyone else have this problem?
It is not anything wrong with the "oos.functions.throw" function, but anyway, this is how it works:
oos.functions.throw = function ( Type, message ) local ocolor = oos.term.getTextColor ( ); local obgcolor = oos.term.getTextColor ( ); if not type ( Type ) == "string" then oos.term.setTextColor ( oos.settings.types [ ERROR ].bg ); oos.term.setBackgroundColor ( oos.settings.types [ ERROR ].color ); write ( oos.settings.types [ ERROR ].title ); oos.term.setTextColor ( oos.settings.types [ ERROR ].color ); oos.term.setBackgroundColor ( oos.settings.types [ ERROR ].bg ); write ( ' ' .. 'Expected TYPE at oos.functions.throw ( TYPE, message )' ); oos.term.setTextColor ( ocolor ); oos.term.setBackgroundColor ( obgcolor ); print ( '' ); return false; end if oos.settings.types [ Type ] == nil then Type = 'UNKNOWNException'; end oos.term.setTextColor ( oos.settings.types [ Type ].bg ); oos.term.setBackgroundColor ( oos.settings.types [ Type ].color ); write ( oos.settings.types [ Type ].title ); oos.term.setTextColor ( oos.settings.types [ Type ].color ); oos.term.setBackgroundColor ( oos.settings.types [ Type ].bg ); write ( ' ' .. message ); oos.term.setTextColor ( ocolor ); oos.term.setBackgroundColor ( obgcolor ); print ( '' ); -- New Line return true; end
These variables below is being implemented at the the very top of my os:
ERROR = 'ERRORException'; WARNING = 'WARNINGException'; SUCCESS = 'SUCCESSException'; INFO = 'INFOException'; USAGE = 'USAGEException'; set = 'SET'; get = 'GET'; current = 'CURRENT';
So what makes my oos.graphic.btn function fail?
The table which contains the different exceptions in the throw function
-- ( OpenOS: Exception delarations ) -- oos.settings.types = { ['ERRORException'] = { color = c.red, bg = c.black, title = 'Error' }, ['WARNINGException'] = { color = c.yellow, bg = c.black, title = 'Warning' }, ['SUCCESSException'] = { color = c.green, bg = c.black, title = 'Success' }, ['INFOException'] = { color = c.blue, bg = c.black, title = 'Info' }, ['USAGEException'] = { color = c.cyan, bg = c.black, title = 'Usage' }, ['UNKNOWNException'] = { color = c.gray, bg = c.black, title = 'Unknown' } };
#264392 ComputerCraft did a miss
Posted by TechnicalCoding on 03 February 2017 - 11:06 PM in Ask a Pro
Dog, on 03 February 2017 - 10:56 PM, said:
if not type(something) == "something" then
Dog, on 03 February 2017 - 10:56 PM, said:
if type(something) ~= "something" then
#264433 ComputerCraft did a miss
Posted by TechnicalCoding on 04 February 2017 - 11:01 AM in Ask a Pro
Bomb Bloke, on 04 February 2017 - 01:02 AM, said:
But "not type(whatever)" will always be a boolean, which will never be equal to "string".
That is to say,
not type(var) == "string"
... is the same as:
(not type(var)) == "string"
... which is different to:
not (type(var) == "string")
... which is the same as:
type(var) ~= "string"
Thanks for the explanation, helps a lot!
- ComputerCraft | Programmable Computers for Minecraft
- → TechnicalCoding's Content