28 posts
Posted 31 March 2015 - 12:48 PM
1140 posts
Location
Kaunas, Lithuania
Posted 31 March 2015 - 04:16 PM
After you load an API you access it through the APIs file name, in your case it's Color. So you'd use Color.CBlack, Color.CGray, etc..
28 posts
Posted 31 March 2015 - 04:54 PM
After you load an API you access it through the APIs file name, in your case it's Color. So you'd use Color.CBlack, Color.CGray, etc..
It's work! Thank you ;)/>
P.S. I forget about my question.
How can I do autostart program? For example: I powered-on my computer and started program for authorization.
Edited on 31 March 2015 - 03:20 PM
1080 posts
Location
In the Matrix
Posted 31 March 2015 - 05:37 PM
create a file named startup, and then inside that have shell.run("yourfilehere")
Or just rename your file to startup, either way
Edited on 31 March 2015 - 03:37 PM
28 posts
Posted 31 March 2015 - 05:55 PM
create a file named startup, and then inside that have shell.run("yourfilehere")
Or just rename your file to startup, either way
Ok, it's clear, thank you. And I have another problem :D/>
If a press CTRL+T program will be closed, how can I denied it?
779 posts
Location
Kerbin
Posted 31 March 2015 - 06:49 PM
#1
use shell.run instead of os.loadAPI if you want to use them as you used in the posted pictures (CBlack and not Color.CBlack)
3057 posts
Location
United States of America
Posted 31 March 2015 - 06:59 PM
Put this at the top of your script:
os.pullEvent = os.pullEventRaw
It'll prevent control+T, but will not prevent control+R or control+S.
1140 posts
Location
Kaunas, Lithuania
Posted 31 March 2015 - 07:41 PM
While KingofGamesYami's solution works, it will disable CTRL-T in
all programs. You should save the original 'os.pullEvent' and restore it whenever your program exits:
--# save the original os.pullEvent
local old_os_pullEvent = os.pullEvent
--# override it to disable termination
os.pullEvent = os.pullEventRaw
--# your main program's code goes here
...
--# put this wherever the program exits to allow termination in other programs
os.pullEvent = old_os_pullEvent
28 posts
Posted 31 March 2015 - 08:41 PM
Thank you for your helping! If you so kindness can you help me again? :)/>
I have a code:
local function gui()
for i=1,4 do
if i == Selector then
term.setTextColor(Color.Red)
write(">")
end
term.setTextColor(Color.White)
print(Menu[i])
end
end
gui()
while true do
local scancode = os.pullEvent("key")
if scancode == 200 then
Selector = Selector-1
if Selector<1 then Selector = 1 end
gui()
elseif scancode == 208 then
Selector = Selector+1
if Selector>4 then Selector=4 end
gui()
elseif scancode == 28 and Selector == 4 then
break
end
end
When I press Arrow Up or Down nothing is go on. What is wrong?
Edited on 31 March 2015 - 06:42 PM
7083 posts
Location
Tasmania (AU)
Posted 31 March 2015 - 09:19 PM
os.pullEvent() returns an event type followed by its parameters. You want something like:
local event, scancode = os.pullEvent("key")
Don't forget the
keys API! This allows you to make your code much more readable, eg:
if scancode == keys.up then
1140 posts
Location
Kaunas, Lithuania
Posted 31 March 2015 - 09:20 PM
That's because os.pullEvent
always returns the event as its first parameter. The second parameter would be the key code. You can also use the keys table to lookup keys
local event, key = os.pullEvent("key")
if key == keys.up then --# up arrow button was pressed
...
elseif key == keys.down then --# down arrow button was pressed
...
end