oos.graphic.btn = function ( obj, string, settings ) if not type ( obj ) == 'table' then -- This is where it misses, because at the bottom you'll see that I put in a string, but for me it fails to see that obj is not a table. oos.functions.throw ( ERROR, 'SELF expects a table, not' .. type ( obj ) ); return false; end end -- ( OpenOS: Debug ) -- oos.graphic.btn ( 'This is not a table', 'Button Content', { ["width"] = 16, ["height"] = 3, ["offsetY"] = 1, ["offsetX"] = 1, ["foregroundColor"] = colors.white, ["backgroundColor"] = colors.red } );
Does anyone else have this problem?
It is not anything wrong with the "oos.functions.throw" function, but anyway, this is how it works:
oos.functions.throw = function ( Type, message ) local ocolor = oos.term.getTextColor ( ); local obgcolor = oos.term.getTextColor ( ); if not type ( Type ) == "string" then oos.term.setTextColor ( oos.settings.types [ ERROR ].bg ); oos.term.setBackgroundColor ( oos.settings.types [ ERROR ].color ); write ( oos.settings.types [ ERROR ].title ); oos.term.setTextColor ( oos.settings.types [ ERROR ].color ); oos.term.setBackgroundColor ( oos.settings.types [ ERROR ].bg ); write ( ' ' .. 'Expected TYPE at oos.functions.throw ( TYPE, message )' ); oos.term.setTextColor ( ocolor ); oos.term.setBackgroundColor ( obgcolor ); print ( '' ); return false; end if oos.settings.types [ Type ] == nil then Type = 'UNKNOWNException'; end oos.term.setTextColor ( oos.settings.types [ Type ].bg ); oos.term.setBackgroundColor ( oos.settings.types [ Type ].color ); write ( oos.settings.types [ Type ].title ); oos.term.setTextColor ( oos.settings.types [ Type ].color ); oos.term.setBackgroundColor ( oos.settings.types [ Type ].bg ); write ( ' ' .. message ); oos.term.setTextColor ( ocolor ); oos.term.setBackgroundColor ( obgcolor ); print ( '' ); -- New Line return true; end
These variables below is being implemented at the the very top of my os:
ERROR = 'ERRORException'; WARNING = 'WARNINGException'; SUCCESS = 'SUCCESSException'; INFO = 'INFOException'; USAGE = 'USAGEException'; set = 'SET'; get = 'GET'; current = 'CURRENT';
So what makes my oos.graphic.btn function fail?
The table which contains the different exceptions in the throw function
-- ( OpenOS: Exception delarations ) -- oos.settings.types = { ['ERRORException'] = { color = c.red, bg = c.black, title = 'Error' }, ['WARNINGException'] = { color = c.yellow, bg = c.black, title = 'Warning' }, ['SUCCESSException'] = { color = c.green, bg = c.black, title = 'Success' }, ['INFOException'] = { color = c.blue, bg = c.black, title = 'Info' }, ['USAGEException'] = { color = c.cyan, bg = c.black, title = 'Usage' }, ['UNKNOWNException'] = { color = c.gray, bg = c.black, title = 'Unknown' } };
Edited by TechnicalCoding, 03 February 2017 - 10:41 PM.