Jump to content


danielsv03's Content

There have been 53 items by danielsv03 (Search limited from 29-March 23)


By content type

See this member's


Sort by                Order  

#276544 Insert help

Posted by danielsv03 on 31 March 2018 - 04:51 PM in Ask a Pro

 EveryOS, on 31 March 2018 - 04:05 PM, said:

Try the textutils.serialize and fs.open functions
Yeah but how would i go from there?



#276542 Insert help

Posted by danielsv03 on 31 March 2018 - 03:50 PM in Ask a Pro

Hello, So basicly i have a sort of dictionary in a dictionary sort of table like this
icons = {
["painter_prog"] = {path = "root/system/Apps/painter/paint.icon"; config = "root/system/Apps/painter/Config.conf"; prog = "root/system/Apps/painter/painter.exf"};
["lua_shell_prog"] = {path = "root/system/Apps/Lau_Shell/lua_shell.icon"; config = "root/system/Apps/Lau_Shell/Config.conf"; prog = "root/system/Apps/Lau_Shell/Lua_Shell.exf"};
["Settings_prog"] = {path = "root/system/Apps/settings/settings.icon"; config = "root/system/Apps/settings/Config.conf"; prog = "root/system/Apps/settings/settings.exf"};
}

Right now for each line i'm adding them manually but i want it to be bale to add them automaticly via a program for example for a like an appstore program where for each app it will add the programs to that table automaticly

Thanks!



#268500 Buttons?

Posted by danielsv03 on 24 July 2017 - 08:21 AM in Ask a Pro

View PostKrul__Tepes, on 23 July 2017 - 05:24 PM, said:

both these replies confuse me xD

well Danels makes sense but the 4th line
okay so the 4th line is to tell the program where it should accept the click/where the button area is
a good way to do this is too tell it first: if x is more or equal to example 34 and x is less or equal too 50 this will keep it in between 34 and 50 as x
picture: ----->34 between 50<-----

and lastly the Y it tells if the y is ex on line 3 then continue if all those is correct.
Note: you can do the same with Y as with x

I tried to do my best explaining just ask if you have any questions :)



#268472 Buttons?

Posted by danielsv03 on 23 July 2017 - 12:15 PM in Ask a Pro

it depends if you want gui buttons, you could use many different ways of this but one way is to do ex: paintutils.drawFilledBox(1, 1, 10, 19, colors.gray)
and from there you want an mouse click detection and mouse click position

ex:

function click() --this function is for checking where and if clicked
    event, button, x, y = os.pullEvent("mouse_click") --this will call the event with the variables button, x, y
    if button == 1 then --if user click left click  (2 is for right click and 3 is for middle click)
        if x>=34 and x<= 45 and y == 3 then --check if x is more or equal to 34 and less or equal too 45 and Y is equal to 3 thats gonna be the area  where the button is
       shell.run("program to run here") --runs the program
       end
    end
end



#267714 [2019] [1.12.2] [Survival] LurCraft : We're back, and better than ever!

Posted by danielsv03 on 20 June 2017 - 12:29 PM in Servers

Ehhm so i installed the mod pack and the server that shows up is the wrong version and when i try this ip lc.krist.club it just says java.connection.refused os something so.. what am i doing wrong?



#267699 parallel.watForAny problem

Posted by danielsv03 on 19 June 2017 - 05:23 PM in Ask a Pro

Okay thanks i will read it now



#267696 parallel.watForAny problem

Posted by danielsv03 on 19 June 2017 - 02:18 PM in Ask a Pro

Okay guys so this is what i have done so far but still it prints them in the prompt window how should i fix that? if you remove prompt from the parallel.wairForAny
then it prints like it should be doing but the the prompt of course is gone so do an know why?
code
local w,h = term.getSize()

uis = true
ui = "Startup"
his = false
hi = "none"
comm = none
drive = false
drivepos = "none"
function setup()
  term.setBackgroundColor(colors.lightGray)
  print("cleaning")
  term.setCursorPos(1, 1)
  term.clear()
  gui()
end

function gui()
paintutils.drawFilledBox(1, 1, 90, 2, colors.orange)
term.setCursorPos(math.floor(w-string.len("Console OS 2.1"))/2, 2)
term.setTextColor(colors.white)
print("Console OS 2.1")
end

function display()
buf = window.create(term.current(),1,3,51,17)
buf.setBackgroundColor(colors.lightGray)
oldterm = term.redirect(buf)
term.clear()
--print("ye")
while true do

