jakj Posted July 19, 2013 Author Posted July 19, 2013 First it said no carriage or to many carriages atached. then i replaced the controller with a new one and it worked with lua. but when i try it using my program i get fail again Aha, yes, that's actually a known bug in my code that will be fixed in a future release. I apologize in the mean time for the inconvenience. For now, breaking/replacing the controller is the best way to fix it. But if you break/replace the controller and it works with lua directly but not with your program, then it has to be an issue with your program. Hrm, noticed a new Tinker's Construct build was released with the Drawbridge block that mDiyo was playing around with. So I threw that into the testing pack to see how that would behave on a carriage. I would describe what I've seen so far as "peculiar", but not game-breaking, ie. it works, but it does interesting things when you move it while it's extended, so I wouldn't worry about adding support for that anytime soon. (The Fancy Redstone Block with an extended activation range doesn't affect engines/motors indirectly, but we can call that a feature here--you coded for an explicit strength here, I believe.) I did code for explicit strength and directionality, because otherwise there can be confusion from sloppy redstoning that would cause it to potentially activate from a direction the user doesn't expect; It's better this way, where any non-clean signal simply doesn't work, instead of working in an unexpected manner. Quote
Spaceshipable Posted July 19, 2013 Posted July 19, 2013 for the simulate flag in the cc command, what does it return? Is it just true or false? If so I would suggest it returns the same info as the error for when it can't move. This would allow users to determine why their carriage isn't moving without having to stop an start the program. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 for the simulate flag in the cc command, what does it return? Is it just true or false? If so I would suggest it returns the same info as the error for when it can't move. This would allow users to determine why their carriage isn't moving without having to stop an start the program. It'll still give out an error message just the same. The only thing the simulate flag does is cause the carriage to not actually move. Quote
Spaceshipable Posted July 19, 2013 Posted July 19, 2013 It'll still give out an error message just the same. The only thing the simulate flag does is cause the carriage to not actually move. Ahh so it will stop the program regardless? Maybe you could make peripheral.call("left","move",2,true,false) return a string that says the error? This way if there is a blockage or some other error the program doesn't have to stop. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 Ahh so it will stop the program regardless? Maybe you could make peripheral.call("left","move",2,true,false) return a string that says the error? This way if there is a blockage or some other error the program doesn't have to stop. The thing is, I have absolutely no clue how ComputerCraft works. I know the basic rudiments, since it is simulating a CLI OS, but not how all the little bits interact. The way the API works, I am expected to return "an array of whatever". (That's literally how it's coded.) These items are then converted by ComputerCraft from Java to whatever the hell Lua does. Right now, on failure, I throw an exception (which ComputerCraft prints as a string), or I return an array of one boolean of value true. So you'll have to tell me what is actually useful for writing programs. Do I return a string error message on failure and nothing on success? Or empty string on success? Or return string if success and boolean if failure? Or should I always return a boolean and string at the same time, and the string is empty if the boolean is true for success? Or should I return just a boolean true on success but a boolean false on failure and a string with it? How do I determine whether or not an error is printed instead of returning a value? I have absolutely no way to detect the difference between "user typed command while looking at computer screen" and "user wrote a program that is being run and issued the command". Quote
Spaceshipable Posted July 19, 2013 Posted July 19, 2013 What would be helpful would be to have the command return a string stating the error and a table for the location of any obstructive block as opposed to exiting the program. There would not need to be an error at all. If people want to know what the issue is they can write some code to find out. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 What would be helpful would be to have the command return a string stating the error and a table for the location of any obstructive block as opposed to exiting the program. There would not need to be an error at all. If people want to know what the issue is they can write some code to find out. The error message already includes the coordinates of an obstructing block. But you haven't answered my question: What type(s) of value(s) do you want it to return in what circumstances? For reference: callMethod java.lang.Object[] callMethod(IComputerAccess computer, int method, java.lang.Object[] arguments) throws java.lang.Exception This is called when a lua program on an attached computer calls peripheral.call() with one of the methods exposed by getMethodNames(). Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe when interacting with minecraft objects. Parameters: computer - The interface to the computer that is making the call. Remember that multiple computers can be attached to a peripheral at once. method - An integer identifying which of the methods from getMethodNames() the computer wishes to call. The integer indicates the index into the getMethodNames() table that corresponds to the string passed into peripheral.call() arguments - An array of objects, representing the arguments passed into peripheral.call(). Lua values of type "string" will be represented by Object type String. Lua values of type "number" will be represented by Object type Double. Lua values of type "boolean" will be represented by Object type Boolean. Lua values of any other type will be represented by a null object. This array will be empty if no arguments are passed. Returns: An array of objects, representing values you wish to return to the lua program. Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type. All other types will be converted to nil. You may return null to indicate no values should be returned. Throws: java.lang.Exception - If you throw any exception from this function, a lua error will be raised with the same message as your exception. Use this to throw appropriate errors if the wrong arguments are supplied to your method. Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 This mod is basically perfect. I also respect you for the license - I come from what is apparently a dying breed of modders, who the entire idea of putting copyright on a mod beyond 'dont say that it belongs to you', or making a mod closed-source, would be absurd. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 This mod is basically perfect. I also respect you for the license - I come from what is apparently a dying breed of modders, who the entire idea of putting copyright on a mod beyond 'dont say that it belongs to you', or making a mod closed-source, would be absurd. Yes, it's a sad state of affairs: Recent events have pissed me off so much, and just proven all over again that the social clique triumphs over all, including fairness and reason, and that the average user/consumer of anything has as much awareness and willpower as a noodle soaked three days. It's put me off of Minecraft all over again, and this mod is the only thing keeping me going right now. For a little while, it looked like things might start to finally turn around, move in a positive direction...and then the hordes start popping out of the woodwork, swarming all over everything, whitewashing the entire thing into some sort of pleasant comedic routine, a shaken finger with "naughty, naughty", and a little sandbox all of his own. Even a guy I actually used to defend, I now find out has been doing the same bullshit the whole time and I didn't even know it. I essentially lied for him out of pure ignorance. I feel disgusted. Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 Yes, it's a sad state of affairs: Recent events have pissed me off so much, and just proven all over again that the social clique triumphs over all, including fairness and reason, and that the average user/consumer of anything has as much awareness and willpower as a noodle soaked three days. It's put me off of Minecraft all over again, and this mod is the only thing keeping me going right now. For a little while, it looked like things might start to finally turn around, move in a positive direction...and then the hordes start popping out of the woodwork, swarming all over everything, whitewashing the entire thing into some sort of pleasant comedic routine, a shaken finger with "naughty, naughty", and a little sandbox all of his own. Even a guy I actually used to defend, I now find out has been doing the same bullshit the whole time and I didn't even know it. I essentially lied for him out of pure ignorance. I feel disgusted. I cannot explain how confused and flabberghasted I was when I realized that the source to a mod wasn't available for the first time, heh. Eloraam might have been the worst offender, but she certainly wasn't the only one. Now, between this and immibis's microblocks/redlogic, I have no reason to ever install RP2 again. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 I cannot explain how confused and flabberghasted I was when I realized that the source to a mod wasn't available for the first time, heh. Eloraam might have been the worst offender, but she certainly wasn't the only one. Now, between this and immibis's microblocks/redlogic, I have no reason to ever install RP2 again. Minecraft modding has some how transcended computer programming into a realm of flying chickens and turds that recite Klingon poetry. And I can't even fathom how it happened. Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 It is because that mods for minecraft are seeing a wider audience than nearly any modding community has gotten in the past. This has led to lots of sheeple getting involved, and cult-like reverence for certain individuals, rather than their work. All the drama aside, I haven't combed through all 33 pages of this thread - has anyone made a movement API or server for CC and this? I've started working on one, but I'd hate to reinvent the wheel for no reason. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 It is because that mods for minecraft are seeing a wider audience than nearly any modding community has gotten in the past. This has led to lots of sheeple getting involved, and cult-like reverence for certain individuals, rather than their work. All the drama aside, I haven't combed through all 33 pages of this thread - has anyone made a movement API or server for CC and this? I've started working on one, but I'd hate to reinvent the wheel for no reason. One guy kind of did a bit of that, but it's not complete. Space-ship-something-or-other is his name. Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 Cool, hopefully I'll have something to post today. It allows enqueuing, then executing of movements, and notification of completion, over rednet. Quote
Spaceshipable Posted July 19, 2013 Posted July 19, 2013 I have been playing with a program but it's not an API (I wouldn't know how to go about doing anything like that) Quote
Spaceshipable Posted July 19, 2013 Posted July 19, 2013 The error message already includes the coordinates of an obstructing block. But you haven't answered my question: What type(s) of value(s) do you want it to return in what circumstances? I would suggest 3 commands that give 3 responses. The first would be 'drive.moveable' which would return a boolean. The second would be something like 'drive.nomovereason' which would return a string stating the reason for not moving and the third would be drive.obstructionlocation which would return a table of the coordinates of the obstructive block. Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 I have been playing with a program but it's not an API (I wouldn't know how to go about doing anything like that) I was going to do this as an API at first, but there isn't much point. It has to be a 'closed startup loop' due to the reboot thing, so... yea. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 I would suggest 3 commands that give 3 responses. The first would be 'drive.moveable' which would return a boolean. The second would be something like 'drive.nomovereason' which would return a string stating the reason for not moving and the third would be drive.obstructionlocation which would return a table of the coordinates of the obstructive block. You keep saying "table", and I don't know what the fuck that is. Do I return three numbers as separate objects? Do I return one object which is an array of three numbers? Do I have to do some sort of key-value pairing? What? I'm not getting paid to do this, so you're going to have to pick up the slack and make me understand to actually get what you want. Quote
theprolo Posted July 19, 2013 Posted July 19, 2013 An array is basically a sort of table. I'm not sure how this would look your end, but in LUA it's used like this: Table = { ["Value"] = key, ["Value2"] = somethingelse, ["Bob"] = "Fred", ["TheUniverse"] = 42 } This is all one value - basically an array. The values inside are accessed by using "Table["Value"] Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 a table in lua is analogous to a map or array in java, its a kv pair, which defaults to having 1..n as keys, and can also contain arbitrary executable code, heh. Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 Okay, guys, I can't return a Map object. I return an array of object, specifically "Object [ ]". This array can contain anything, including other arrays. Possibilities I can think of off the top of my head: [ key1 , value1 , key2 , value2 , key3 , value3 ] [ [ key1 , value1 ] , [ key2 , value2 ] , [ key3 , value3 ] ] [ [ key1 , key2 , key3 ] , [ value1 , value2 , value3 ] ] I can't generate the output without knowing what the output should be, and I have neither the time nor inclination to not only learn Lua but also learn Java<->Lua glue just to generate a couple of output values in a Minecraft mod. If you can tell me what I should return in a form I can actually implement, then hey. Quote
Alexander0507 Posted July 19, 2013 Posted July 19, 2013 I have played around with my program a little bit and it works now. But i wanted to know is there a way to restart the program after an error-message from the frame controller ? Quote
jakj Posted July 19, 2013 Author Posted July 19, 2013 I have played around with my program a little bit and it works now. But i wanted to know is there a way to restart the program after an error-message from the frame controller ? I think that's what they're trying to get me to do, to return the error message as a value instead of aborting the process. If we can work out how to implement that in Java, then your program should not be cancelled on error in the future. Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 Oh, guys... that is the issue? Try something like this. You'll get the normal return value of move in 'status', and a string containing the error in 'err' local status, err = pcall(p.move(0, false, true)) Quote
fingerboxes Posted July 19, 2013 Posted July 19, 2013 Also, here is a preliminary version of my controller program, if anyone wants to try it out. It isn't complete, but I could use some feedback http://pastebin.com/rcdPpr1y set it as the startup program of a computer attached to the controller, and connect that computer to another using modems. Then send a rednet message of the type described in the comments to program a path, and the other kind to execute the path. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.