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 - iamlowlikeyou

#21
I just tried it myself in an empty game, and here it works perfectly too.
*Sigh* I guess this is where the endless hunt for the bug begins...

UPDATE:
Finally for some reason beyond my knowledge I ended up taking the code into the same function that actually made the GUI visible, and then it worked flawlessly. Why I cannot say...
Of course this is a little inelegant, but it works.
#22
The GUI has no background, only background color and then some buttons.
I tried re-importing the room background, though I set the game to 32 bit color from the start (and should a room background have any effect on GUIs?), but it still makes the same error.

The fade-in code isn't supposed to be at any specific place in the script, right?
#23
It's in the main script...

It's being called from a key press (but that's not important I guess, since it's the function itself that's acting weird).
#24
Okay, so I tried to make it like this just to be absolutely sure;
Code: ags

void SetTransparency(){
    gIconbar.Transparency = 100;
    Wait(10);
    gIconbar.Transparency = 80;
    Wait(10);
    gIconbar.Transparency = 70;
    Wait(10);
    gIconbar.Transparency = 60;
    Wait(10);
    gIconbar.Transparency = 50;
    Wait(10);
    gIconbar.Transparency = 40;
    Wait(10);
    gIconbar.Transparency = 30;
    Wait(10);
    gIconbar.Transparency = 20;
    Wait(10);
    gIconbar.Transparency = 10;
    Wait(10);
    gIconbar.Transparency = 0;
  }


Still it just waits 2-3 seconds (the 100 gameloops) in which the GUI is invisible, and then it becomes Transparency = 0 at once.
It looks to me like it's not a scripting error since the "not visible/visible function" IS working, only all the inbetween-steps are not shown. But since my game is set to 32 bit color, I can't figure out what could cause this error?

EDIT: I just discovered that if I just put:
Code: ags

void SetTransparency(){
    gIconbar.Transparency = 50;
}

...it sets the transparency to 50 like it's supposed to, but as soon as I put:
Code: ags

void SetTransparency(){
    gIconbar.Transparency = 50;
    Wait(10);
    gIconbar.Transparency = 20;
}

...it simply waits for the 10 gameloops and then sets transparency to 20 at once. So it somehow seems to be the Wait command that makes some kind of glitch in my script?
#25
Quote from: Ultra Magnus on Fri 21/01/2011 12:56:10
What do you have the while game is paused, GUIs should... setting as? Try setting it to display as normal.

If you mean "when player interface is disabled, GUIs should", then it's already set to normal.

Anyway, should I put the fade-in code in any specific section of the script, or should it work anywhere?
#26
Quote from: Gilbet V7000a on Fri 21/01/2011 12:42:41
What colour depth is your game at?
My game is at 32 bit, so that shouldn't be the problem...

Quote from: Matti on Fri 21/01/2011 12:44:33
A while loop like this one:

Code: ags

    while (trans > 0) {
      trans--;
      gIconbar.Transparency = trans;
      Wait(1);
    }


..will stop all code from being executed until its finished. The transparency decreases until it reaches 0 and then the code finally has a chance to even show that change. It needs a moment due to the 100 wait commands.  You'd need an if instead of while.

Thanks, I'll try with an "if".
But why does it say "while" in the manual then ???

EDIT: When I change it to "if" it simply doesn't work - that is it just stays invisible...
#27
I'm using this code to fade in my GUI:
Code: ags

void SetTransparency(){
    gIconbar.Transparency = 100;
    int trans = gIconbar.Transparency;
    while (trans > 0) {
      trans--;
      gIconbar.Transparency = trans;
      Wait(1);
    }
  }


SetTransparency() is initiated when pressing the key that makes the GUI visible.
When I run the game and tries it out, the GUI remains "invisible", that is transparency =100 for some 5 seconds, and then become visible (trans = 0) all of a sudden...
Any ideas why this isn't working?
#28
To be honest I can't get my head around this right now.
I'll try to read it again tomorror, and perhaps I'll understand it then...
#29
I'm still a newbie in scripting, so bear with me on this :)

I used mouse.SetPosition at first, but then the player would be able to move the mouse away from the button again. So I used the mouse.SetBound to "lock" the mouse to the buttons.

How does Button* work? I mean basically, because I have no idea what the * means.

Quote from: monkey_05_06 on Thu 20/01/2011 17:44:38
Also, how are you handling processing the clicks on the GUIs/GUIControls? There's no way to generically simulate it, so I guess you're probably just calling the click event handlers manually?  

I haven't gotten to the actual clicks yet, but I figured there must be a way to do something like "on key press push the button which mouse is over"?
Well, it's probably easier to just use the bools here also... (or the button*, when I understand that ;))
#30
Ah, I see. Thank you!

Quote from: Khris on Thu 20/01/2011 17:19:41
You don't need to initialize them as false btw, bools are false by default.

Yeah, I actually thought so too, but I wrote it in to be absolutely sure ;)

Is there a more elegant way to make the mouse point on the buttons, or would you say this is an alright method?
#31
Didn't see the last comments until now...

@Khris: Well, this is for the same interface you already helped me so much with, so the game is keyboard controlled. And at least to begin with I'll keep it like that...
What I want is just a simple popup GUI in top of screen (like the one in the default game, except this one should become visible at key press and not mouse move to top of screen).
Then I suppose it should be made with buttons containing normal graphics and mouse-over graphics.
A default button is highlighted (that is set to mouse-over graphic) when the GUI becomes visible, and then by pressing left- or right-key player can switch between the buttons.
The buttons should probably just be "save", "load" and "quit" I think.

