Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Knox on Fri 28/05/2010 17:36:07

Title: 'this' cannot be used with primitive types (CursorMode*) **SOLVED**
Post by: Knox on Fri 28/05/2010 17:36:07
Hi, its me again  ;D

Im sure this is going to be another "1question 1 answer" type thread...

I just want to know how to place a (I think its called a "pointer"?) inside a function parameter "thing" ---> ( ) (sorry, I dont know how to call this!) when its a cursor mode (like eModeLookAt, for example):



function cursorAnimOnOff(this CursorMode*, int iXcursor, int iAnimView, int iNoAnim )
{
   if (mouse.GetModeGraphic(this) == iXcursor) //"x" cursored-out
   {
     if (cursorAnim == true)
     {      
       mouse.ChangeModeView(this, iAnimView); //change to normal animated view
     }
     mouse.ChangeModeGraphic(this, iNoAnim); //normal cursor, no animation
   }  
}


When I previously tried "this GUI*" or "this Button*"....it worked...now I try "this CursorMode*" and it gives me an error:

GlobalScript.asc(913): Error (line 913): 'this' cannot be used with primitive types

Whats a primitive type? Im guessing Button* or GUI* arent "primitive types" since those worked and "CursorMode*" didnt?

Are those "pointers"...and most importantly, in the manual they explain what pointers are but is there a list of all "pointers" in AGS somewhere? I couldnt find it.
Title: Re: 'this' cannot be used with primitive types (CursorMode*)
Post by: Ryan Timothy B on Fri 28/05/2010 17:50:46
It's called enumeration (enum, in AGS).

You're actually using it wrong.  It's supposed to be like this (I believe, haven't tested):

function cursorAnimOnOff(CursorMode theMode, int iXcursor, int iAnimView, int iNoAnim )
{
   if (mouse.GetModeGraphic(theMode) == iXcursor) //"x" cursored-out
   {
     if (cursorAnim == true)
     {      
       mouse.ChangeModeView(theMode, iAnimView); //change to normal animated view
     }
     mouse.ChangeModeGraphic(theMode, iNoAnim); //normal cursor, no animation
   }  
}


A pointer used for OBJECT, GUI, etc are just pointing to that particular item.  But since CursorMode is a list of enumerations like: eModeLookat, eModeInteract, etc.  You have to access it like it's a variable type.

So the variable theMode will only use the enumeration types of CursorMode.
Title: Re: 'this' cannot be used with primitive types (CursorMode*)
Post by: Knox on Fri 28/05/2010 18:12:55
AHHHHHhh!! (The Light turns on)

Well that works! Ok, so NOW I get it: CursorMode enumerates things in a list so its called an "enum", GUI or BUTTON are "objects". Wow, ok, that clarified a lot actually. Now I know how to use that :P

I just noticed I could have also have done:
function cursorAnimOnOff(int iMode, int iXcursor, int iAnimView, int iNoAnim )
but then Id have to remember the numbers of different modes instead of its name so the once you gave is much better.

Thanks once again Ryan :)
Title: Re: 'this' cannot be used with primitive types (CursorMode*) **SOLVED**
Post by: Khris on Fri 28/05/2010 18:53:39
To elaborate, enums are ints.
You can assing initial values when declaring an enum, and you can do this:
  Display("%d", eModeInteract);