Jump to content


Writer's Content

There have been 13 items by Writer (Search limited from 10-February 22)


By content type

See this member's

Sort by                Order  

#232887 Rotating Buttons

Posted by Writer on 19 September 2015 - 02:00 PM in Ask a Pro

View PostBomb Bloke, on 19 September 2015 - 01:44 PM, said:

Intersperse print statements throughout your script (or writes to a log file, whatever's easier for you) so you can pinpoint the line within your code that's leading to the error within the window API - as Yami notes, it'll be one of the ones where you call a term function. Once you've figured out the culprit, have the script print out the values you're passing to the problematic term function before it goes ahead and does so. You'll then know which variable has the incorrect value, and can start work of figuring out how it got that way.

I actually made that on the original code. Ended up figuring out what the problem was. Apparently, the sColor variable should be declared either as a pointer (I believe this is the term for 'local sColor') outside the if/else statement or as a global variable. I didn't know that local variables inside if/else statements could only be used inside these statements.

View PostKingofGamesYami, on 19 September 2015 - 12:10 PM, said:

		addButton(1, 5, 9, 3, 'color', defaultColors[9], 2)
...
function addButton(id, decrement, increment, y, type, color, value)
		registeredButtons[id] = {}
		registeredButtons[id]['minX'] = decrement
		registeredButtons[id]['maxX'] = increment
		registeredButtons[id]['y'] = y
		registeredButtons[id]['type'] = type
		registeredButtons[id]['btn_color'] = color
		registeredButtons[id]['value'] = value
end
...
				local bColor = defaultColors[data.btn_color]

You end up with nil, since defaultColors[ 256 ] doesn't exist. From the first snippet, change it to simply '9', not defaultColors[ 9 ] or change the last snippet to just data.btn_color.

If you didn't already know, that particular error means a term function that expected a number didn't get one - culprits are commonly term.setCursorPos and term.setBackgroundColor.

Yap. That was the other problem. Thank you very much to both of you for your help! :)



#232881 Rotating Buttons

Posted by Writer on 19 September 2015 - 01:30 PM in Ask a Pro

Dang, I had done the same mistake on another parameter on the same function. Looks like I can't have multiple ideas while programming. Nevertheless, I changed the program but it keeps giving me the same error.



#232868 Rotating Buttons

Posted by Writer on 19 September 2015 - 11:52 AM in Ask a Pro

I'm currently making a turtle miner program from scratch. Although there is already a program in the turtle itself that does what I want it to do, I wanted to challenge myself. This program, beyond the program in the turtle itself, will contain a GUI program inside a computer (which will send various commands via rednet), where you will be able to set different variables, dynamically stop the mining process, etc. I'm currently working on the computer part, but I quickly found a problem on the buttons.

You see, I want my GUI to have cycling buttons, aka, a selector with two buttons, one of which will increment the value of the selector and another button which will decrement the value. This type of button will be used to set both colors (background color, text color...) and numbers (specifically for the mining area).

The problem that I'm having is that, whenever I run the code, the computer registers the buttons, but crashes when drawing them. It says something along the lines of 'window 57: Expected number' and shuts itself off. I've tried to work around the function that draws the buttons, but nothing seems to work, since the program keeps crashing all the time. Here's the code: http://pastebin.com/3BXYnbiC



#211917 Problems with OpenPeripherals

Posted by Writer on 01 April 2015 - 05:09 PM in Peripheral Help and Discussion

Really? So, I would have to do something like this, right?:
b = peripherals.wrap("right")
b.addBox(10, 10, 50, 50, 0xFFFFFF, 1)
b.sync()

If so, can you explain a bit more about the "sync" function?



#211761 Problems with OpenPeripherals

Posted by Writer on 31 March 2015 - 04:51 PM in Peripheral Help and Discussion

Figured it out: the newest version of the openPeripherals is kinda broken. Don't know if it is the integration part or anything else. I downgraded to the previous version and it worked. Anyway, thanks for your help Bomb Bloke. :)



#211728 Problems with OpenPeripherals

Posted by Writer on 31 March 2015 - 02:47 PM in Peripheral Help and Discussion

The table is blank and according to "openp/docs right addBox", I'm doing everything right! So, I really don't know what I'm doing wrong.



#211725 Problems with OpenPeripherals

Posted by Writer on 31 March 2015 - 02:31 PM in Peripheral Help and Discussion

I haven't tried to print the table. Will try that in a bit.



#211711 Problems with OpenPeripherals

Posted by Writer on 31 March 2015 - 01:40 PM in Peripheral Help and Discussion

I made a modpack where I included openPeripherals (and necessary parent mods) and peripherals++. I tried to make a program using the bridge and the terminal glasses, but before I went to the lua prompt and tested the addBox method. First I placed the bridge on the right side of the computer and clicked with the terminal glasses on the bridge and equiped them. Then I connected the peripheral to the computer using "p = peripheral.wrap("right")". Up until here, everything went great. But then I typed "p.addBox(10, 10, 50, 50, 0xFFFFFF, 0.5)" and it returned a table, but it didn't appeared anything in my screen. I don't know if there is something wrong with the mod or if it is just me derpin or if the peripherals++ is messing with openPeripherals. BTW, I'm using ComputerCraft V 1.65, OpenMods V 0.6, OpenPeripherals V 0.5 and peripherals++ V 1.2.0-beta4. Please help me!



#203262 Tips to a cool program

Posted by Writer on 16 January 2015 - 04:17 PM in Ask a Pro

Thank you so much! Although your API is really cool, right now I kinda changed my mind. What I wanted was something like Google Glasses, with a menu where you selected what you want with, in this case, your mouse, but I already found a new way to do the thing. I may then post the code when I'm done. :)



#203210 Tips to a cool program

Posted by Writer on 15 January 2015 - 09:49 PM in Ask a Pro

No, with the moar peripherals I will be able to digit a code and it will execute it. Nothing to do with range or mouse position. About the bars, well then. Looks like there won't be 2 mods in the modpack I'm playing (they really weren't necessary, they were just there when I installed the modpack).



#203204 Tips to a cool program

Posted by Writer on 15 January 2015 - 09:05 PM in Ask a Pro

That is a shame. I will then have to use the moar peripherals to do this task (it will be easier, I think) cause I think there is a range limit. And yes, indeed it is amazing how he did! BTW, is it possible to eliminate the minecraft bars (like health, hunger, xp, etc)?



#203200 Tips to a cool program

Posted by Writer on 15 January 2015 - 08:11 PM in Ask a Pro

Still, I just wanna know if there is a way to do without the ccsensor. I could use the API, but if there was a better way, I don't really mind to to an entire API from scratch.



#203192 Tips to a cool program

Posted by Writer on 15 January 2015 - 06:37 PM in Ask a Pro

I'm making an utility program that will allow me to control my base at distance with the Terminal Glasses from OpenPeripherals and the ChatBox from MoarPeripherals. The problem is that I have a limited space to work with and my idea to save space is to enable the glasses if a moving point hovers over a certain area (I saw it in this video: https://www.youtube....h?v=eqtLcN3v1Rs). Now, this video is kinda old and I don't know if it is possible to do anymore. My first question is it possible? My second question is if it is possible to get rid, somehow, of the inventory/XP/health/food/etc bars with something.