sleep(0.5)
--oldterm = term.redirect(buf)
--print("Ye")
if uis == true then uis = false
  print("User: "..ui)

  --coroutine.yield()
  --HERE DO SOMETHING TO GO BACK TO PROMPT OR HANDLER
  --print("Boi")
  term.redirect(oldterm)
elseif his == true then his = false
  print(hi)
  --coroutine.yield()
  --HERE DO SOMETHING TO GO BACK TO PROMPT OR HANDLER
  --print("bois")
  term.redirect(oldterm)
else
  --coroutine.yield()
  --HERE DO SOMETHING TO GO BACK TO PROMPT OR HANDLER
  --print("bo")
  term.redirect(oldterm)
end
end

end
function prompt()
--sleep(0.5)
buff = window.create(term.current(),1,17,51,1)
buff.setBackgroundColor(colors.gray)
while true do
oldtermm = term.redirect(buff)
term.setCursorPos(1, 1)
term.clear()
write(">> ")
--term.redirect(oldterm)
local com = read()
ui = com
uis = true
--coroutine.yield()
--HERE DO SOMETHING TO GO BACK TO DISPLAY OR HANDLER
oldterm = term.redirect(buf)
end
end
function handler()
while true do
sleep(0.5)
left = peripheral.isPresent("left")
right = peripheral.isPresent("right")
bottom = peripheral.isPresent("bottom")
top = peripheral.isPresent("top")
front = peripheral.isPresent("front")
back = peripheral.isPresent("back")
if left == true then
  his = true
	    drivepos = "left"
	    drive = true
	    hi = ("Detected drive "..drivepos)
	   oldterm = term.redirect(buf)
elseif right == true then
  his = true
	    drivepos = "right"
	    drive = true
	    hi = ("Detected drive "..drivepos)
	    oldterm = term.redirect(buf)
else
	    drive = false
end
--HERE DO SOMETHING TO GO BACK TO PROMPT OR DISPLAY
end
end


setup()
parallel.waitForAny(display, prompt, handler)
--display()
--prompt()



#267695 parallel.watForAny problem

Posted by danielsv03 on 19 June 2017 - 02:04 PM in Ask a Pro

View PostLupus590, on 19 June 2017 - 10:05 AM, said:

You may want to look at how multishell handles it's window switching
Where can i find that?



#267691 parallel.watForAny problem

Posted by danielsv03 on 19 June 2017 - 09:04 AM in Ask a Pro

View PostBomb Bloke, on 19 June 2017 - 02:05 AM, said:

A little formatting would make that much easier to read, but glancing over it, the main problem I see is that you're expecting the different functions to render to different windows. ComputerCraft won't "remember" which window each function last redirected to - it's up to you to ensure that the correct window is selected at the time each coroutine wishes to start rendering.


ohh so i will just have to redirect them at the correct time



#267679 parallel.watForAny problem

Posted by danielsv03 on 18 June 2017 - 08:02 PM in Ask a Pro

View PostKingofGamesYami, on 18 June 2017 - 07:58 PM, said:

Thats... not how parallel works, nor is it the way to accomplish what you want. You dont want to run functions simultaneously, especially when said functions interact with the user.


Well what would a good way to do this?



#267677 parallel.watForAny problem

Posted by danielsv03 on 18 June 2017 - 07:54 PM in Ask a Pro

Hello so i'm making a console for practice as for a BIGGER project i want it to run multiple functions at the same time with parallel.waitForAny api but the thing is that is just glitches it seems to pause the functions before they have finished why?
i want them to pause the function where it says
--DO SOMETHING HERE TO GO BACK TO BLA BLA BLA
then continue the function when it gets back to it

here is the code
and a brief explanation to what it should do
so the display function will always look if an variable like his changes if so then print the suggested variable and the prompt will take in user commands and send it to the display so the display show it and the last thing is the handler with checks if it founds a peripheral attached to it if so send that to the display


code

local w,h = term.getSize()

uis = true
ui = "Startup"
his = false
hi = "none"
comm = none
drive = false
drivepos = "none"
function setup()
  term.setBackgroundColor(colors.lightGray)
  print("cleaning")
  term.setCursorPos(1, 1)
  term.clear()
  gui()
end

function gui()
paintutils.drawFilledBox(1, 1, 90, 2, colors.orange)
term.setCursorPos(math.floor(w-string.len("Console OS 2.1"))/2, 2)
term.setTextColor(colors.white)
print("Console OS 2.1")
end

