Jump to content


Himself12794's Content

There have been 43 items by Himself12794 (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#172567 Emailing servers

Posted by Himself12794 on 09 April 2014 - 04:28 PM in Ask a Pro

If you are playing on a server where you cannot edit the wireless range, you can make several computers that will re-rout the signal if you wish. If you configure each one separately, then it shouldn't be too hard to do.



#167678 Determining Prime

Posted by Himself12794 on 10 March 2014 - 02:16 PM in Ask a Pro

View Posttheoriginalbit, on 10 March 2014 - 02:13 PM, said:

View PostHimself12794, on 10 March 2014 - 07:22 AM, said:

I ran a trace and found that just one sum down, I get, 3682913, which is just 3 off.
as for this problem, its all to do with the loop. there's multiple ways to change it so that it works, the way I did it in my test before was the following.

repeat
  if primes(number) then
	count=count+1
	sum=sum+number
  end
  number=number+1
until count == 1000
That does seem simpler, though my initial problem was when trying to determine a prime number faster, I forgot to include 3. That way it went over one extra not including 3. I did not know about the repeat function. Seems to work like do...while.



#167673 Determining Prime

Posted by Himself12794 on 10 March 2014 - 02:05 PM in Ask a Pro

View Posttwormtwo, on 10 March 2014 - 10:40 AM, said:

You just forgot that 3 is a prime number. And since 3%3=0, it returns false for 3.
Ah! So it is. Thanks alot!



#167661 Determining Prime

Posted by Himself12794 on 10 March 2014 - 07:22 AM in Ask a Pro

For a project I'm working on, I need to find the sum of the first 1000 prime number.
I know the answer should be: 3682913
But instead I'm getting: 3690837
The code I use is below.
function primes(n)
    if n<2 then
	    return false
    elseif n==2 then
	    return true
    elseif n%2==0 or n%3==0 then
	    return false
    else
	    for i=3, math.ceil(n^0.5) do
		    if n%i==0 then
			    return false
		    end
	    end
    end
    return true
end

local count=0
local number=2
local sum=0
    
while count<1000 do
    if primes(number) then
	    count=count+1
	    sum=sum+number
    end
    number=number+1
end
print(sum)
I ran a trace and found that just one sum down, I get, 3682913, which is just 3 off. Not sure if my problem has to do with determining primes in the first place, limitations of lua, or just simple errors. Help is appreciated.



#165593 Graphic Explorer for CraftOS

Posted by Himself12794 on 21 February 2014 - 01:04 AM in Operating Systems

 Lyqyd, on 15 February 2014 - 08:44 PM, said:

Moved to Operating Systems.
Very good looking, will definitely try when I have a chance.



#165414 having issues with division and floating point numbers

Posted by Himself12794 on 19 February 2014 - 11:53 AM in Ask a Pro

View Postackley14, on 18 February 2014 - 09:02 PM, said:

.......Thank you! wow i feel stupid! xD i have caught EVERY other typo of mine like that until now! awesome!
I do the same thing ALL the time, believe me.



#165360 Request for testing - HimCo Industries Experimental OS v0.8 and Network

Posted by Himself12794 on 19 February 2014 - 01:39 AM in Operating Systems

So I have been working for quite awhile on my own network and OS system. So far I have it at what I deem an acceptable level to ask if people could test it. I have done testing, but I can only do so much for that. If anyone could test it, it would be much appreciated, and if anyone could critique the coding, that would be very much appreciated as well.

Right now, all I've really done is made a master server, router, passwords server, a file server, and a nice GUI for the client computer.
All of the computers start with rednet modems on the top, since I have not done a config program yet.

The code for the master server just has to be downloaded and run on the computer.
It's found here:

http://pastebin.com/zeZyS1fd

The routers help bridge the gap when distance is too far. There has to be at least one router, as the clients will not connect to the master server. After running the router startup, just put in the id of the master server.

The code for the routers are here:

http://pastebin.com/ZZ0zdH1x

There is the password server, which is supposed to control authentication. You register the sub-servers the same way as a router.

Password server is here: (sorry for inconvenient location, ran out of pastebin pastes)

http://philip.whitin...0server/startup

You can use below to download.
Spoiler

The file server allows the client to save files remotely, where anyone can access it. Password server provides protection to user specific files.

Code is here: (again, sorry for wonky location)

http://philip.whitin...0server/startup

Finally, the client code. This one has the most files, and the one mostly likely to be littered with mistakes.

http://philip.whitin...craft/installer

That one has an installer, so you just download and run it.

I believe that's everything. If anyone is willing to try it out, I hope you are able to tell me about any errors or weak coding you find.

Thanks!



#165358 Strengthening Password Server Security

Posted by Himself12794 on 19 February 2014 - 01:22 AM in Ask a Pro

View PostBomb Bloke, on 19 February 2014 - 01:15 AM, said:

Rednet cables or ComputerCraft's network cables, whatever, so long as no one can tap into them.

If people can tap into them, then (properly implemented) encryption would secure things, yes - assuming they can't get direct access the server machine, in which case all bets are off unless you rig up some rather complicated security directly on that unit (along the lines of "needs a password just to boot because everything on the system is encrypted"-type-security).

The best starting point is to figure out how many people are likely to want to break into your system, and where their knowledge levels are. You merely need to aim for a level of security that, for them, would be more trouble then it's worth to break through.

That's what I'm banking on. Right now this is mostly to just to see if I can actually finish this project, and then it's mostly for convenience. Really the only reason the passwords are there right now are to give some semblance of a network, and prevent someone from deleting a file he did not upload. Later I will add instant messaging and email, and that will require a bit more of security savy. I was actually just about to put what I've done so far in the OS section to see if I could get anyone to test it for me and give feedback.



#165351 Strengthening Password Server Security

Posted by Himself12794 on 19 February 2014 - 12:17 AM in Ask a Pro

View PostCometWolf, on 19 February 2014 - 12:11 AM, said:

That won't be secure at all. Rednet is just a simplified api for the modem api, which allows you to chose what channel to send and receive on. The very same channels which rednet use for it's id system.
I did not know that. However the only thing really that I have authentication for is whether or not you can delete a file. I will also assume that the only way to securely send information, then, will be by the use of rednet cables? In my case, the only compromised information would be what the client sends to the server in requesting to log in. Perhaps there is an encryption algorithm I could use?



#165343 Strengthening Password Server Security

Posted by Himself12794 on 18 February 2014 - 10:23 PM in Ask a Pro

View PostBomb Bloke, on 18 February 2014 - 10:16 PM, said:

View PostHimself12794, on 18 February 2014 - 09:25 PM, said:

I know a user could go through and change config and functions, and I want to make so that there is nothing they can do cause information to be sent to a unsecure source, or wrongly extract information.
Well, if you're using wireless, then anyone in range of the signal can tap into your communications. If wired, then anyone with access to your networking cable run can do the same.
Well the way I set it up, when a router/client/server is first activated, it request the id of a parent router. In the case of a sub-server, it will only receive and send from that id. In the case of a router or master server, it only will do anything with a message that has correct values, so as to prevent crashes due to people randomly sending out messages. They also store a list of ids with registered computers.
I could have the client require to know the parent id as well, but I'm trying to make it so I can just spread the routers out throughout the world, and have some just pop in and attempt to connect, provided they have the correct OS.

The only broadcast I have is for a computer asking to join the newtwork, then everything else is based on stored ids after initial registration. I made the master server be able to act as a router as well, but I'm debating keeping this function.



#165340 Strengthening Password Server Security

Posted by Himself12794 on 18 February 2014 - 09:25 PM in Ask a Pro

I'm making a computercraft network, inspired by Nitrogen Fingers, and Have just finished out ironing some bugs in my password authentication system, and would like to know if there are things I could do make things more secure, mostly by making authentication based on things a console user cannot change. I know a user could go through and change config and functions, and I want to make so that there is nothing they can do cause information to be sent to a unsecure source, or wrongly extract information.

I have several different computers, there's router files, a master server computer, sub-servers, and the client computer. What I'm most interested in is the password sub server and the client.

Here's the relevant client code:
Spoiler

Here is the password server code:
Spoiler

If necessary, the router code is here, and the master server code is here.



#165334 having issues with division and floating point numbers

Posted by Himself12794 on 18 February 2014 - 08:51 PM in Ask a Pro

On line 166, you have nst1/nst1 instead of nst1/nst2. That is why it always equals 1.

elseif opptype == "divide" then
  nst2 = table.concat(numset2)
  nst1 = table.concat(numset1)
  opt = nst1/nst1
  printOut(opt)

Should be:

elseif opptype == "divide" then
  nst2 = table.concat(numset2)
  nst1 = table.concat(numset1)
  opt = nst1/nst2
  printOut(opt)

I changed that and it seems to work.



#164704 Help with a scrolling multiple choice selection

Posted by Himself12794 on 12 February 2014 - 11:58 PM in Ask a Pro

I got it! Runs just as I wanted!
Here's the code:
Spoiler



#164701 Help with a scrolling multiple choice selection

Posted by Himself12794 on 12 February 2014 - 11:38 PM in Ask a Pro

So I made something that works, but not exactly as I wish for it too. I don't wish for the values to scroll until selection hits the bottom, but this code scrolls through the rest of values until they no longer fill the page. It's a fair compromise for what I want, but I will work until I get the results.
Here's the code for this:
Spoiler



#164681 Help with a scrolling multiple choice selection

Posted by Himself12794 on 12 February 2014 - 06:35 PM in Ask a Pro

 Bomb Bloke, on 12 February 2014 - 06:09 PM, said:

I haven't tested either your code nor mine, but best I can make out, rather then this:

Spoiler

... you may want something like this:

Spoiler

Also, the keys API is worth a look. It allows you to rewrite stuff like this:

		if key == 208 --down arrow
		or key == 31 then -- S

... like this:

		if key == keys.down or key == keys.s then

Using these pre-defined constant variables stored in that API means you don't need to work out the numeric codes yourself.
That does help maintain the header, but there's still weirdness with printing the options.



#164676 Help with a scrolling multiple choice selection

Posted by Himself12794 on 12 February 2014 - 05:35 PM in Ask a Pro

I'm writing a function to allow selection from a list of options, returning the index of the selected choice. At first, it only worked if the length of the items fit onto the page, then I modified it, so now it can do a list if the items fit on a second page, at the cost of losing the header. However, anything larger than two pages just does weird things. Anyone know how I can fix it?
Here's the code:
Spoiler
Help is appreciated.



#164554 Weird Text Utilities + script error

Posted by Himself12794 on 11 February 2014 - 10:01 PM in Ask a Pro

View Postawsmazinggenius, on 11 February 2014 - 09:54 PM, said:

You can't send booleans unless in a table if you are not using 1.6pr0, I think (don't quote me).
Thanks, I found the error though, a simple syntax error.



