Jump to content


BigTwisty's Content

There have been 106 items by BigTwisty (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#147612 Corrupt-A-Wish!

Posted by BigTwisty on 02 October 2013 - 10:26 PM in Forum Games

Granted, but they now run on Redpower Blutricity.

I wish I could come up with something clever to wish for.



#147477 Corrupt-A-Wish!

Posted by BigTwisty on 01 October 2013 - 12:13 PM in Forum Games

Granted, but the cc-boards crashed and lost that post, and this post replaced it.

I wish I could hack the human mind.



#147405 Attempt To Index Field '?' (A Boolean Value)

Posted by BigTwisty on 30 September 2013 - 02:51 PM in Ask a Pro

Couple of problems:
1:
for c=sizeZmin, sizeYmax do
should be:
for c=sizeZmin, sizeZmax do

2. There are several places where world is referenced with 4 sub tables, but it only seems to be generated with 3.

3. You defined importModel with 2 arguments, but are calling it with 5. The last 3 arguments are being ignored.

Those are just the few I found on a quick scan. If you fix those and it still doesn't work, we can look more in depth.



#147382 Rednet code question.

Posted by BigTwisty on 30 September 2013 - 12:27 PM in Ask a Pro

The answer lies in the tutorials on this very site. Check out the "If then else" tutorial here: http://www.computerc...onal_statements
and the Redstone API documentation here: http://www.computerc.../Redstone_(API). In the Redstone API, check out the rs.getInput(side) function. Figuring it out from there should be simple enough.



#147123 Multiple Alarm Events.

Posted by BigTwisty on 28 September 2013 - 11:48 PM in Ask a Pro

View PostCCJJSax, on 27 September 2013 - 09:56 PM, said:

Well, it did work, but now something is going on with my last timer. It's not activating at time 20. Here is the pastebin link.

Line 160 is where it should be called and the function is at line 115.

First thing I notice is that night() is the only function that turns on redstone. If the other chime functions work, then I'd look at the chime peripheral and see if redstone affects thruway it works. An easy test would be to comment out line 117 and see if it starts working.



#147066 How to automate quarry/tesseract/chest placing?

Posted by BigTwisty on 28 September 2013 - 04:46 PM in Ask a Pro

View PostLyqyd, on 28 September 2013 - 03:13 PM, said:

View PostBigTwisty, on 28 September 2013 - 01:19 AM, said:

The other problem you'll find is that tesseracts don't keep their settings like redstone cells do when you wrench them. The turtle can place them, but they won't actually do anything until you come by and set their frequencies.

You can use either a shiny dust or a shiny ingot on them to cause them to retain their settings when broken. This may only work when they're broken with the crescent hammer. TE adds an "engineering turtle" or similar that has a crescent hammer tool attached. Obviously, craft a turtle and a crescent hammer to get one.

That is awesome! Never knew that. Thanks!



#147035 Asking For Code Review (By Pros)

Posted by BigTwisty on 28 September 2013 - 11:07 AM in Ask a Pro

View PostEngineer, on 28 September 2013 - 09:13 AM, said:

But then you are using a function just like goto, which I have heard is bad.

Do you understand WHY using a goto is bad? A goto statement moves the next executing line pointer to another point in the code, but DOES NOT RETAIN any information on where it was called from. This creates a needlessly complicated flow through the code, leading to confusion and much difficulty when trying to find bugs. In this case, the functions are being used more like a gosub, which moves the next executed line pointer but retains the call point, allowing code continuation from that point when the subroutine is finished.



#147004 How to automate quarry/tesseract/chest placing?

Posted by BigTwisty on 28 September 2013 - 01:19 AM in Ask a Pro

The other problem you'll find is that tesseracts don't keep their settings like redstone cells do when you wrench them. The turtle can place them, but they won't actually do anything until you come by and set their frequencies.



#147003 Binary Editor In Minecraft

Posted by BigTwisty on 28 September 2013 - 01:13 AM in Ask a Pro

View Postwojbie, on 27 September 2013 - 03:41 AM, said:

For converting from base 10 to any base you can use http://stackoverflow...-base-converter
Thats what i am using anyways.

Try:
string.format("X", number)



#147002 Asking For Code Review (By Pros)

Posted by BigTwisty on 28 September 2013 - 01:06 AM in Ask a Pro

View PostEngineer, on 27 September 2013 - 06:38 PM, said:

What is the point of making a function and then calling it once?

One common use for functions is to separate bits of code for readability. Take for instance the "main" function in many applications. The entirety of the main loop is usually contained within that function, and it is only called once, from the bottom of the app. A "setup" function is used the same way. I assume that is what the OP was doing here.



#146890 Asking For Code Review (By Pros)

Posted by BigTwisty on 27 September 2013 - 01:06 PM in Ask a Pro

See my comments in the code, prefixed with -->>

Also cleaned up some code indentation.

For the most part this is laid out fairly well. The code is pretty easy to read. There is a bit of redundant code you can remove, and at least one function that is never called, but all in all it isn't too bad. :)

Spoiler



#146724 redstone activated terminal

Posted by BigTwisty on 26 September 2013 - 04:23 PM in Ask a Pro

You are incredibly unclear about what you mean by "activate". Do you want it to run a program when a redstone signal is applied, and then stop that program when the redstone signal goes away? If so, then the "deactivation" would need to be part of the program that runs.

startup:
while true do
  _,side = os.pullEvent("redston")
  if side == "back" then
	shell.run("prog")
  end
end

prog:
begin
  -- Do stuff
  -- Kick dog
  -- Make fun of Lyqyd
  -- Get banned from CC forum
until not rs.getInput("back")



#146476 How To Make An Installer.

Posted by BigTwisty on 24 September 2013 - 10:33 PM in Ask a Pro

View PostPixelToast, on 24 September 2013 - 02:49 PM, said:

View PostBigTwisty, on 24 September 2013 - 02:36 PM, said:

2. There is no way to make ANYTHING closed source in ComputerCraft. Everything is saved in source code form. Anyone downloading the 9 files would be able to reading them.
there are ways to obufuscate lua code
you can use string.dump/luac to turn the program into bytecode, that can be decompiled/dissasembled though, there is a program to randomize the localize names making it harder to dissasemble (i forget where)
sometimes i localize random functions with random function names and make the code completely unreadable, though its kind of hard developing something like that

i find it completely useless to make CC programs closed source, or anything for that matter because there are always ways of retrieving the source

Interesting. I was unaware of this. I would think server admins would dislike this a bit, as they can't go in and see if it is your code screwing up their server. I figured CC was open source by design.

I can see how this might be of use in a war server, however.



#146475 Rednet code question.

Posted by BigTwisty on 24 September 2013 - 10:29 PM in Ask a Pro

View Postbrattus123, on 23 September 2013 - 10:57 PM, said:

instead of a line of redstone being applied directly to the turtle how would i make it stop looping with a rednet signal also i changed the rednet_message to rednet.recieve to stop the turtle from wating indefinatly and now im getting the error rednet :68: Expected number here is the code:

rednet.open ("left")
while true do
local event, id, msg = os.pullEvent (rednet.receive ("10"))
if id == 18 then
if msg == "nograv" then
shell.run ("offorbit")
shell.run ("orbit")
end
end
end

Look at your os.pullEvent line. Read the documentation on os.pullEvent, look at your code again, and have a nice facepalm moment.



#146474 While True Do Loop Issue

Posted by BigTwisty on 24 September 2013 - 10:24 PM in Ask a Pro

One issue with using that particular timer code is that os.pullEvent will pull the first available event, whether it is a timer or not. The way you have it coded, every time a non-timer event occurs, the program will loop back and create a new timer event. The system will then respond to both the new timer and the old one. You could end up with thousands of active timers, looping on each one.

If you want to keep it simple, remove the timer stuff from the top and add sleep(5) to the bottom of the loop. Otherwise you'll need to use the value returned by os.startTimer to ensure only the latest timer is being responded to.



#146418 How To Make An Installer.

Posted by BigTwisty on 24 September 2013 - 02:36 PM in Ask a Pro

1. The best thing to do would be to look at the pastebin program built into your computer. It is at rom/programs/http/pastebin if I remember correctly. Basically I would recommend you take that code and manipulate it to do what you want specifically.

2. There is no way to make ANYTHING closed source in ComputerCraft. Everything is saved in source code form. Anyone downloading the 9 files would be able to reading them.



#146413 While True Do Loop Issue

Posted by BigTwisty on 24 September 2013 - 01:40 PM in Ask a Pro

Several issues:

1. I don't see where the tables named "chest", "mace" or "efurn" are created, so either you aren't showing all your code or these are missing.
2. If you don't tell us what error you are getting, we can't tell you where it is coming from.
3. You have a bunch of useless "else" statements cluttering up your code. Remove them.
4. Proper indentation helps us read it. See corrected indentation here:
chest.condense() --Organize the Chest
local slotnum = chest.getSizeInventory() --Use the Max Invantory Size to calculate the Slot number and Loop amount
local macedone = mace.getStackInSlot(1)
local efurndone = efurn.getStackInSlot(1)
while true do
  os.startTimer(5)
  event = os.pullEvent()
  if event == "timer" then
	--push completed items out of the mace and efurn--
	mace.push("north", 1, 64)
	efurn.push("up", 1, 64)
	--start looking for ore--
	for i=1,slotnum do -- LOOP!
	  local tableInfo = chest.getStackInSlot(i)
	  if tableInfo ~= nil then
		for key, value in pairs(tableInfo) do
		  if string.find(value, "Ore") then -- Find Ore
			print("Ore Found! Moving to Macerator!")
			chest.push("north", i, 64)
		  else
		  end
		end
	  else
	  end
	end
  else
  end
end

Edit: Ninja'd on the error



#146356 Rednet code question.

Posted by BigTwisty on 23 September 2013 - 10:23 PM in Ask a Pro

rednet.open ("left")
repeat
  local event, id, msg = os.pullEvent ("rednet_message")
  if id == 18 then
    if msg == "nograv" then
      shell.run ("offorbit")
    else
      shell.run ("orbit")
    end
  end
until rs.getInput("left")



#146309 How To Refresh A Clock

Posted by BigTwisty on 23 September 2013 - 01:42 PM in Ask a Pro

View PostHellkid98, on 23 September 2013 - 12:52 PM, said:

Uhmm.. Just want to point out that it's not good to have the clock var named same as the function..

As long as the variable is local to the function and he is not calling the function recursively from inside itself, this should cause no problems.

View PostHellkid98, on 23 September 2013 - 12:52 PM, said:

And for you updating problem.. You could use a timer, And my guess you have some events pausing the loop and waiting for an event etc.
Here's an example
clockTimer = os.startTimer(.8) -- Start the timer for the first time
while true do
	evt, p1, mX, mY = os.pullEvent()
		if evt == "key" then
			-- Do something
		elseif evt == "timer" then
			clockTimer = os.startTimer(.8) -- Restart the timer when it has ran
		end
end

This will only work if he is doing nothing else. If you look at the image in the OP, there are other menus and things being accessed simultaneously. Like I said, we really need to see the rest of the code. The solution in the previous post makes too many assumptions.



#146289 How To Refresh A Clock

Posted by BigTwisty on 23 September 2013 - 11:48 AM in Ask a Pro

First off, it would be EXTREMELY helpful to see the rest of your code, as you may be overwriting your clock output elsewhere.

Second, it is a good idea to not hard code your screen locations, just in case your position is off or you decide to run code on a monitor.
function time()
  local time = textutils.formatTime(os.time(), true)
  local w = term.getSize()
  term.setCursorPos(w - #time + 1, 1)
  print(time)
end

3rd, you need to check the rest of your code to ensure this function is being called regularly. This is why we need to see the rest of your code.



#146263 Rednet code question.

Posted by BigTwisty on 23 September 2013 - 07:20 AM in Ask a Pro

View Postbrattus123, on 23 September 2013 - 12:05 AM, said:

with this code which is attempting to combine the rednet code with the orbit code im getting an error saying ("eof") expected on line 10 and i don't know why and also would it be possible to make this code loop until the redstone signal is applied

Turtle:
rednet.open ("left")
while true do
local event, id, msg = os.pullEvent ("rednet_message")
if id == 18 then
if msg == "nograv" then
shell.run ("offorbit")
end
end
end
else
shell.run ("orbit")

Proper code indentation would make this syntax error easier to spot.

rednet.open ("left")
while true do
  local event, id, msg = os.pullEvent ("rednet_message")
  if id == 18 then
    if msg == "nograv" then
      shell.run ("offorbit")
    end
  end
end
else
  shell.run ("orbit")

The last 2 lines actually belong right after the other shell.run. Right now they are outside your loop and will never run. Can you see how code indentation makes it easier to read your own code?



#146251 [Lua] [Question] Is there something like Select Case?

Posted by BigTwisty on 22 September 2013 - 10:42 PM in Ask a Pro

View Postkreezxil, on 22 September 2013 - 08:54 PM, said:

I don't see anywhere in this thread where readability was stated as a rule. But I'll give you the point. In fact I thought it was Select Case, did you have any comments on the article I found and my implementation of it?
I read through it, but it doesn't seem to be as efficient as the simple if then elseif that is typically used in Lua. It's a creative way of using tables, but I don't think it really adds anything useful while requiring more code to do the same thing.



#146215 [Lua] [Question] Is there something like Select Case?

Posted by BigTwisty on 22 September 2013 - 05:40 PM in Ask a Pro

View Postkreezxil, on 22 September 2013 - 12:22 PM, said:

What about this at 3 lines!
name = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
function getDay() day=name[tonumber(io.read())] if day ~=nil then print ("It is " .. day) end return day end
while true do print ("What day is it? (1-7) ",getDay() or "Where do you live?!") end

Now you're just cheating. You're just stringing statements together. If you do that, you might as well just put it all on 1 line. Your code is actually quite a step back with respect to efficiency.

The point was to reduce the number of function calls as far as possible to show how little Lua actually needs select case statements. I think we've proven our point.

(I still think my coded was the smallest, though...)



#146158 [Lua] [Question] Is there something like Select Case?

Posted by BigTwisty on 22 September 2013 - 10:30 AM in Ask a Pro

View Postkreezxil, on 22 September 2013 - 08:48 AM, said:

View PostShefla, on 22 September 2013 - 08:34 AM, said:

name = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
while true do
	print "What day is it?"
	print(name[tonumber(io.read())] and "It is "..day or "Where do you live?!")
end

It seems the day variable in this version is never initialized.

Your're right, I it's total garbage and can't be done the way I wrote it. Day must be captured as a variable before being processed inside the print string.

Nice try! This approach would work if you didn't have to print "It is " before the day.

name = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
while true do
	print("What day is it?  ", name[tonumber(io.read())] or "Where do you live?!")
end



#146138 Rednet code question.

Posted by BigTwisty on 22 September 2013 - 07:41 AM in Ask a Pro

Whenever you have several places in your code that are basically the same, it's a good idea to use a function. Try this:
local function backTurn(length)
  for i = 1,length do
    turtle.back()
  end
  turtle.turnRight()
end

backTurn(25)
backTurn(12)
backTurn(25)
backTurn(12)

Looking at the last 4 lines it is now easier to (a.) see what the turtle is going to do and (b.) make it do something different if you want.

It should be noted that Lyqyd's code should do he same thing if it is copied in correctly.