function display()
buf = window.create(term.current(),1,3,51,17)
buf.setBackgroundColor(colors.lightGray)
oldterm = term.redirect(buf)
term.clear()
while true do
sleep(0.5)
print("Ye")
if uis == true then uis = false
  print("User: "..ui)

  --coroutine.yield()
  --HERE DO SOMETHING TO GO BACK TO PROMPT OR HANDLER
elseif his == true then his = false
  print(hi)
  --coroutine.yield()
  --HERE DO SOMETHING TO GO BACK TO PROMPT OR HANDLER
else
  --coroutine.yield()
  --HERE DO SOMETHING TO GO BACK TO PROMPT OR HANDLER
end
end

end
function prompt()
--sleep(0.5)
buff = window.create(term.current(),1,17,51,1)
buff.setBackgroundColor(colors.gray)
oldterm = term.redirect(buff)
while true do
term.setCursorPos(1, 1)
term.clear()
write(">> ")
local com = read()
ui = com
--coroutine.yield()
--HERE DO SOMETHING TO GO BACK TO DISPLAY OR HANDLER
end
end
function handler()
while true do
sleep(0.5)
left = peripheral.isPresent("left")
right = peripheral.isPresent("right")
bottom = peripheral.isPresent("bottom")
top = peripheral.isPresent("top")
front = peripheral.isPresent("front")
back = peripheral.isPresent("back")
if left == true then
  his = true
		drivepos = "left"
		drive = true
elseif right == true then
  his = true
		drivepos = "right"
		drive = true
		hi = ("Detected drive "..drivepos)
else
		drive = false
end
--HERE DO SOMETHING TO GO BACK TO PROMPT OR DISPLAY
end
end


setup()
parallel.waitForAny(display, prompt, handler)
--display()
--prompt()



Any help is useful



#267673 Error handling no function

Posted by danielsv03 on 18 June 2017 - 01:33 PM in Ask a Pro

View PostExerro, on 18 June 2017 - 12:49 PM, said:

`pcall` and `xpcall` are the only native ways of catching errors. They both accept functions as arguments. If you want to catch an error, you need the code to be inside a function to pass it to either. All Lua code can be placed inside a function and called without any differences:
literally_any_code
--# is the same as
(function() literally_any_code end)()
with the slight exception of stack-related stuff being a little different, but inside CC, that's almost never a problem.

If your code isn't working when put in a function, something else is going wrong, and you should address that issue. We can't help with an ambiguous error message and no source code, however. (i.e. give the source code and you'll get help!)

My best shot without source is that there's a chance you called your main function something that essentially overrides another function, so instead of calling that other function, it's calling itself, resulting in a stack overflow.

View PostBomb Bloke, on 18 June 2017 - 09:48 AM, said:

We cannot suggest alterations to that which we cannot see.

here



#267665 Error handling no function

Posted by danielsv03 on 18 June 2017 - 08:57 AM in Ask a Pro

Well if i use i won't be able to do the error handling so any solutions would be help full :)



#267651 Error handling no function

Posted by danielsv03 on 17 June 2017 - 04:10 PM in Ask a Pro

there is no need for that i think, the Exact error is: dow97: vm error: java.lang.ArrayIndexOutOfBoundsExecption



#267649 Error handling no function

Posted by danielsv03 on 17 June 2017 - 03:52 PM in Ask a Pro

View PostLupus590, on 17 June 2017 - 01:51 PM, said:

You have something like this:
print("hello world")

What KingofGamesYami is suggesting is something like this:
local function main()
  print("hello world")
end
local ok, err = pcall(main)
if not ok then
  --# handle error
  print("error: "..err) --# print out the error
end

Thats wha i have been doing but the problem is that the pat of the script is the GUI handling part and it gets an error if it is in a function so i moved it ou of the function and still want the error handling btw the method you guys told that was the one i was using also btw the error wasn't because of the error handling its that the GUI handling part was just timing out or something



#267645 MLG teachers and students table bonanza!

Posted by danielsv03 on 17 June 2017 - 12:02 PM in Ask a Pro

 Reinified, on 17 June 2017 - 11:40 AM, said:

Thanks so much! This was a great help, hats off to you sir.

no problem :)



#267642 Error handling no function

Posted by danielsv03 on 17 June 2017 - 11:37 AM in Ask a Pro

Hello so i used a error handling before on an function but the thing is the the main part of the script can't be in a function but i also want it to cath errors in a custom error screen right now its just the normal what is the solutions to this?