#164550 Weird Text Utilities + script error

Posted by Himself12794 on 11 February 2014 - 09:47 PM in Ask a Pro

So I'm working on a network programwith routers, servers, subserves, clients, etc., and I came across a weird error I can't solve. This program was working just fine, and then randomly started giving me the textutils:177 error. It seems every time I reboot it, itis receiving a blank message, but no other computer is sending out messages. It was working fine, I made no changes, then it just started doing this.
Here's the code:
Spoiler
It makes it up to print statement 'da heck?' before I get that error. Not sure what couldbe causing it.

Edit:
Woops, nevermind, I found it. Somehow the parenthesis at the end of 'receiveMessage()' were somehow deleted.



#163995 Concurrency, apis

Posted by Himself12794 on 07 February 2014 - 01:04 AM in Ask a Pro

Yes, I would recommend separating the load between various computers and have them communicate via rednet. I built frame machine just like yours that had several functions, and I have found that it is much easier to just have a different computer for each function. What I did, was build an input computer that sends commands to the appropriate computer, like you suggested.

It's much easier I believe than messing with parallel.waitForAny()



#163993 Help (again) cleaning up a code

Posted by Himself12794 on 07 February 2014 - 12:55 AM in Ask a Pro

View Posttheoriginalbit, on 07 February 2014 - 12:49 AM, said:

View PostHimself12794, on 07 February 2014 - 12:45 AM, said:

Also, is there a way I can do the program without having to declare this twice?
Yeah of course, just define it at the top of your program — just as you did with diggingMode. any function below its definition will have access to it.
I was going to do that, but if I do I can't get the update if the amount of items change. I have it so it changes every time there is a difference in the inventory.



#163990 Help (again) cleaning up a code

Posted by Himself12794 on 07 February 2014 - 12:45 AM in Ask a Pro

View Posttheoriginalbit, on 07 February 2014 - 12:15 AM, said:

theres things throughout that you can fix. These are the 5 6 things that stood out to me immediately when I had a quick scan of your code.

#1 is localising your variables

#2 your for loops
local i=1
for i, 16 do
  count=count+turtle.getItemCount(i4)
end
since you do not use i outside the for loop once it is complete there is no need to perform a forward declaration. if you do it like so
for i = 1, 16 do
  count=count+turtle.getItemCount(i4)
end
i is localised to the for loop.

#3 This
if dichotomy('Yes','No') then
  diggingMode=true
else
  diggingMode=false
end
can simply be this
diggingMode = dichotomy('Yes', 'No')
conditionals are booleans, so why test a conditional to then assign a boolean, its just waste of a fork and CPU cycles.