Save and load both opens a new GUI, controlled in the same way - except switching up and down instead of left and right, and then player just custom name the savegames like standard (this is basically a standard adventure game story-wise, so it makes more sense to name the savegames instead of automatically naming them time and date).
Quit just opens a "yes" or "no" GUI.

And that's it.
BTW I want my Inventory window to be the same way, just in the bottom of the screen...

----------

EDIT:

I came up with this code trying to make at least the switches available (the mouse.SetBounds values are the button areas - perhaps the method is a little (or very) clumsy, but it was the best I could come up with at the moment)... I put it in the function on_key_press(eKeyCode keycode) section of the globalscript.

Code: ags

  bool SaveGameButtonActive = false;
  bool LoadGameButtonActive = false;
  bool QuitGameButtonActive = false;
  
  if (keycode == eKeyEscape){
    if (gIconbar.Visible == false){
      gIconbar.Visible = true;
      PauseGame();
      mouse.SetBounds(200, 10, 210, 20);
      SaveGameButtonActive = true;
    }
    else if (gIconbar.Visible == true){
      gIconbar.Visible = false;
      UnPauseGame();
    }
  }
  
  if (keycode == eKeyLeftArrow){
    if (SaveGameButtonActive == true){
      mouse.SetBounds(260, 10, 270, 20);
      SaveGameButtonActive = false;
      QuitGameButtonActive = true;
      }
      else if (LoadGameButtonActive == true){
        mouse.SetBounds(200, 10, 210, 20);
        LoadGameButtonActive = false;
        SaveGameButtonActive = true;
      }
      else if (QuitGameButtonActive == true){
        mouse.SetBounds(230, 10, 250, 20);
        QuitGameButtonActive = false;
        LoadGameButtonActive = true;
      }
      else {}
  }
  if (keycode == eKeyRightArrow){
    if (SaveGameButtonActive == true){
      mouse.SetBounds(230, 10, 250, 20);
      SaveGameButtonActive = false;
      LoadGameButtonActive = true;
    }
    else if (LoadGameButtonActive == true){
      mouse.SetBounds(260, 10, 270, 20);
      LoadGameButtonActive = false;
      QuitGameButtonActive = true;
    }
    else if (QuitGameButtonActive == true){
      mouse.SetBounds(200, 10, 210, 20);
      QuitGameButtonActive = false;
      SaveGameButtonActive = true;
    }
    else {}
  }


It doesn't work however. I can't figure out why...
It doesn't respond to arrow key press at all. I don't know if I'm using the bools correctly?
#32
Thanks!
Sorry, I didn't think keyboard control of gui was in the manual :S

I'll check it, and remember to check next time before posting.
#33
I am working on a game that has only keyboard control, no mouse at all.

I need a control panel for save/load/exit functions, and an inventory window.
I want to make them as "popups" that are made visible by press key.
So far so good...

Now I'm in search of ideas for how to make them controllable.
Basically both controls have to be a line of icons that appear at the edge of the screen, and then switched between by the cursor keys.

I am thinking that the control panel could be done with 6 images, one for each control selected and unselected, and then it could be written as "if this selected and cursor left, then deselect and select that"... I don't know if that's a "clumsy" method - perhaps there's a most much more elegant way to do it?
Anyway my greatest problem is how to do the inventory, because the icons in the inventory will not be arranged the same way every time in the nature of an inventory... But of course there is a way, I just haven't thought of it yet :)
#34
Ah, thanks for the explanation.

Anyway, my room IS scrolling and IS lowres, so it's a good thing you included the GetViewport element then...

Well, perhaps I should try again with your interface... The thing is I feel a little bad using code that I don't understand, but I guess I'll just have to bite the apple.
I'm really terrible at understanding logics, but I'm working hard on it, because I want to be able to do my own programming.
#35
I am putting this in the room script, so it's working :)
#36
Thanks again!
Yeah I'm sorry I never got back to you - I've been trying to figure it out very hard, but I'm simply not skilled enough yet to fully understand it. Which is why I've started studying general basic programming lately :)

In the meantime I've been trying to decide which interface is best; the one you wrote for me, or one where interaction becomes possible whenever on a hotspot, and then interaction makes player walk to position before interacting. The result will be almost the same, but maybe the latter is a little more user-friendly - and a LOT easier for me to work with.

If you have the time, can you try to explain the code you just provided?
I don't really understand what GetViewport does even though I have read the description...
Also what does the "Hotspot*h" mean? and the ID?

EDIT: Well, I think I understand what GetViewport does, but I don't understand why it's in this code... What would happen it was just "player.x, player.y"?
#37
I'm not sure if the headline makes any sense :)

What I want to do:
Press a key --> execute mouse.Mode on the hotspot which player is standing on...
#38
Okay, so is it reasonable to say:
Code: ags

function repeatedly_execute_always(){  
  
  if (Hotspot.GetAtScreenXY(player.x, player.y) == hHotspot1){
    Label1.Text = "on hotspot";
  }
  
  else Label1.Text = "not on hotspot";
  
}


...I mean is this a problematic statement in any way?
#39
Is there a way to check (supposedly as "function repeatedly_execute_always") if the player is standing on a specific hotspot?
I don't want to do it with regions, because I can max. make 15 regions per room...
#40
All right, well perhaps Calin would like to share in this thread with me and all interested how He did it? :D

By the way I started yesterday with the Eclipse Java for total beginner's course, and I'm already in over my head with the 2nd video... I see that the structure is somewhat similar to the AGS scripting, so I think I will benefit from it - I guess I'll just to have to go over each video some 5 times or so :)
SMF spam blocked by CleanTalk