Jump to content


Fatal_Exception's Content

There have been 104 items by Fatal_Exception (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#41911 camera blocks

Posted by Fatal_Exception on 19 October 2012 - 12:54 AM in Suggestions

Congratulations for making today's camera suggestion.
Who will it be tomorrow?



#41239 Title above main menu

Posted by Fatal_Exception on 17 October 2012 - 01:02 PM in Ask a Pro

...snip...
--[[ Main Methods ]]--
function main()
  while running do
	term.clear()
	term.setCursorPos(1,1)	-- << These two lines
	print("Your Title Here")  -- <<  
	term.setCursorPos(1,2)
	printMenu(mainMenu)
	event, key = os.pullEvent("key")
	onKeyPressed(key, mainMenu)
  end
end

edit: sneaky ninjas in the shadows



#41231 os.pullEvent with multiple loops

Posted by Fatal_Exception on 17 October 2012 - 12:08 PM in Ask a Pro

If you want to be indignant and play "It's too HARD!!", be my guest. If you take a minute or two and look at the code, and think a bit yourself, you might learn something.

Call os.startTimer with the time in seconds until the timer fires, and save the return value.
Use pullEvent to check for a "timer" event with its first argument equal to the return value you saved.

Any complication with this is purely in your head, I assure you.



#41127 os.pullEvent with multiple loops

Posted by Fatal_Exception on 17 October 2012 - 02:28 AM in Ask a Pro

They're not really that difficult either.

myTimer = os.startTimer(5) -- timer will fire in 5 seconds

event, arg1, arg2, arg3 = os.pullEvent()
if event == "timer" and arg1 == myTimer then
  print("My Timer fired!")
end



#40779 Help with Installation

Posted by Fatal_Exception on 16 October 2012 - 02:53 AM in Ask a Pro

I think you're doing something terribly wrong here.
Why do you have a minecraft zip?
And why are you even considering deleting the jar?



#40776 Converting to base 2 (aka binary)

Posted by Fatal_Exception on 16 October 2012 - 02:46 AM in Ask a Pro

That's telling it you have a number in base 16 that you want to display in base 10.



#40775 Email Application

Posted by Fatal_Exception on 16 October 2012 - 02:41 AM in Ask a Pro

View PostKingdaro, on 15 October 2012 - 12:33 PM, said:

Fatal, have you ever thought that maybe English isn't the OP's first language? These forums are pretty nationally diverse :S

I inferred from the email address that the poster should be at least reasonably literate in English.



#40771 Small issue about turtle API returns

Posted by Fatal_Exception on 16 October 2012 - 02:22 AM in Ask a Pro

It means it returns a bool that indicates the success of the operation.



#40490 Retrieving items

Posted by Fatal_Exception on 15 October 2012 - 11:31 AM in Ask a Pro

Everywhere you have color.gray needs to be colors.gray



#40472 [Question] Starting a timer in the middle of code.

Posted by Fatal_Exception on 15 October 2012 - 09:58 AM in Ask a Pro

I sense a tall, dark stranger, the number 14, and someone whose name starts with 'K'. Wait, scratch that. I'm a terrible psychic. So are the rest of us. Sorry.



#40430 Email Application

Posted by Fatal_Exception on 15 October 2012 - 05:35 AM in Ask a Pro

i thought about maybe helping but then i thought no this person cant be bothered even using proper sentence structure or capitalization and hasnt understood that we typically help people fix bugs in their code not completely write it for them. Thanks!



#40363 Is there any way to get rid of the "too long without yielding" error?

Posted by Fatal_Exception on 15 October 2012 - 12:58 AM in Ask a Pro

It's a timeout error, not a recursion limit. Literally, it's been too long since you've given another process the chance to run. Your program is not playing nice in a co-operative multitasking environment, so it's been sent to sit in the corner.

The solution is as Lyqyd said. Throw in some sleep(0) to let it yield.



#40012 Unhackable Password Door (Simple)

Posted by Fatal_Exception on 14 October 2012 - 06:56 AM in Programs

View PostChaddJackson12, on 14 October 2012 - 03:19 AM, said:

I think I may have found a solution to the problem about boot disks!

When someone's presses Ctrl, have the computer reboot; but before rebooting have it delete disk/startup, or even multiple disk startups; and THEN reboot the computer, meaning that if they put a disk in then press control, their disk would no longer have a startup to exit the normal program!

Tell me how well this works for you!
Like this:
repeat
   event, key = os.pullEvent("key")
   os.sleep(0.1)
until key == (# for LCTRL) or key == (# for RCTRL) or key == (# for ENTER)
If key == (# for LCTRL) or key == (# for RCTRL) then
   if fs.exists("disk/startup") then
	  fs.delete("disk/startup")
	  os.reboot()
   else
	  os.reboot()
   end
elseif key == (# for ENTER) then
   -- password script
end
Sorry I don't have the numbers for the IDs of the keys but I am unsure of them and am too lazy to look for them at the moment :3. Hope that I helped

All you'd have to do is shut the computer down, then switch disks.



#40010 "Small" Problem

Posted by Fatal_Exception on 14 October 2012 - 06:48 AM in Ask a Pro

What does your code look like now?



#40009 Strange Problem

Posted by Fatal_Exception on 14 October 2012 - 06:46 AM in Ask a Pro

http://lua-users.org...i/ScopeTutorial



#39928 "Small" Problem

Posted by Fatal_Exception on 14 October 2012 - 01:56 AM in Ask a Pro

Correct.



#39920 "Small" Problem

Posted by Fatal_Exception on 14 October 2012 - 01:35 AM in Ask a Pro

That's caused by a stack overflow, because you're calling your function from itself repeatedly (infinite recursion). Use a loop instead.



#39918 How do I make a GUI with key events?

Posted by Fatal_Exception on 14 October 2012 - 01:33 AM in Ask a Pro

View PostKadecamz, on 14 October 2012 - 12:31 AM, said:

How would you get the id, msg and distance with the rednet message event?

If you look at the example I gave, you already have them. arg1, arg2, arg3.



#39890 Problem with rednet sending

Posted by Fatal_Exception on 14 October 2012 - 12:07 AM in Ask a Pro

Repeat the process multiple times (in a for loop) and concatenate your result to the previous.

local alphabet = { (a table of characters here) }
local str = ""
for i = 1, 6 do
  str = str .. alphabet[math.random(1,#alphabet)]
end



#39887 How do I make a GUI with key events?

Posted by Fatal_Exception on 14 October 2012 - 12:01 AM in Ask a Pro

Each time you detect a up/down keypress, increment or decement a variable that indicates which menu item you've selected.

As for receiving and detecting other events at the same time:
local event, arg1, arg2, arg3 = os.pullEvent()
if event == "rednet_message" then
  -- arg1 is senderid
  -- arg2 is message
  -- arg3 is distance
elseif event == "key" then
  -- arg1 is keycode
end



#39693 startup on server?

Posted by Fatal_Exception on 13 October 2012 - 10:17 AM in Ask a Pro

There's probably another program modifying your startup.



#39690 Print doesn't work correctly.

Posted by Fatal_Exception on 13 October 2012 - 10:12 AM in Ask a Pro

They probably do show up, but then it jumps back to the start of the while loop and clears the screen. You probably want to sleep for a second or two, or os.pullEvent("key") to pause for key input.



#39332 Looping program forces computer to shutdown.

Posted by Fatal_Exception on 12 October 2012 - 07:09 AM in Ask a Pro

I would imagine you're getting a "too long without yielding" error.

input = "top"
output = "left"
rs.setOutput(output, true)
while true do
  if os.pullEvent() == "redstone" then -- <<THIS
	if rs.getInput(input) then
	  rs.setOutput(output, false)
	  sleep(8)
	  rs.setOutput(output, true)
	end
  end
end

edit: ninja!



#39313 Delete This.

Posted by Fatal_Exception on 12 October 2012 - 04:23 AM in General

Funny how you explicitly disallow "retarded criticism" in your thread, but it's all good for you to do the same thing in someone else's thread.



#38924 The stack and you: How to not crash your program

Posted by Fatal_Exception on 11 October 2012 - 01:32 AM in Tutorials

All true, and details I basically glossed over to simplify things. I wanted to present an idea of what the stack was conceptually without delving too much into technicalities. I probably should have expanded on the different forms of recursion though.

The major take home point being, if you aren't careful to clean up after yourself, your program will crash eventually.