#4 while waiting for the user to input items you can actually wait for the turtle_inventory event (assuming you're using CC 1.55 or above)

#5 these
if event=="key" and key==203 then sel=not sel end
if event=="key" and key==205 then sel=not sel end
if event=="key" and key==28 then break end
could actually just be
if event == "key" then
  if key == 203 or key == 205 then
	sel = not sel
  else if key == 28 then
	break
  end
end
this reduces the amount of conditionals that need to be evaluated by removing unnecessary event checking.

EDIT: Found another one
#6 this
if casings>34 and heat>3880 then
  write(3880)
  write(' K')
  write('  Too many casings! Only 34!')
elseif casings>34 and heat<=3880 then
  write(heat)
  write(' K')
  write('  Too many casings! Only 34!')
elseif casings<34 then
  write(heat)
  write(' K')
  write('  Not enough casings! 34 Needed!')
else
  write(heat)
  write(' K')
end
can be simplified to the following
write(math.min(heat, 3880)..' K')
if casings > 34 then
  write('  Too many casings! Only 34!')
elseif casings < 34 then
  write('  Not enough casings! 34 Needed!')
end
Oh yes! That's exactly the type input I'm looking for. I'm going to start looking at more advanced users codes and perhaps I can learn some styling lessons. I'm gonna have to start crediting you in my codes that you help with.
Also, is there a way I can do the program without having to declare this twice?
    local count={
        standard=turtle.getItemCount(1),
        reinforced=turtle.getItemCount(2),
        advanced=turtle.getItemCount(3),
        lava=turtle.getItemCount(4)+turtle.getItemCount(5)==2,
        nichrome=turtle.getItemCount(6)>=4,
        kanthal=turtle.getItemCount(7)>=4
    }
I tried passing it out of the function like I did with heat, but it did not work, even when I removed the local statement from in front of it.



#163971 Help with a mining machine.

Posted by Himself12794 on 06 February 2014 - 10:57 PM in Ask a Pro

I think it's because you used shell.run(), which, if I remember correctly, exits the current program when it runs, so your while loop does no good.



#163968 Updating information

Posted by Himself12794 on 06 February 2014 - 10:54 PM in Ask a Pro

To constantly update it, I recommend placing the line
eu = p.getEUOutput()
in your while loop, right at the beginning. If you don't do that, then eu will always be what it was when you started the program. Adding to the while loop allows it to constantly update.



#163962 Help (again) cleaning up a code

Posted by Himself12794 on 06 February 2014 - 10:33 PM in Ask a Pro

So I made another code for my turtle OS, and, again, just know that it can be made so much shorter and so much more nicer looking. I finished the information gathering functions, and I think they look horrible (at least they work!), so once I again I ask you all what I can do to improve it, things I can do to make it shorter, etc.

The reason I always ask is because all of my coding is self-taught and I have no idea what a professional code should look like.

Here's the code, which gathers the information needed for constructing an Industrial Blast Furnace:
Spoiler

Most of my focus is on making the code shorter and simpler, but input on code organization is fully welcome as well.
Hopefully, based on the repeated input I get, I'll need less and less help, and perhaps can provide some of my own.
Thanks in advance!



#163612 Add blinking cursor to a numbers only input function

Posted by Himself12794 on 05 February 2014 - 01:45 AM in Ask a Pro

View Posttheoriginalbit, on 05 February 2014 - 01:30 AM, said:

View PostHimself12794, on 05 February 2014 - 01:29 AM, said:

Oh I'm sorry, I should use comments more. The argument 'pre' is supposed to stand for prefix, and it is just there to print a little header in front of the number input.
Ah, well in any case, you should be able to see what you need to do in order to get it to work.
I do, and I have. I ended up with this:
local function numbersOnly(pre)
    term.setCursorBlink(true)
    local x,y=term.getCursorPos()
    local num=''
    while true do
        if pre then write(pre) end
        write(num)
        local event,key=os.pullEvent()
        if event=='char' and tonumber(key) then
            num=num..key
        elseif event=='key' then
            if key==14 then
                num=string.sub(num, 1, -2)
            elseif key==28 then
                print()
			    term.setCursorBlink(false)
                return tonumber(num)
            end
        end
        term.setCursorPos(x,y)
        term.clearLine()
    end
end
Thanks for all the help!