#267638 MLG teachers and students table bonanza!

Posted by danielsv03 on 17 June 2017 - 09:29 AM in Ask a Pro

What you could do is
local persons = {
	  ["Alex"] = {rank =  "Teacher"; PremissionLevel = 3};
	  ["Paul"] = {rank = "Student"; PremissionLevel = 0};
}

Could be a good table for this
what you could do is that you have an function that checks if student have rank == teacher if so add that person to another table called teachers in a separate file

That could look something like this
teachers = {}
student = {}
function check()
for k,v in pairs(persons) do
if v.rank == "Teacher" then
  table.insert(teachers, k)
elseif v.rank == "Student" then
  table.insert(student, k)
end
end

end

that should separate all the student and teachers into separate tables
then you could just check if that person belongs to that table and add premissions to that table like if the person belongs to teacher table then it has more permissions like permissionslevel 3



#267622 DanzOs

Posted by danielsv03 on 16 June 2017 - 03:18 PM in Operating Systems

View Posthbomb79, on 19 April 2017 - 03:16 AM, said:

The huge update actually being the OS?

Yes

View PostRestioson, on 19 April 2017 - 10:38 AM, said:

At the moment you're storing the passwords in plaintext. This is very insecure. You might want to look into SHA2 and password security.

Working on it

View Posthouseofkraft, on 19 April 2017 - 12:46 PM, said:

You should really consider using GitHub for downloading files. It makes the download process a lot faster and will not spam pastebin. Also, when you ask for the password, you should really consider replacing the text typed with a asterisk. You can do that by doing
local pass = read("*")
. Finally, you should really consider securing the password with SHA2.

Also, don't copy the CraftOS Shell! Please, different UI's (even without a GUI) makes operating systems unique. You are just copying the CraftOS shell and modifying it.

Good luck with your OS!

The local pass = read(" * ")
i already knew it and it is included when you login not when you set up a password

btw thanks for the tips.



#267576 [1.7.10] CubeSpace Creative [CC 1.75] [24/7]

Posted by danielsv03 on 14 June 2017 - 06:40 AM in Servers

I just logged on the server again after a long time is any one still playing on it?



#267575 Why can't click on shutdown [SOLVED!]

Posted by danielsv03 on 14 June 2017 - 05:53 AM in Ask a Pro

View PostKingofGamesYami, on 13 June 2017 - 08:21 PM, said:

Move the event pulling out of the for loop. I completely missed that it was in there because your indentation is screwy, sorry.

Thank you so much!! it works now!
:D



#267568 Why can't click on shutdown [SOLVED!]

Posted by danielsv03 on 13 June 2017 - 05:27 PM in Ask a Pro

and if so is there an solution?

View PostKingofGamesYami, on 13 June 2017 - 04:22 PM, said:

I was actually able to reproduce the problem just now. It seems resizing the minecraft window does something screwey. I'm using the latest version of CC so that may be the problem.

It's not a problem with your script though. This is a computercraft bug which you have no control over.



#267566 Why can't click on shutdown [SOLVED!]

Posted by danielsv03 on 13 June 2017 - 04:24 PM in Ask a Pro

View PostKingofGamesYami, on 13 June 2017 - 04:22 PM, said:

I was actually able to reproduce the problem just now. It seems resizing the minecraft window does something screwey. I'm using the latest version of CC so that may be the problem.

It's not a problem with your script though. This is a computercraft bug which you have no control over.

ohh well that weird. Because i tried another script that works just the same and it works fine



#267562 Why can't click on shutdown [SOLVED!]

Posted by danielsv03 on 13 June 2017 - 03:10 PM in Ask a Pro

No i'm not i'm using the normal terminal btw can you click directly on the text for me i have too click outside of it

View PostKingofGamesYami, on 13 June 2017 - 03:02 PM, said:

Are you running this on a monitor? There is a bug which may be the culprit.

View Postdanielsv03, on 13 June 2017 - 03:10 PM, said:

No i'm not i'm using the normal terminal btw can you click directly on the text for me i have too click outside of it



#267559 Why can't click on shutdown [SOLVED!]

Posted by danielsv03 on 13 June 2017 - 02:51 PM in Ask a Pro

View PostKingofGamesYami, on 12 June 2017 - 09:19 PM, said:

I copy-pasted that code into CC and both buttons work. So I'm a bit confused.

Wow well shutdown dosen't work for me

Ohh well nvm i know why now its because i have to click outside shutdown.. idk why

Do any one know why i have to click outside the text?