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

#481
Sorry if I replying in an old thread but I would also REALLY like the limits removed completly for gui controls...

In the meantime I can use multiple gui's buts its a pain in the azz!
#482
Hey Joseph!

This is the first time I actually feel I can answer a question, unless someone has a better solution :P
Code: ags

int iLMclick; //put that at the top of your global script

//Put this in your rep_exec:
        overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
        if (mouse.IsButtonDown(eMouseLeft) && overGuiControl == yourButtonName)
        {
          while (mouse.IsButtonDown(eMouseLeft))
          {     
            textboxName.Text = String.Format("%d", iLMclick);
            Wait(1);
            iLMclick = (iLMclick + 1);
           }
          lblHotspot.Text = "0";
          iLMclick = 0;
        }


I tested in my game and it works!
#483
Awesome! Thank-you kind sir  :D
#484
Nice, I got it to work! Here is what I did:
Code: ags

void lstRadioCode_OnSelectionChange(GUIControl *control)
{
  //copy the contents of that selection to the radio LCD area
  clearTXT(txtRadio_CodeInput); //first clear whats in the LCD
  String selectedItemText = lstRadioCode.Items[lstRadioCode.SelectedIndex];
  txtRadio_CodeInput.Text = selectedItemText;
  bReady = true;
  //Display("Selection changed...");
}

function repeatedly_execute() 
{
  overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  if (overGuiControl == lstRadioCode)
  {
    if (iExecuteDC == 1) //this is set from doubleClick command
    {
      if (bReady == true)
      {
        //Display("Send message");
        btnRadio_Send_OnClick(btnRadio_Send, eMouseLeft);
        iExecuteDC = false;
        bReady = false;
        return;
      }
    }
  }
}



Thanks for your help!
#485
Ok, so if I change the value of bReady in repeatedly_execute_always, then the while loop can continue...

Does stuff in the "on_event" get processed before "lstRadioCode_OnSelectionChange"? If so, how in the crap can I get "bReady" to be true so that when I get to the on_event part, it can finally exit that while loop?

Man Im all mixed up on this one..arrrrg
#486
Ok well thats almost like Khris's 2nd suggestion (grouping all emotions together by type)...so Id have to group my character's face anims by emotion instead of by char name, which is not a big deal....ok, Ill try that!

Too bad there wasnt a function "convertReturnToString" or something :P

**Im checkin the StringPlus module now to see if I can get more options!
#487
Im trying to get a "while" function to work, but Im missing something...

I have a list (lstRadioCode) and when the selection is changed in that list, the text in the radio's screen display gets updated with the text from the list...when this text is updated, I can then press a button "push to talk" and it will send the text that is in the radio's screen display to the dispatcher.

All works well except I added a doubleClick function...if the selection in the list is doubleClicked on, it will read what text is in the radio's screen display (txtRadio_CodeInput) and call the "push to talk" function. There is a delay in updating the text from the list to text box, so I decided to put a "while" in the script cause I want to make sure the text box gets the new text from the list before executing the "push to talk".

Here is what I tried, but at the "while" part, it just keeps on waiting, never exiting the loop...but I set the bool "Ready" to true AFTER the textbox gets updated:

Code: ags

void doubleClick(eDoubleClickSpeed eSpeed)
{
  ViewFrame *frame0 = Game.GetViewFrame(VWAIT_FAKE, 0, 0);
  if (frame0.Graphic != 2061) frame0.Graphic = 2061;
  mouse.ChangeModeView(eModeWait, 54); //fake "Pointer-Wait" view...(waitMouseKey shows Wait View)
  mouse.ChangeModeGraphic(eModeWait, 2061);
  
  int iDoubleClick;
  int dc;
  if (eSpeed == eSlowClick) dc = 15;
  else if (eSpeed == eMediumClick) dc = 12;
  else if (eSpeed == eFastClick) dc = 9;
  
  iDoubleClick = (WaitMouseKey(dc) * mouse.IsButtonDown(eMouseLeft));
  if (iDoubleClick)
  {
    //Display("Double click!");
    iExecuteDC = 1;
    mouse.ChangeModeView(eModeWait, 14); //restore Default Wait view
    mouse.ChangeModeGraphic(eModeWait, 297);
  }
  else iExecuteDC = 0;
}

void lstRadioCode_OnSelectionChange(GUIControl *control)
{
  bReady = false;
  clearTXT(txtRadio_CodeInput);
  String selectedItemText = lstRadioCode.Items[lstRadioCode.SelectedIndex];
  txtRadio_CodeInput.Text = selectedItemText;
  bReady = true;
}

void on_event (EventType event, int data)
{
  overGuiControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  if (event == eEventGUIMouseDown && (overGuiControl == lstRadioCode))
  {
    doubleClick(eMediumClick);
    if (iExecuteDC == 1)
    {
      if (gRadio.Visible)
      {
        while (bReady != true) fakeWaitCursor(1, 2091);
        Display("Ready!");
        //btnRadio_Send_OnClick(btnRadio_Send, eMouseLeft);
      }
    }
  } 
}


