Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Knox

#601
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):


Code: ags

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.
#602
Dang it, thats dumb of me :P
Works great now...thanks once again guys!!
#603
Hi,

Im guessing this is pretty simple to answer but I cant debug this on my own. I first did the script in the manual for saving a screenshot:
Code: ags

  String input = Game.InputBox("Type the filename of your screenshot:");
  input = input.Append(".bmp");
  SaveScreenShot(input);


This works fine, it saves the bmp with the right filename the user inputs.
Next, I tried to accomplish the same but with my own gui:
Code: ags

function openScreenShotGUI()
{
  mouse.Mode = eModePointer;
  gScreenshotGUI.Visible = true;
  input = txtScreenshotInput.Text;
  input = input.Append(".bmp");
}

The button that takes the screenshot:
Code: ags

function btnScreenshot_OK_OnClick(GUIControl *control, MouseButton button)
{
  SaveScreenShot(input);
  gScreenshotGUI.Visible = false;
  mouse.Visible = false;
}

At the top of my global script, I declare the string "input":
Code: ags

String input;


However, with my custom GUI, the screenshot gets saved but there is no name...its just .bmp. Im guessing for some reason the input string gets reset to "null" when I call the function to take the screenshot?

What did I do wrong?
#604
Wow, thanks for explaining things guys...I got it working perfectly...just to say I wasnt using 3 guis (a, b and c)...its actually 15 and much more going on then just turning off and on gui's...:P Now I can add more gui's to the list in the future and it will behave perfectly without having to re-type the same code all over again! Im starting to really enjoy scripting :)

ps: I just bought a C++ for Dummies book...hope it helps :P
#605
Hey Ryan :)

Ok, so the array elements have to be declared inside game_start...why? Global Ints + Strings, etc...can be declared at the top of the global script, so I just want to know how come its different for arrays?

Ok, Ill try this out and let you know what happens. Im going to look up #define in google to see what it means :P

Thanks
#606
Lets say I have 3 gui's, and each gui can close each other with keyboard shortcuts if one of  them is opened...as in, say guiA is open and I press "b" to open guiB, guiA will close and guiB will open...same thing for any other combination of gui's + their shortcuts. Also, if none are open, pressing the shortcut button wont close anything, it will just open the gui assigned to that shortcut.

Ill try to explain what Im after, let me know if it isnt clear:

Id like to add the names of these gui's into an a global string array so that I can use it later in a function, and be able to exclude the function parameter's gui name from the array and do stuff to each remaining element in that array...something like this:

Code: ags

String guiList[3] = {gA, gB, gC}

function hideGui(this GUI*)
{
  if (this.Visible) return;
  else
  {
    //exclude "this" from array guiList[]; (not sure how to write this line)-->
    guiList[] -= this //(something like this?)
    for $each in guiList[] //for each element now remaining in the array after removing "this"
    {
      $each.Visible = false; //set the visibility to false
    }
  }
}


I looked up Arrays in the Manual but Im still not too sure how to do this...Im thinking I might have to convert the gui names into ints and then use their index? Im confused!

#607
Hi Khris,

Ok Im going to see what I can do with this for now. Thanks!
#608
Ive recently learnt how to make my first function with parameters and it looks like this:
Code: ags

function off_SoTurnOn(this Button*)
{
  if (this.NormalGraphic == 1175)
  {
    this.NormalGraphic = 1176;
    this.PushedGraphic = 1175; 
    this.MouseOverGraphic = 1184;
  } 
}


I was wondering how can I add a global variable as  the parameter...something like this;

Code: ags

function myFunction(this GlobalVariable*)
{
   //do something
}


Basically I just want to be able then to type in the name of my global variable in another function, (myVariable.myFunction) and it will execute more script.

Since I couldnt figure it out, I tried to do this instead as a work-around but I get an error I cant convert 'Button*' to 'const string';

Code: ags

function panelSettingsRestore(this Button*)
{ 
//the name of my variable is the same as the button name, plus "Restore" (btnMyVariableRestore)

 String globalVarName = (this + "Restore");  
 if (globalVarName == true)
  {
    this.off_SoTurnOn();
  }
  else
  {
    this.on_SoTurnOff();
  }

}

So how do I "get" the String "contents" from a Button* name and be able to add other pieces of "string" to make a new string? ...and even better, how do I just add global variables I have declared at the top of my global script into a parameter for a function?

Hope this makes sense :P
#610
Hi Ryan!

Thanks for your help, I got it working now! Man, I was sooo close...Im slowly learning :P

Now, one last question:

This could create a problem when I activate speech, since the text can be censored but the same audio file with swearing will be played. I guess I can use "if/ else", but then I would have to write the dialog line twice and defeats the purpose of my above script. Is there a way to make the call to the audio file a variable aswell? Something like:

