Hi Im new to using Ags.
But already Ive had a problem ???
I plan to have a Sam and Max style Inventory system. Ive drawn the pic and I was testing it out and I found that when i had it up I couldnt right click to scroll through the cursor options.
Its probably not tooo important but im a bit of a perfectionist.
So if anyone has had the same prob or knows how to fix it I would be much obliged.
Cheer. ;D
I have the same problem... when my cursor is over the GUI, I can not change the cursor with the right mouse button.
Any help would be appreciated! :D
Maybe this manual excerpt will help:
Handle inventory clicks in script - normally, if the player clicks on an inventory item, it is processed internally by AGS. However, if you enable this option, then clicking an inventory item will call your on_mouse_click function with LEFTINV or RIGHTINV, and you then need to process it yourself. You can use the game.inv_activated variable to find out what they clicked on.
NOTE: this only works with custom Inventory GUI controls
Well, that works when overlapping the items themselves only, but the rest of the GUI still doesn't recognize right-clicks.
There was a script for that somewhere... Probably buried under the dozens and dozend of new theads in either here of the Tech Forum....
maybe the gui is in popup mode, and then when the gui is on, the game is paused, and then, if there is something like ' if (IsGamePaused() == 1){} ' in the on_mouse_click function, clicks arent registered?
just having a guess... ::)
EDIT: oh, but then left clicks shouldnt be registered also, and they are... :-\
Any click on a GUI doesn't trigger on_mouse_click() function (unless it's not clickable) - that's the problem. Handle inventory clicks in script, as Bernhard said, works only for inventory window itself and not for the rest of GUI. Dorcan wrote a solution. It was here: http://host.deluxnetwork.com/~dorcan/script.php?id=1&page=1&langue=en (http://host.deluxnetwork.com/~dorcan/script.php?id=1&page=1&langue=en)... but the link doesn't seem to work now.
Another solution is to handle the right click inside the repeatedly_execute():
int rbutton_pressed = 0;
function repeatedly_execute() {
if (IsButtonDown(RIGHT)) {
if (rbutton_pressed == 0) {
SetNextCursorMode();
rbutton_pressed = 1;
}
}
else rbutton_pressed = 0;
}
The rbutton_pressed is needed to avoid repeatedly cycling when you hold the right button.
Also don't forget to remove the SetNextCursorMode(); line inside on_mouse_click() or you'll jump over the two cursor modes instead.
~Cheers
This works great, thanks! Now my interface is complete, heh. :D
I have a small problem with this code... if you click away a text with the right mouse key, it'll switch to the next icon. I need to find a way to lock changing cursors for a bit when the game is unpaused again.
Sweet thanks for that!
That was anoyying me a bit, im sur now i can fix it
Cheers ;D
QuoteI have a small problem with this code... if you click away a text with the right mouse key, it'll switch to the next icon. I need to find a way to lock changing cursors for a bit when the game is unpaused again.
To do this, you'll need to create a custom display function:
function DisplayEx (string message) {}
// This function does not support the extra parameter, since I have no idea on how to pass it on as optional...
// but: First, display the message passed as parameter as usual
Display(message);
// then, set GlobalInt 79 to 1 for a few game loops
SetGlobalInt(79,1);
SetTimer(20,10); // set timer 20 to run for 10 game loops, which is usually 1/4 of a second.
while (IsTimerExpired(20) == 0) {
// Do nothing...
}
SetGlobalInt(79,0); // set the GlobalInt back to 0
}
and you need to modify the mouse click handling script:
int rbutton_pressed = 0;
function repeatedly_execute() {
if (IsButtonDown(RIGHT)) {
if (rbutton_pressed == 0) {
if (GetGlobalInt(79) == 0) SetNextCursorMode(); // do this change so the cursor mode will only be toggled if GI 79 is 0, which is not true in the following 10 game loops of a display with DisplayEx
rbutton_pressed = 1;
}
}
else rbutton_pressed = 0;
}
;)
I tried adding the code, but it didn't change anything. I played with it a bit, but the function doesn't seem to do anything at all. -_-
Well, TK, there're a problm with your codes:
the
while (IsTimerExpired(20) == 0) {
// Do nothing...
}
part would be an endless loop, you MUST put a Wait() statement inside it instead of "doing nothing", and if you use waiting, you don't need a timer anyway.
So, try TK's codes, but replace the
SetTimer(20,10); // set timer 20 to run for 10 game loops, which is usually 1/4 of a second.
while (IsTimerExpired(20) == 0) {
// Do nothing...
}
part with
Wait(10);
I never checked, so I can't gaurantee it would work.
Well, I theorized (sp? in case makes sense), thinking that the engine would check the timer once in every game loop... well I guess I was wrong.
Yes the engine will update the timer once in each game loop. However, in a while loop, it won't advance a game loop unless you tell it to, so the while loop will just run within the same game loop, so the timer would probably never got updated within it.
Oh, dammit......
Well, The problem is that the displayex function itself doesn't do anything... i tried to only set a globalint to 1 under it but it didn't even do that.
I had the same problem when making flashbax.
I can`t remeber exactly what i did but i think its something like this:
Set the interface to clickable:
then add to start...
int rbutton_pressed = 0;
then in the repeatedly.
f ((IsButtonDown(RIGHT)==0) && (rbutton_pressed == 1)){rbutton_pressed = 0;}
if (IsGamePaused()==0){
if (IsButtonDown(RIGHT)==1){
if (rbutton_pressed == 0) {
SetNextCursorMode();
rbutton_pressed = 1; }
thats it think......
You dont need to mess around with timers i did`nt.
hope this helps
No, doesn't work either... thanks though! :3
I'll just deactivate skipping text with mouse (keyboard only) for the time being until I find a fix for this.