I dont quite understand why this isnt working!
#488
Ok, I was just playing around with stuff and I was wondering what you guys thought of it...is it too complicateed for nothing? I kind of tried to do my "convert enum to string" manually...

*ps: I left out other emotions so its not so long in this post

Code: ags


void SetFa(this Character*, eFaceAnim eFa)
{
  this.SaveSettings_ToVariables("Backup", eiF);
  this.SetFaceAnim(eFa);  
}

void setStringTo(String sThisString)
{
  sAsString = sThisString;
}

void SetUpFaceAnims_AsStrings()
{
  //setup converting manually character enum to strings
  //BRIAN
  if (currentFa == eFa_BrianYng_eNeutral) setStringTo("Yng_eNeu");
  else if (currentFa == eFa_BrianYng_eMad) setStringTo("Yng_eMad");
  else if (currentFa == eFa_BrianYng_eSad) setStringTo("Yng_eSad");
  else if (currentFa == eFa_BrianYng_eHappy) setStringTo("Yng_eHap");
  else if (currentFa == eFa_BrianRSh_eNeutral) setStringTo("RSh_eNeu");
  else if (currentFa == eFa_BrianRSh_eMad) setStringTo("RSh_eMad");
  else if (currentFa == eFa_BrianRSh_eSad) setStringTo("RSh_eSad");
  else if (currentFa == eFa_BrianRSh_eHappy) setStringTo("RSh_eHap"); 
  //else if...add more versions of Brian here...
  
}

function ChangeEmotion(this Character*, eEmotions eEmotionType)
{
  currentFa = this.GetFaceAnim();
  SetUpFaceAnims_AsStrings();
  if (sAsString != null)
  {
    if (eEmotionType == eSad)
    { 
      //Display("Set Emotion: Sad");
      if (!(sAsString.EndsWith("_eSad", true))) // NOT one of the sad anims
      {
        //BRIAN
        if (sAsString.StartsWith("Yng_", true)) this.SetFa(eFa_BrianYng_eSad);
        else if (sAsString.StartsWith("RSh_", true)) this.SetFa(eFa_BrianRSh_eSad);
        else if (sAsString.StartsWith("RSt_", true)) this.SetFa(eFa_BrianRSt_eSad);
        else if (sAsString.StartsWith("Mid_", true)) this.SetFa(eFa_BrianMid_eSad);
        else if (sAsString.StartsWith("Old_", true)) this.SetFa(eFa_BrianOld_eSad);
        
        //Other Characters here       
      }
      //else if...other emotions here
    } 
}


Im not sure if its more complicated to do this way or just do it the way Khris suggested (1st suggestion).

Ill check out parallel arrays too (wikipedia for sure), GarageGothic...never used that before!

Also...is there a possibility of creating a plugin or expanding your StringPLus module, Monkey...so AGS can "see" variable/enum returns as a string that can be used with string functions? That way I wouldnt need to convert those enums manually to strings...
#489
Thanks Calin, Ill try that module out!
#490
I know this is an older thread, but I was interesting in this module and the link seems to be broken...does anyone have a copy of this? It doesnt seem available on american girl scouts either :P...DOH!
#491
It would be great to have some sort of "tokenize" for strings (taken from Mel scripting):

QuoteThis command will split the first string argument up according to split characters provided in the optional second argument. If this argument is not provided, tokenize will use a default split string consisting of whitespace characters. The input string is scanned for substrings (tokens) which are separated by any of the split characters. Note: tokenize does not match the entire split string; it matches any character in the string. The resulting token strings are put into the third argument which is a string array. The return value of this procedure is the number of tokens into which the original string is divided.

Code: ags

MEL examples
string $buffer[];
$numTokens = `tokenize "A/B//C/D" "//" $buffer`;

// Buffer will contain 4 strings, not 2: "A", "B", "C", "D"
// and $numTokens will be 4.

string $buffer[];
$numTokens = tokenize("Mildred Pierce Femme Fatale", $buffer);

// Buffer will contain 4 strings: "Mildred", "Pierce", "Femme", and "Fatale."
// and $numTokens will be 4.

string $buffer[];
$numTokens = `tokenize "testing=non-default separators" "=" $buffer`;

// Buffer will contain 2 strings: "testing" and "non-default separators."
// and $numTokens will be 2.

#492
Well the main reason why I tend to "think" the way I do about variables, strings, etc...is due to the fact I use maya's mel script often, and its permitted to use variables + strings in that way...its kinda hard to unlearn since its so automatic for me!

...slowly but surely it will get pounded into my brain!!

Some of Mel script string functions:  ;D

Holy crap it would be great to have some of these in AGS (the ones we dont already have, that is)...especially "tokenize"!!
#493
Ah crap I thought so...I believe I had a simliar question but I was hoping this was different!

I currently have done your first suggestion but was hoping to save space with indexOf...Ive got quite a bit of varieties so it will be quite long!
Ill see if your 2nd suggestion gives me less work :P
thanks :)