Code: ags

function swearAudio(int swearFile)
{
  if matureLanguage == true
  {
    return swearFile; //which would be file #2 (cEGO2.wav)...the line with swearing
  }
  else
  {
    return 1; //which would be file #1 (cEGO1.wav)...the line with a "Beep" sound instead
  }
}


This is normally how we'd write the line with the audio file for speech:
Code: ags

cEgo.Say (&2 "Go %s yourself.", swear("Fuck"));


Is it possible to make the "&2" audio file call a variable? (the number 2 here would reflect cEgo2.wav)...something like:
Code: ags

cEgo.Say("%d "Go %s yourself.", swearAudio(2), swear("Fuck"));

#611
Ive got a game setting that turns swearing on or off. If the mode is on, you see swearing in the text and dialog. I saved this setting in a bool and by default its true:
Code: ags
bool matureLanguage = true;


I wrote this String, if matureLanguage is false, instead of the inputted swear word string, display a "censor" of characters:
Code: ags

String swear(String sSwearWord)
{
  if (matureLanguage == true)
  {
     return sSwearWord;
  }
  else
  {
    sSwearWord = "$%#@";
    return sSwearWord;
  }
}


However, I dont know exactly how to display this (with Display, Say or in a dialog). This was my best attempt:

Code: ags
    Display("Go %d yourself.", String swear(Fuck)); 


How would I display this in dialog, say command or with display?

#612
Ok Ill try to debug this then...its something that I put off on my todo list for too long.

I hope I find the prob :P
#613
True, its not really necessarry to create the fridges as objects...hotspots do the same thing!

Ok, good to know Im on the right track :P
#614
Sorry to re-open, but would there be an active link somewhere to this module? It seems they are all dead and not to be found on american girl scouts :P
#615
I found a way to fake a "container" and I was wondering if you guys thought its an "ok" way to do it...or if you knew of an even better way?

Lets say you have a fridge in a room. I make the fridge an object. When you click on it, it opens another room with a closeup view of the fridge. This fridge is also an object. On top of the fridge are my sprites of other objects (milk, bread, etc). When you click the hand icon, it makes the objects disappear and adds it to your inventory. If you want to put it back, when you click on the fridge object with the item's cursor, it will just make the object re-appear and its then removed from your inventory.

Im guessing that's what everyone else is doing, right?
#616
First off Id like to say this is a great module!!

Im not sure if Im the only one but it seems that when the guiportrait is "in action" over a GUI, the framerate drops about 10fps...is this what other people are getting as results?

Of course, Ive got some tween animations running in the backgrouns aswell (on the gui that is behind the guiportrait).
#617
Hey Calin!

That's incredibly simple, for some reason I thought I "had" to use the "SelectNextMode"!

Ok, here's what I did and it works great:

Code: ags

      {
        if(mouse.Mode == 0) mouse.Mode = 13;
        else if(mouse.Mode == 13) mouse.Mode = 1;
        else if(mouse.Mode == 1) mouse.Mode = 2;
        else if(mouse.Mode == 2) mouse.Mode = 3;
        else if(mouse.Mode == 3) mouse.Mode = 8;
        else if(mouse.Mode == 8)
        {
          if (player.ActiveInventory != null)
          mouse.Mode = 4;
          else
          {
            mouse.Mode = 0;
          }
        }
        else if(mouse.Mode == 4) mouse.Mode = 0;
        //mouse.SelectNextMode();
      }


I just made sure if there is no active inventory item to skip that cursor.

Thanks :)
#618
I have my right-click mouse button set to cycle through my cursors in "on_mouse_click":
Code: ags
  
    if (button == eMouseRight)
    {
        mouse.SelectNextMode();
    }


Right now, when I right-click to cycle, this is how the cursor order is cycled (# on the left is the mouse ID):

Current sequence:

0-Walk
1-Look
2-Interact
3-Question
4-Use Inv
5-Command
6-Run

However, I would rather have the run cursor come right after the "walk" cursor and the "use inventory" cursor as the last option as I cycle with the right-click.

Ive searched the manual and it seems IIANM the mouse ID cannot be changed...so how would I "reorder" the sequence so that I get the new result when I cycle through cursors with the right-mouse button?

New sequence:
0-Walk
6-Run
1-Look
2-Interact
3-Question
5-Command
4-Use Inv


#619
hehhe exactly! ;D
#620
I really hope this will make it to the next release...makes its easier to sort and organizing things!

Any possibility we can see sub-folders for most things in 3.2 (inventory items, gui's, dialogs, everything!)?

:)
SMF spam blocked by CleanTalk