Jump to content


JokerRH's Content

There have been 147 items by JokerRH (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#111361 BukkitOS The OS of The Future - In Progress

Posted by JokerRH on 18 April 2013 - 05:41 AM in Operating Systems

View PostCrosS_light, on 17 April 2013 - 12:26 PM, said:

i want the path of the file when it is running function lol() fs.delete("lol") end lol() I want if i run this code in one file that i get the name of the file in the fs.delete action

function shell.run(file, ...)
  file = tostring(file)

  if not fs.exists(file) then
    error(file..": File not found")
  end

  env = {yourReplacedFunctions}
  env._api = fs.getName(file)

  local success, param = loadfile(file)
  if not success then
    error(param)
  end

  setfenv(param, env)
  local success, err = pcall(param, ...)
  if not success then
    error(err)
  end
end

function fs.delete(file)
  --Your code
  if not valid then
    error(tostring(getfenv(2)._name)..": You don't have permission to delete that file!")
  end
end

...That should work...



#111233 os.pullEvent = os.pullEventRaw failing

Posted by JokerRH on 17 April 2013 - 09:08 PM in Ask a Pro

function MainSelect()
  event, button,X,Y = os.pullEvent("mouse_click")
    if button == 1 then
       ...
    end
end

There's your problem.
Computers are resumed with an api similar to the parallel api (I think Cloudy said that sometimes), and that checks if the filter matches or the event is "terminate".

In your case os.pullEvent will be resumed with "terminate" and your button variable is nil, so the program stops.
That's the same reason why you can press the right mouse button to stop the program...



#111230 os.pullEvent = os.pullEventRaw failing

Posted by JokerRH on 17 April 2013 - 08:42 PM in Ask a Pro

View PostSariaz, on 17 April 2013 - 04:56 PM, said:

This is because for some reason in my experience making it lock with the pullEventRaw messes with os.pullEvents where an event to wait for is specified.

os.pullEvent(filter)
calls
os.pullEventRaw(filter)
calls
coroutine.yield(filter)

There shouldn't be any problem.

Edit: I have no idea where your problem is. I copied your program from your post and tested it and it terminated just fine...
Edit2: Do you know how it feels if you write sh*t and as you want to delete it your internet connection crashes?



#111226 Computerized Timer?

Posted by JokerRH on 17 April 2013 - 08:37 PM in Ask a Pro

 Tyken132, on 17 April 2013 - 07:40 PM, said:

I was thinking of something simple like making it pulse then simply sleep till i'm ready for it to pulse again?

That's probably the best solution :D



#110976 Bypass Disk Startup

Posted by JokerRH on 17 April 2013 - 05:47 AM in Ask a Pro

View PostSpongy141, on 17 April 2013 - 02:44 AM, said:

^
*Face palm*
If someone is trying to bypass your password on your computer, and they just use a disk, what makes you think you could edit there startup files to rename itself, that is one of the dumbest ideas I have ever heard of. You would need to edit the actual startup in the rom folder so it tells the computer to load first.

What are you talking about...?
If the shell runs disk/startup first that is fine if there is no disk/startup
An api that doesn't exist can't be run, right?



#110911 Bypass Disk Startup

Posted by JokerRH on 17 April 2013 - 02:11 AM in Ask a Pro

View PostSpongy141, on 16 April 2013 - 10:21 AM, said:

^ No, the disk will override the computers startup, so no mater what, the computers startup wont load, as long as the disk has a file called "startup", so nothing you do to "created" computer startup file will have an affect.

Read my post again...Where would be the point of renaming the computer startup file on disc insertion? It should have been obvious that i meant to rename disk/startup to something like disk/notstartup



#110706 [Question] How can I clean up/mess up my code?

Posted by JokerRH on 16 April 2013 - 09:51 AM in Ask a Pro

@offtopic question: "by the way" or "nebenbei bemerkt"

@question: You can prevent termination by typing os.pullEvent = os.pullEventRaw, anything more secure is really hard (run apis with modified fs api, disk eventlistener and modified setfenv to prevent people from getting _G)



#110705 Higher Debug/Sandboxing Level & setfenv

Posted by JokerRH on 16 April 2013 - 09:45 AM in Ask a Pro

Look at the api I created, it is way more like java than table oop.
But I actually got a feeling that we're getting offtopic :D



#110700 An unreadable file?

Posted by JokerRH on 16 April 2013 - 09:36 AM in General

If you want to save code you could also remove the spaces and eol characters. If the program is long enough it'll be really painful to read...



#110697 Bypass Disk Startup

Posted by JokerRH on 16 April 2013 - 09:25 AM in Ask a Pro

You can. If you insert a disk it will cause an event to appear. All you have to do is create a coroutine that waits for that event and then renames disk/startup to something else.



#110695 Higher Debug/Sandboxing Level & setfenv

Posted by JokerRH on 16 April 2013 - 09:22 AM in Ask a Pro

@Smiley: No. The fenv way is way more like java :P



#110360 I Need Help.

Posted by JokerRH on 15 April 2013 - 09:50 AM in Ask a Pro

View PostSpongy141, on 15 April 2013 - 09:47 AM, said:

Could you clean your English up a little, I can't fully understand what your asking, but if you want to have a "button (stone/wooden)" toggle an event on your computer... then do
if rs.getInput("back") then  --change back to where the button is
  <Code here>
end

I think he want's to have a button on his monitor and when he clicks it it toggles to red and emits a redstone signal, if he clicks it again it would toggle back to green and stop the redstone signal... but it is really well encrypted :D

EDIT: There's always someone faster that you :(



#110352 Higher Debug/Sandboxing Level & setfenv

Posted by JokerRH on 15 April 2013 - 09:41 AM in Ask a Pro

View PostBubba, on 15 April 2013 - 09:31 AM, said:

Object orientation is much easier to do with metatables than setfenv...

#1 You have to use self (if you forget the : it'll take you a long time debugging)
#2 A table has always the same function enviroment as it's creating function
#3 Extending a table with anotherone isn't that simple as extends(object)
#4 It is always getting unclear



#110348 Is it possible to do this?

Posted by JokerRH on 15 April 2013 - 09:35 AM in Ask a Pro

View Postdiegodan1893, on 15 April 2013 - 06:54 AM, said:

Doing tostring(var) when printing isn't necessary, it will do it automatically for you.

You can only concatenate a string with a string (or a table with __concat metamethod)



#110341 Higher Debug/Sandboxing Level & setfenv

Posted by JokerRH on 15 April 2013 - 09:17 AM in Ask a Pro

View PostImque, on 14 April 2013 - 08:38 PM, said:

Ok thanks! I don't really a pratical use. What would you need to use this for?

You have to use it for every function that shouldn't use the global enviroment.
os.loadAPI / os.run use it for example, but I used it to program object oriented, too. (You could find the program in the programs section :D)



#109748 Wireless communication without modems?

Posted by JokerRH on 14 April 2013 - 01:10 AM in Ask a Pro

View PostBabyCodder, on 13 April 2013 - 11:19 PM, said:

View PostTheCoryKid, on 13 April 2013 - 12:41 PM, said:

You could pair your turtles: have one with a modem and pickax and another with a modem and chunk loader. Then just program the one with the pickax to move one block ahead of the one with the chunk loader.

Alternatively, if you really want to use just one turtle, then I'm not sure what you could do. If turtles can detect redstone (can they?), then you could use RedPower bundled cables (like Joker said). But I suppose the easiest way would be to have a computer on top of a disk drive on top of the turtle. You could then use the computer to receive the rednet message, save the data to a floppy in the disk drive, then have the turtle process that data.

They can detect redstone. I would vote on the pair'd thing though. As it could be alot better with the following code:
while i < <number of blocks it has to dig> do
  turtle.dig()
  turtle.forward()
  rednet.send(<ID OF PAIRED TURTLE>, "forward")
  i =(i+1)
end

And the chunk loader turtle having:
while true do
  id, command = rednet.recieve()
  shell.run(command)
end
And there will be a program for each command.

I don't think you understood his question.



#109724 help with IM no wireless modems redstone only

Posted by JokerRH on 13 April 2013 - 11:04 PM in Ask a Pro

Use string.byte() to convert it to numbers and string.char() to convert it back.



#109628 LAN cabling

Posted by JokerRH on 13 April 2013 - 12:20 PM in Suggestions

Install redpower and write a serial communication api.
You have 8bit per direction, that should be sufficient. :D



#109627 Wireless communication without modems?

Posted by JokerRH on 13 April 2013 - 12:16 PM in Ask a Pro

You could still use redpower bundled caes.
That's 8bit serial communication (if I recall correctly)
So you'd have to use string.byte to convert the string to a number.



#109175 [lua][coroutine][noerror] Having trouble debugging my coroutine implementation

Posted by JokerRH on 12 April 2013 - 08:01 AM in Ask a Pro

View PostLyqyd, on 12 April 2013 - 05:35 AM, said:

View PostYesurbius, on 11 April 2013 - 08:25 PM, said:

But I realized a few things. First off .. I was thinking that when we are calling resume - we are calling the function itself... Not the case ... we are restarting the execution of the thread within the function - so the parameters of the function don't matter at all to resuming...

I... what? Have you been reading my posts? I said explicitly that the first time we call resume on a newly created coroutine, the parameters will be passed in as the initial parameters to the function. How much of what I've been writing have you been ignoring. No wonder I've been having to repeat myself.

Having a bad day? :P
But Yesurbius is right. The first resume will start the function but any following one will resume inside of the function, right were it yielded



#109084 [lua][coroutine][noerror] Having trouble debugging my coroutine implementation

Posted by JokerRH on 12 April 2013 - 03:16 AM in Ask a Pro

View PostYesurbius, on 11 April 2013 - 08:25 PM, said:

I'ts hanging up in Go .. which is frustrating .. I'll figure out what's causing that ..

It might be the bug with queueEvent.
I already posted that in the bugs section but basically queueEvent won't work until there hasn't been another event before (That does not use queueEvent)
A simple sleep(0) in the beginning of the program should fix that... :D



#108652 [QUESTION] Mouse input for more than one spot?

Posted by JokerRH on 10 April 2013 - 09:55 PM in Ask a Pro

local tab = {
  {1, 1},
  {15, 3}
}



#108638 [lua][coroutine][noerror] Having trouble debugging my coroutine implementation

Posted by JokerRH on 10 April 2013 - 08:44 PM in Ask a Pro

Nice explanation!
In addition to that:
The Filter is passed to os.pullEventRaw(filter), wich will call coroutine.yield(filter). The coroutine runs until it hits the yield function and returns the filter. Next time it'll be resumed if the filter matches.

event, p1, p2, p3, p4 = coroutine.yield(filter)

Edit: You don't have to resume it with the event if you don't use sleep, pullEvent, rednet.receive etc. you can pass it whatever you want, but what I recommend is simply using os.queueEvent and you can create your own event.



#108460 [lua][coroutine][noerror] Having trouble debugging my coroutine implementation

Posted by JokerRH on 10 April 2013 - 07:57 AM in Ask a Pro

View PostYesurbius, on 10 April 2013 - 02:33 AM, said:

What kind of events would pass through our little app? Timer? KeyStroke .. RedNetMessage received? etc?

They are listed on the wiki if you look for os.pullEvent, but yes, these are events :D



#108242 Not Loading API, I think?

Posted by JokerRH on 09 April 2013 - 09:57 PM in Ask a Pro

View Posttheoriginalbit, on 09 April 2013 - 03:55 PM, said:

The problem is that in Lua For loops do not need brackets around its conditional, and when the brackets are actually there it will error with the message you are getting. Remove the brackets and you will be good.

local bool = (1 == 0)
print(bool)
--> false

bool = (1 < 15)
print(bool)
--> true

if true then print("Test") end
--> Test

if (1 == 1) then print("Test") end
--> Test 

@TheOriginalBit: Try it, it should work