QuoteThat way you can e.g. use 10 to 19 for all those containing Sad, then check if (currentFa/10 == 1).
ok so (for example) 19/10 will get truncated to an int (not float), so it will return 1, right? Interesting...
#494
Hi,

Im pretty sure this will be answered fairly easily, but how do I convert an enum to a string so I can use "IndexOf" on it?
I tried to simply place a return inside a string variable, but this doesnt work:

 
Code: ags
 
  eFaceAnim currentFa = this.GetFaceAnim();
  Character* cChar = this;
  
  //if faceAnim is already the same as the change... dont save the backup
  //is the word eSad contained inside the string currentFa?
  
  String sCurrFa = return currentFa;
  int iResult = sCurrFa.IndexOf("Sad");
  Display("%d", iResult);
  
#495
Perfect, thanks for all your help Khris!
#496
Wow, same here! I like the mood of those pics...makes me want to play it!
#497
Ok so I made a button the same size as the portrait gui (btn_BlinkView). I got the blinkview now drawn onto it, the only thing is, the blink frame stays drawn on the button "forever"...doesnt get "cleared" so we dont see the blink turn off. This is what I got so far (from your suggestion):

Code: ags

function Portrait_DoFrame() 
{
  Portrait_vf = Game.GetViewFrame(Portrait_View, Portrait_Loop, Portrait_Frame);
  bool flip = Portrait_vf.Flipped;
  // Something like:
  if (Portrait_AutoFlip && Portrait_AtRight) flip =! flip;
  Portrait_Mod = DynamicSprite.CreateFromExistingSprite(Portrait_vf.Graphic, true);

  // Flip AFTER blink, if required
  if (flip) Portrait_Mod.Flip(eFlipLeftToRight);
  Portrait_GUI.BackgroundGraphic = Portrait_Mod.Graphic;
}

function Portrait_DoBlinkFrame() 
{
  Portrait_bvf = Game.GetViewFrame(Portrait_BlinkView, Portrait_BlinkLoop, Portrait_BlinkFrame);
  bool flip = Portrait_bvf.Flipped;
  // Something like:
  if (Portrait_AutoFlip && Portrait_AtRight) flip =! flip;

  // Flip AFTER blink, if required
  if (flip) Portrait_bMod.Flip(eFlipLeftToRight);
  btn_BlinkView.NormalGraphic = Portrait_bvf.Graphic;
}
  
function repeatedly_execute_always() 
{
  if (Portrait_Counter == 0) 
  {
    Portrait_Frame++;
    if (Portrait_Frame == Game.GetFrameCountForLoop(Portrait_View, Portrait_Loop)) Portrait_Frame = 0;
    Portrait_DoFrame();
    Portrait_Counter = (Portrait_AnimSpeed + Portrait_vf.Speed + 1);
  } 
  else if (Portrait_Counter >= 0) Portrait_Counter--;

  if (Portrait_BlinkTimer == 0) 
  {
    Portrait_BlinkFrame++;
    if (Portrait_BlinkFrame == Game.GetFrameCountForLoop(Portrait_BlinkView, Portrait_BlinkLoop)) Portrait_BlinkFrame = 0;
    Portrait_DoBlinkFrame();
    Portrait_BlinkTimer = (Portrait_AnimSpeed + Portrait_bvf.Speed + 1);
  } 
  else if (Portrait_BlinkTimer >= 0) Portrait_BlinkTimer--;
}

#498
Hmm, creative idea. Ok Ill try that tonight to see what I can do...if I fail miserably Ill post about how much I suck tomorrow morning! :)
#499
crap I retested with the added code and 1 frame with a delay of 120 (to debug) and it doesnt take into account that delay.

So, crap...sorry, actually it doesnt fix the prob!  :-[
#500
Hey Khris!

Ok, well I tried that and it works, but partially (but I most prob did something wrong somewhere).

It now seems to take into account the delays, but it also seems to "reset" the loop after a few frames only  depending on what the character says...it seems that the full loop doesnt have time to display itself fully...so instead of getting 14 frames of animation in loop 0, it seems only the first few frames get animated. They have delays of 40 frames each, approx.

Does it have something to do with modifying these lines in the function GSay to get it to work (Portrait_BlinkTimer here should contain the .Speed too?)
Code: ags

  if (this.BlinkView > 0) 
  {
    Portrait_BlinkTimer = this.BlinkInterval;
    Portrait_BlinkInterval = this.BlinkInterval;   
    Portrait_BlinkView = this.BlinkView;
    Portrait_BlinkLoop = 0;
    Portrait_BlinkFrame = 0;
  }
  else Portrait_BlinkTimer = -1;



Quoteanimation has reached its last frame, which is frame 1 of a total of 2, I guess the module assumes.

--can we add a script where it wont assume 2 frames, but gets the real number of frames the blink loop actually contains?
SMF spam blocked by CleanTalk