Jump to content


Graypup's Content

There have been 15 items by Graypup (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#188910 For input string "1shell"

Posted by Graypup on 23 July 2014 - 09:50 PM in Ask a Pro

c = true
while c do
  c = true
  shell.run("clear")
  print("...")
  print("...")
  write("...")
  a = io.read()
  if a == "Raffinerie" then
	shell.run("Raffinerie")
  elseif a == "Steinbruch" then
	shell.run("Steinbruch")
  else
	print("Falsche Eingabe")
	c = true
  end
end
Side note: lua has booleans, true and false. So you could replace c == 0 in the while declaration with simply c, and if c is true, it will run, otherwise it won't.



#182635 Gamax92's CCLite ComputerCraft Emulator (Updated for CC1.75)

Posted by Graypup on 06 June 2014 - 09:12 PM in General

Invalid escape sequences? Those break the chat program too.



#174629 Gamax92's CCLite ComputerCraft Emulator (Updated for CC1.75)

Posted by Graypup on 21 April 2014 - 04:44 AM in General

View Postgamax92, on 16 April 2014 - 11:19 PM, said:

View PostGraypup, on 14 April 2014 - 04:38 AM, said:

Found a bug in http support. Temporarily hosting a demo site so that it can be fixed.
local h = http.get("http://ma.sdf.org:1254")
print(h.readAll())
EXPECTED RESULT: http.get taking 5 seconds
ACTUAL RESULT: http.get returning nil instantly

Server code, in nodejs:
var h = require('http')

var s = h.createServer(function (req, resp) {
  req.on('data', function(datas) {
	console.log('Got: ' + datas)
  })

  var body = 'yaaays\r\n'

  setTimeout(function () {
	resp.writeHead(200, {'Content-Length' : body.length, 'Content-Type' : 'text/plain'})
	resp.end(body)
  }, 5000)
})
console.log('running')
s.listen(1254)
LuaSocket reports the server closing the connection.
There's probably some Keep-Alive trickery going on that Java does.
Yeah, some kind of hax in LuaSocket. Seems that I have to be sad, and not get to write some kind of realtime messaging thing that's easy to test D:
EVEN
http.request("http://ma.sdf.org:1254")
e, p1, p2 = os.pullEvent()
doesn't work



#173304 Gamax92's CCLite ComputerCraft Emulator (Updated for CC1.75)

Posted by Graypup on 14 April 2014 - 04:38 AM in General

Found a bug in http support. Temporarily hosting a demo site so that it can be fixed.
local h = http.get("http://ma.sdf.org:1254")
print(h.readAll())
EXPECTED RESULT: http.get taking 5 seconds
ACTUAL RESULT: http.get returning nil instantly

Server code, in nodejs:
var h = require('http')

var s = h.createServer(function (req, resp) {
  req.on('data', function(datas) {
    console.log('Got: ' + datas)
  })

  var body = 'yaaays\r\n'

  setTimeout(function () {
    resp.writeHead(200, {'Content-Length' : body.length, 'Content-Type' : 'text/plain'})
    resp.end(body)
  }, 5000)
})
console.log('running')
s.listen(1254)



#172516 Post your desktop!

Posted by Graypup on 09 April 2014 - 03:26 AM in General

I don't have very much on my desktop... Mostly just icons dumped by random programs, that I haven't been obsessive enough to delete. No fanceh rainmeter, because I never look at the thing. ;P Also, sorry for having adblock plus on cc.info, I should fix that! Hmm, ghostery too.Posted Image
The autohotkey is to fix my Model M not having media keys. And windows hating my weird routing setup to change volume.



#172259 Lua: What would you change?

Posted by Graypup on 07 April 2014 - 05:33 PM in General

A switch statement
A string-supporting switch statement
Who needs functional overloading? It can be done with some type() and some if statements.
Bracket notation, remembering ends is stupid, and brackets are easier
Ways to escape some boilerplate like
str = str or "blah"



#172252 ComputerCraft 1.6 is out of Beta!

Posted by Graypup on 07 April 2014 - 05:08 PM in General

View Post1lann, on 01 April 2014 - 03:56 PM, said:

One thing that annoys me is that the "repeat" program doesn't allow you to Terminate (ctrl+t) out of it, although you do state in the program
-- Main loop (terminate to break)
Ironically it uses os.pullEventRaw(), and thus you can't terminate out of it. I'm not sure if this is intentional or not, as it does add some small protection for computers that are dedicated repeaters.
CTRL-R, unless you put a startup file starting it, in which case, put a no-op startup on a floppy.



#170798 Ultimate Door Lock - PDA Opened Doors!

Posted by Graypup on 31 March 2014 - 03:43 AM in Pocket Programs

View Postoeed, on 31 March 2014 - 02:51 AM, said:

View PostSxw, on 31 March 2014 - 12:03 AM, said:

Is there anything keeping others from rebroadcasting the fingerprint to open the door?

No. There's really nothing I can think of that can prevent others from mimicking another PDA. ComputerCraft is very open, even if I did encrypt everything you could still fairly easily reverse it.

If you have any suggestions let me know. I'm trying out the program on the CoderCraft server and haven't run in to any issues as of yet.
Simple. Shared secret. Server sends a challenge (RANDOM), server encrypts it, without sending the encrypted version, client encrypts it, server checks whether it's the same as its own encryption. Just grab some lua implementation of a cipher, and add the 10 lines of code necessary



#167285 Attempt to compare __le on nil and number

Posted by Graypup on 06 March 2014 - 10:42 PM in Ask a Pro

View Postsci4me, on 06 March 2014 - 10:21 PM, said:

for i = 1, n do
Oops, too used to other languages D:



#167279 Attempt to compare __le on nil and number

Posted by Graypup on 06 March 2014 - 10:07 PM in Ask a Pro

Attempt to compare __le on nil and number. I am passing the required arguments.

tArgs = {...}
n = tonumber(tArgs[1])

for i=1, i <= n do
  turtle.place()
  turtle.back()
end



#162269 OpenPeripheral chest monitor not working

Posted by Graypup on 27 January 2014 - 11:10 PM in Ask a Pro

View PostCometWolf, on 25 January 2014 - 05:13 PM, said:

temp will be nil if there is no items in the slot it's checking. change line 7 to
if temp then --THIS IS LINE 7

I didn't know lua did that... Looks like more code checks are in my future D:



#161948 OpenPeripheral chest monitor not working

Posted by Graypup on 25 January 2014 - 04:30 PM in Ask a Pro

I have a program that is supposed to read the total amount of iridium in a chest, then phone home to my server, so I can check my UU progress anywhere.

Unfortunately, this throws an attempt to index nil error on line 7.

What am I doing wrong?

The setup is as follows: openperipheral installed, vanilla chest on the left of the computer.

p = peripheral
c = p.wrap("left")
while true do
  local totalUU = 0
  for i=1, 27 do
	local temp = c.getStackInSlot(i)
	if temp["qty"] ~= nil then --THIS IS LINE 7
	  totalUU = totalUU + temp["qty"]
	end
	temp = nil
  end
  --this is a demo thing and will 404, but we don't care!
  http.get("http://computercraft.info/update-uum.php?uum="..totalUU)
  print("told the server about my amazing "..totalUU.." iridium ore!")
  totalUU = 0
  sleep(180)
end

The serverside portion works FINE with manual requests



#142388 Graypup's Turtle Programs (Currently Not Plural)

Posted by Graypup on 30 August 2013 - 12:25 PM in Turtle Programs

I wrote a program called TurtleTB (turtle tunnel bore). It's definitely not perfect, and I know about some efficiency improvements that can be done, but it definitely works really well for digging tunnels.

The syntax is TurtleTB distance numberOfTurnarounds
numberOfTurnarounds must be a number or no, or nothing. no or nothing means that the program will not turn around, and just stop at the end of the tunnel.

It is open-source (LIKE EVERY FREAKING CC PROGRAM THAT ISN'T BYTECODE SAVED TO A FILE!), and what most people call open-source, so it's also on github here: https://github.com/Graypup/TurtleTB

There are various config variables at the start of the source code, so please configure them how you want them.
UsingEnderChest means that the turtle will break the chest after putting its stuff in it. Otherwise it will leave the chest in the bottom of the tunnel. Note: it doesn't fill in holes in the floor left by enderchest placement

Chests go in the last item slot, torches in the second last. I will add something for when the turtle runs out of chests, but for now, just make sure the chest item slot is full when refilling torches.

It's in the public domain, have fun doing whatever you want. Preferably credit me, though I can't do anything about you not doing so. :)



#140631 Anyone Interested In A Javascript (Web/html5) Version Of A Cc Emulator?

Posted by Graypup on 18 August 2013 - 01:44 PM in General

That idea is insane. You're running 1 programming language that isn't very fast on another not-very-fast programming language. Someone has done this, though I think they're crazy. https://github.com/kripken/lua.vm.js



#140629 Using ComputerCraft and Magic Launcher

Posted by Graypup on 18 August 2013 - 01:40 PM in General

If stuff explodes because you PUT ALL YOUR MODS IN THE JAR FILE, it isn't our fault.