Posted 22 March 2014 - 07:26 PM
SOLVED: (kind of), I rewrote the whole thing in a different way suggested by CometWolf
I am in the process of making an API for items to be displayed on a monitor. These item types would include: buttons, text boxes, pictures, screens (which would fill the entire screen and contain other types of items inside of them), etc. I have, however, only worked on the buttons and the screens, and I am now getting an error when I test it.
The API is here, and the program I am using to test it is here.
When I run "main" (the program I am using to test it), I get the error "204". I have never seen this one before, and couldn't find anything about it on Google. I recently changed something, and before that I was getting an error on items:84, "Attempt to index ? (a nil value)".
I can tell you what it is supposed to do:
initialize(side) wraps the monitor on specified side, and creates some necessary variables/arrays.
mkItem(…) adds an entry into the array items, which contains data for all created items. It takes the arguments in this form:
if making a button then: mkItem(type,name,text,w,h,txtColor,bgColor,fn,args) where:
"type" = "btn" (for "button")
"name" = a string for the button to be called with
"text" = text to be displayed on the button
"w","h" = width and height of button on monitor
"txtColor" = color of text displayed on button (colors API)
"bgColor" = color of button (background) (colors API)
"fn" = function to be called when button is pressed
"args" = an array of arguments to call the function with
if making a screen then: mkItem(type,name,items,bgColor) where:
"type" = "scn" (for "screen")
"name" = a string for the screen to be called with
"items" = an array containing the items to be displayed on this screen. It has the structure:
{{item1_name,item1_x,item1_y},{item1_name,item1_x,item1_y}} where:
"name" = the name declared in mkItem()
"x" = the x coord to display that item at
"y" = the y coord to display that item at
"bgColor" = the color for the background of the screen (colors API)
dispItem(…) actually puts already created items onto the screen. It takes the arguments in this form:
if displaying a button then: dispItem(name,x,y) where:
"name" = the name declared in mkItem()
"x" = the x coord to display the item at
"y" = the y coord to display the item at
if displaying a screen then: dispItem(name) where
"name" - the name of the screen declared in mkItem()
(it doesn't need x,y because it takes up the whole screen)
waitEvent() waits for the monitor to be touched, and, if a button is clicked, it calls that button's function.
Thank you.
I am in the process of making an API for items to be displayed on a monitor. These item types would include: buttons, text boxes, pictures, screens (which would fill the entire screen and contain other types of items inside of them), etc. I have, however, only worked on the buttons and the screens, and I am now getting an error when I test it.
The API is here, and the program I am using to test it is here.
When I run "main" (the program I am using to test it), I get the error "204". I have never seen this one before, and couldn't find anything about it on Google. I recently changed something, and before that I was getting an error on items:84, "Attempt to index ? (a nil value)".
I can tell you what it is supposed to do:
initialize(side) wraps the monitor on specified side, and creates some necessary variables/arrays.
mkItem(…) adds an entry into the array items, which contains data for all created items. It takes the arguments in this form:
if making a button then: mkItem(type,name,text,w,h,txtColor,bgColor,fn,args) where:
"type" = "btn" (for "button")
"name" = a string for the button to be called with
"text" = text to be displayed on the button
"w","h" = width and height of button on monitor
"txtColor" = color of text displayed on button (colors API)
"bgColor" = color of button (background) (colors API)
"fn" = function to be called when button is pressed
"args" = an array of arguments to call the function with
if making a screen then: mkItem(type,name,items,bgColor) where:
"type" = "scn" (for "screen")
"name" = a string for the screen to be called with
"items" = an array containing the items to be displayed on this screen. It has the structure:
{{item1_name,item1_x,item1_y},{item1_name,item1_x,item1_y}} where:
"name" = the name declared in mkItem()
"x" = the x coord to display that item at
"y" = the y coord to display that item at
"bgColor" = the color for the background of the screen (colors API)
dispItem(…) actually puts already created items onto the screen. It takes the arguments in this form:
if displaying a button then: dispItem(name,x,y) where:
"name" = the name declared in mkItem()
"x" = the x coord to display the item at
"y" = the y coord to display the item at
if displaying a screen then: dispItem(name) where
"name" - the name of the screen declared in mkItem()
(it doesn't need x,y because it takes up the whole screen)
waitEvent() waits for the monitor to be touched, and, if a button is clicked, it calls that button's function.
Thank you.
Edited on 23 March 2014 - 04:02 AM