PDA

View Full Version : Unofficial Novashell Scripting API Documentation Thread



Ian
01-07-2007, 10:31 PM
I'll start with the Color class. These definitions are pretty obvious and uninteresting but oh well.

Color(red: number, green: number, blue: number, alpha: number) -> Color

:Getalpha() -> number
Returns the alpha (transparency) value of the color object.

:GetBlue() -> number
Returns the blue value of the color object.

:GetGreen() -> number
Returns the green value of the color object.

:GetRed() -> number
Returns the red value of the color object.

:Setalpha(alpha: number)
Sets the alpha (transparency) value of the color object.

:SetBlue(blue: number)
Sets the blue value of the color object.

:SetGreen(green: number)
Sets the green value of the color object.

:SetRed(red: number)
Sets the red value of the color object.

(Note to Seth: why are Setalpha/Getalpha not SetAlpha/GetAlpha? I've once already screwed up the name when trying to test it. :( )

Ian
01-07-2007, 10:32 PM
Rect(x1: number, y1: number, x2: number, y2: number)

:GetHeight() -> number
Returns the height of the rectangle.

:GetWidth() -> number
Returns the width of the rectangle.

:IsOverlapped() -> number
This appears to be broken. I presume it should take a single argument (another Rect) and return true if the two overlap, but instead it takes no arguments and returns the same value as GetHeight().

.bottom -> number
The bottom y (y2) coordinate of the rectangle.

.left -> number
The left x (x1) coordinate of the rectangle.

.right -> number
The right x (x2) coordinate of the rectangle.

.top -> number
The top y (y1) coordinate of the rectangle.

Ian
01-07-2007, 10:36 PM
Vector2(x: number, y: number) -> Vector2

:Cross() -> number
Returns the cross product of the vector. (In other words, it rotates the vector 90 degrees.)

: Dot(Vector2) -> number
Returns the dot product of the two vectors.

:Length() -> number
Returns the length of the vector.

.x
The x value of the vector.

.y
The y value of the vector.

Seth
01-08-2007, 12:48 AM
Ok, now I just feel guilty that I haven't put up API documentation yet, I'm going to make this a priority. The reason I've been putting it off is I want to setup a way to parse the source to build it, otherwise I'll never keep it updated.

Agree on the Setalpha, I'm going to fix the capitalization in the next build, beware of script errors.

And thanks, IsOverlapped was connected to GetHeight in luabind, whups!

Ian
01-08-2007, 06:01 AM
Ok, now I just feel guilty that I haven't put up API documentation yet, I'm going to make this a priority. The reason I've been putting it off is I want to setup a way to parse the source to build it, otherwise I'll never keep it updated.

Something like Doxygen?

Also, Novashell crashes when you try to call an internal-use symbol. (i.e. one of the following: App, BaseEntity, Brain, BrainManager, Camera, CameraSettings, DataManager, Entity, GameLogic, GoalManager, InputManager, LayerManager, Map, MapManager, Material, MaterialManager, SoundManager, State, TagObject, TagManager, TextManager, WatchManager.) Do any of these have any use inside Lua? If not, is it possible to make them invisible, or at least mangle their names?
(I ran across this problem when I wanted to make a function called Map.)

Seth
01-08-2007, 07:54 AM
Something like Doxygen?

Also, Novashell crashes when you try to call an internal-use symbol. (i.e. one of the following: App, BaseEntity, Brain, BrainManager, Camera, CameraSettings, DataManager, Entity, GameLogic, GoalManager, InputManager, LayerManager, Map, MapManager, Material, MaterialManager, SoundManager, State, TagObject, TagManager, TextManager, WatchManager.) Do any of these have any use inside Lua? If not, is it possible to make them invisible, or at least mangle their names?
(I ran across this problem when I wanted to make a function called Map.)

Hmm, I will check out Doxygen, I know there are a lot of C++ documentation systems but not sure if anything can format info from luabind declarations in a decent way. :confused: Would sure save some time to find something though!

Reserved names of class types - these are all novashell classes that are exported to lua on purpose - (for instance, "this" is a pointer to an Entity object when used in an entities script) - and in some cases can be instantiated (Color, Rect) but in most cases you can't, except through special means. (CreateEntity, CreateSpecialEntity)

I'm not sure if there is a way I can get lua to give a clear error if you use a reserved word or not, hate to see crashes happen for any reason.

PS: Hmm, you know, I could probably obfuscate some of those names, like Map, internally and nobody would care, but I think in the future some of those may be instantiable, or you may want to use the lua method to get the class type, in that case you'd want to see the return value is a Map and not a MapJHD&23 or something.

UPDATE: Some of novashells API documentation is now available here (http://www.rtsoft.com/novashell/docs/api).