I try to use SetCursorMode(6); to set the cursor mode 6 but it stays at 0!
EDIT: I was probably so angry I forgot about elling you guys what I was tying to do!
What I was trying to do:
For some GUIs I want it to be the pointer cursor but for some strange reason it was the walk cursor. That is all I can say, unless you want the script or the GUIs I want to have the pointer icon on:
This script may be familiar to some of you:
CentreGUI(3);
Ã, if (interface == 3){
Ã, Ã, if (button == 8) SetGameSpeed(GetSliderValue(3,8));
Ã, Ã, else if (button == 9) SetMusicMasterVolume(GetSliderValue(3,9));
Ã, Ã, else if (button == 10) game.text_speed = GetSliderValue(3,10);
Ã, Ã, else {
Ã, Ã, if (button == 0) SaveGameDialog();
Ã, Ã, if (button == 1) RestoreGameDialog();
Ã, Ã, if (button == 2) GUIOn(4);
Ã, Ã, if (button == 3){
Ã, Ã, Ã, SetCursorMode(6);
Ã, Ã, Ã, RestartGame();
Ã, Ã, Ã, }
Ã, Ã, if (button == 4)
Ã, Ã, Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
Ã, Ã, }
Ã, if (button == 11){
Ã, Ã, InterfaceOff (3);
Ã, Ã, InterfaceOn (ICONBAR);
Ã, Ã, SetCursorMode (1);
Ã, Ã, }
Ã, }
The other GUI:
if (interface == 4)
Ã, SetCursorMode(6);
Ã, SetMouseCursor(6);
Ã, DisableCursorMode(0);
Ã, DisableCursorMode(1);
Ã, DisableCursorMode(2);
Ã, DisableCursorMode(3);
Ã, DisableCursorMode(5);
Ã, {
Ã, if (button == 0)
Ã, QuitGame(0);
Ã, else if (button == 1)
Ã, GUIOff(4);
Ã, EnableCursorMode(0);
Ã, EnableCursorMode(1);
Ã, EnableCursorMode(2);
Ã, EnableCursorMode(3);
Ã, EnableCursorMode(5);
Ã, SetCursorMode(0);
Ã, }
[post now irrelevant]
Hey, just to let you know, I modified my the first post of this topic!
Your code is currently in "interface_click" - which means it is only run when the GUI is actually clicked on.
You want to put that code in the repeatedly_execute. And I modified it here so it will work:
if (GetGUIAt(mouse.x,mouse.y) == 4) SetMouseCursor(6);
else SetDefaultCursor();
Put that in the repeatedly_execute.
And remove the following lines from the interface_click:
SetCursorMode(6);
SetMouseCursor(6);
DisableCursorMode(0);
DisableCursorMode(1);
DisableCursorMode(2);
DisableCursorMode(3);
DisableCursorMode(5);
Those lines above are messing up your brackets.
I'm not an expert on this either, but I'm pretty sure it should work.
I don't get it, how is it in interface_click?
Parse error: unexpected "if"
The parse error: Check that the line above it ends in a semicolon.
As far as why it was in interface_click, AGS automatically puts it there when you go to edit your gui code.
It ends in a semicolon but it mentioned "if"
Post the code.
if (GetGUIAt(mouse.x,mouse.y) == 4) SetMouseCursor(6);
else SetDefaultCursor();
else if (GetGUIAt(mouse.x,mouse.y) ==3) SetMouseCursor(6);
else SetDefaultCursor();
Change that code to:
if (GetGUIAt(mouse.x,mouse.y) == 4) SetMouseCursor(6);
else if (GetGUIAt(mouse.x,mouse.y) ==3) SetMouseCursor(6);
else SetDefaultCursor();
If you still get the error, post the code before and after the "if" statement as well.
I still get the error...
Quote from: JaysSite on Fri 27/08/2004 22:10:30
Change that code to:
if (GetGUIAt(mouse.x,mouse.y) == 4) SetMouseCursor(6);
else if (GetGUIAt(mouse.x,mouse.y) ==3) SetMouseCursor(6);
else SetDefaultCursor();
[partidontget]If you still get the error, post the code before and after the "if" statement as well.[/partidontget]
I don't get it...
There is a text scripting tutorial in the AGS help file. It's dated, but maybe it'll give you a few tips. I've spotted a few easy mistakes that you made, and it'll probably frustrate you if you have to keep coming back to the forum.
Anyway, post your entire repeatedly_execute so I can see why you're getting the error.
the reason he got that error was because he had and If statement, and if that wasn't satisfied it was doing 2 else statements and an else if. Which is stupid
function repeatedly_execute() {
Ã, // LEC Statusline
string bunky;string texty; int cursy;
StrCopy (texty, "");Ã, cursy=GetCursorMode();Ã,Â
if (cursy==0){Ã, Ã, StrCat(texty,"Walk to ");}Ã,Â
else if (cursy==1) {Ã, Ã, StrCat (texty,"Look at ");}Ã,Â
else if (cursy==2) {Ã, Ã, StrCat(texty,"Use ");}Ã,Â
else if (cursy==3) {Ã, Ã, StrCat(texty,"Talk to ");}Ã,Â
else if (cursy==4) {Ã, Ã, StrCat(texty,"Use ");Ã, Ã,Â
GetInvName (player.activeinv, bunky);Ã, Ã,Â
StrCat(texty,bunky);Ã, Ã, StrCat(texty," with ");}Ã,Â
else if (cursy==5) {Ã, Ã, StrCat(texty, "Pick up ");}Ã,Â
else if (cursy==8) {Ã, Ã, StrCat(texty, "Open ");}Ã,Â
GetLocationName(mouse.x,mouse.y,bunky);Ã,Â
StrCat(texty,bunky);Ã,Â
SetLabelText (0,0,texty);
}
if (GetGUIAt(mouse.x,mouse.y) == 4) SetMouseCursor(6);
else if (GetGUIAt(mouse.x,mouse.y) ==3) SetMouseCursor(6);
else SetDefaultCursor();
EDIT: Ok, something is definately wrong cursor 6. In GUIs, Cursor 6 does not work at all!
You have to put the 'if (GetGUIAt(...))' part within the function's body:
function repeatedly_execute() {
// LEC Statusline
string bunky;
string texty;
int cursy;
StrCopy (texty, "");
cursy=GetCursorMode();
if (cursy==0) StrCat(texty,"Walk to ");
else if (cursy==1) StrCat (texty,"Look at ");
else if (cursy==2) StrCat(texty,"Use ");
else if (cursy==3) StrCat(texty,"Talk to ");
else if (cursy==4) {
StrCat(texty,"Use ");
GetInvName (player.activeinv, bunky);
StrCat(texty,bunky);
StrCat(texty," with ");
}
else if (cursy==5) StrCat(texty, "Pick up ");
else if (cursy==8) StrCat(texty, "Open ");
GetLocationName(mouse.x,mouse.y,bunky);
StrCat(texty,bunky);
SetLabelText (0,0,texty);
if (GetGUIAt(mouse.x,mouse.y) == 4) SetMouseCursor(6);
else if (GetGUIAt(mouse.x,mouse.y) ==3) SetMouseCursor(6);
else SetDefaultCursor();
}
Hmm, then it would only change to cursor 6 if your mouse moves over the GUI
In that case put the following code within the repeatedly_execute function:
if (IsGUIOn(3) || IsGUIOn(4)) SetMouseCursor(6);
else SetDefaultCursor();
Let's say I want the label to change to " " (nothing) when GUI 3 and 4 are clicked. How do I do that?
Do you mean a click anywhere over a GUI, or only over GUI buttons?
Oh, wait, sorry i didn't give enough details. I wanted the status bar label to change to " " (nothing) if GUI 3 or 4 were open.
Then make an addition to the previous code:
repeatedly_execute:
if (IsGUIOn(3) || IsGUIOn(4)) {
SetMouseCursor(6);
SetLabelText(STATUSBARGUI_NAME_HERE, LABEL_NUMBER_HERE, " ");
}
else SetDefaultCursor();
Thanks, when I did
if (IsGUIOn(3) || IsGUIOn(4)) {
Ã, Ã, SetLabelText(STATUSBARGUI_NAME_HERE, LABEL_NUMBER_HERE, " ");
Ã, Ã, SetMouseCursor(6);
Ã, Ã,Â
}
else SetDefaultCursor();
there was a parse error on "else". Notice that it is slightly different to your script.
Ok, questions to ask:
I want the status bar to change to "something" when I move over a button on the GUIs. How can I do that?
On the inventory GUI (its a custom GUI), when you click on the select button my cursor changes to the walk icon. What can I do to fix that? I haven't modified any script on the inventory GUI. And...would it help if I showed you the script?
Function show_inventory_window
function show_inventory_window () {
// This demonstrates both types of inventory window - the first part is how to
// show the built-in inventory window, the second part uses the custom one.
// Un-comment one section or the other below.
/*
// ** DEFAULT INVENTORY WINDOW
InventoryScreen();
*/
// ** CUSTOM INVENTORY WINDOW
GUIOn (INVENTORY);
// switch to the Use cursor (to select items with)
SetCursorMode (MODE_USE);
// But, override the appearance to look like the arrow
SetMouseCursor (6);
}
Function interface_click
function interface_click(int interface, int button) {
if (interface == ICONBAR) {
if (button == 4) { // show inventory
show_inventory_window();
}
else if (button == 5) { // game controls
InterfaceOff(1);
SetCursorMode(6);
InterfaceOn(3);
}
else if (button == 6) // save game
SaveGameDialog();
else if (button == 7) // load game
RestoreGameDialog();
else if (button == 8) // quit
GUIOn(4);
else if (button == 9) // about
Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
} // end if interface ICONBAR
if (interface == INVENTORY) {
// They clicked a button on the Inventory GUI
if (button == 1) {
// They pressed SELECT, so switch to the Get cursor
SetCursorMode (MODE_USE);
// But, override the appearance to look like the arrow
SetMouseCursor (6);
}
if (button == 2) {
// They pressed LOOK, so switch to that mode
SetActiveInventory(-1);
SetCursorMode(MODE_LOOK);
}
if (button == 3) {
// They pressed the OK button, close the GUI
GUIOff (INVENTORY);
SetDefaultCursor();
}
if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed)) {
// scroll down
game.top_inv_item = game.top_inv_item + game.items_per_line;
}
if ((button == 5) && (game.top_inv_item > 0)){
// scroll up
game.top_inv_item = game.top_inv_item - game.items_per_line;
}
}
CentreGUI(3);
if (interface == 3){
if (button == 8) SetGameSpeed(GetSliderValue(3,8));
else if (button == 9) SetMusicMasterVolume(GetSliderValue(3,9));
else if (button == 10) game.text_speed = GetSliderValue(3,10);
else {
if (button == 0) SaveGameDialog();
if (button == 1) RestoreGameDialog();
if (button == 2) GUIOn(4);
if (button == 3){
SetCursorMode(6);
RestartGame();
}
if (button == 4)
Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
}
if (button == 11){
InterfaceOff (3);
InterfaceOn (ICONBAR);
SetCursorMode (1);
}
}
if (interface == 4)
SetCursorMode(6);
SetMouseCursor(6);
DisableCursorMode(0);
DisableCursorMode(1);
DisableCursorMode(2);
DisableCursorMode(3);
DisableCursorMode(5);
{
if (button == 0)
QuitGame(0);
else if (button == 1)
GUIOff(4);
EnableCursorMode(0);
EnableCursorMode(1);
EnableCursorMode(2);
EnableCursorMode(3);
EnableCursorMode(5);
SetCursorMode(0);
}
}
Look up status bar in the manual, therse a little section on the variable about hotspots and set label text
Quotethere was a parse error on "else". Notice that it is slightly different to your script.
You have to place the code within the repeatedly_execute function body, not outside of it:
function repeatedly_execute()
{<<<put it here>>>}Also be sure to consult the AGS manual Text scripting tutorial on how functions are declared.
Quotewant the status bar to change to "something" when I move over a button on the GUIs. How can I do that?
Again, inside the
repeatedly execute:if (GetGUIAt(mouse.x, mouse.y) == GUI_NAME_HERE) {
if (GetGUIObjectAt(mouse.x, mouse.y) == BUTTON_NUMBER_HERE) SetLabelText(GUI_NAME_HERE, STATUSBAR_LABEL_NUMBER_HERE, "something");
}
QuoteOn the inventory GUI (its a custom GUI), when you click on the select button my cursor changes to the walk icon. What can I do to fix that?
Depends on what you mean by "fix that". Can you be more specific?
Quote from: Scorpiorus on Sun 05/09/2004 07:49:18
..........QuoteOn the inventory GUI (its a custom GUI), when you click on the select button my cursor changes to the walk icon. What can I do to fix that?
Depends on what you mean by "fix that". Can you be more specific?
On the inventory GUI there is three buttons on the bottom, right? The first one is 'look', second one is 'select' and the third one is 'OK'. When I click on the second one, 'select', it changes to the 'use' cursor but the script overrides it to the 'pointer' cursor. Now, when you click the 'select' button, it switches to the 'walk' cursor, completely ignoring the cursors 'use' and 'pointer'.
QuoteDepends on what you mean by "fix that". Can you be more specific?
"Fix that" means, "I got a problem, ..............(whatever the problem is), what can I do to
fix my problem.
Quote from: Edwinxie on Mon 06/09/2004 01:56:22"Fix that" means, "I got a problem, ..............(whatever the problem is), what can I do to fix my problem.
Yeah, that's all fine, except that you are supposed to replace all these dots with a detailed description of what's wrong and
*in which way* you would like it to behave instead. ;)
Quote from: Edwinxie on Mon 06/09/2004 01:56:22On the inventory GUI there is three buttons on the bottom, right? The first one is 'look', second one is 'select' and the third one is 'OK'. When I click on the second one, 'select', it changes to the 'use' cursor but the script overrides it to the 'pointer' cursor. Now, when you click the 'select' button, it switches to the 'walk' cursor, completely ignoring the cursors 'use' and 'pointer'.
I'm still not quite sure what you mean but looking into the script it seems that interaface 4 is messing things, here is a new version of the whole interface_click():
function interface_click(int interface, int button) {
Ã, Ã, if (interface == ICONBAR)
Ã, Ã, {
Ã, Ã, Ã, Ã, if (button == 4)Ã, Ã, // show inventory
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, show_inventory_window();
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else if (button == 5)Ã, Ã, // game controls
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, InterfaceOff(1);
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(6);
Ã, Ã, Ã, Ã, Ã, Ã, InterfaceOn(3);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else if (button == 6)Ã, Ã, // save game
Ã, Ã, Ã, Ã, Ã, Ã, SaveGameDialog();
Ã, Ã, Ã, Ã, else if (button == 7)Ã, Ã, // load game
Ã, Ã, Ã, Ã, Ã, Ã, RestoreGameDialog();
Ã, Ã, Ã, Ã, else if (button == 8)Ã, Ã, // quit
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(6);
Ã, Ã, Ã, Ã, Ã, Ã, SetMouseCursor(6);
Ã, Ã, Ã, Ã, Ã, Ã, DisableCursorMode(0);
Ã, Ã, Ã, Ã, Ã, Ã, DisableCursorMode(1);
Ã, Ã, Ã, Ã, Ã, Ã, DisableCursorMode(2);
Ã, Ã, Ã, Ã, Ã, Ã, DisableCursorMode(3);
Ã, Ã, Ã, Ã, Ã, Ã, DisableCursorMode(5);
Ã, Ã, Ã, Ã, Ã, Ã, GUIOn(4);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else if (button == 9)Ã, Ã, // about
Ã, Ã, Ã, Ã, Ã, Ã, Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
Ã, Ã, }Ã, // end if interface ICONBAR
Ã, Ã, if (interface == INVENTORY) // They clicked a button on the Inventory GUI
Ã, Ã, {
Ã, Ã, Ã, Ã, if (button == 1)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // They pressed SELECT, so switch to the Get cursor
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode (MODE_USE);
Ã, Ã, Ã, Ã, Ã, Ã, // But, override the appearance to look like the arrow
Ã, Ã, Ã, Ã, Ã, Ã, SetMouseCursor (6);
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, if (button == 2)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // They pressed LOOK, so switch to that mode
Ã, Ã, Ã, Ã, Ã, Ã, SetActiveInventory(-1);
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(MODE_LOOK);Ã,Â
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, if (button == 3)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // They pressed the OK button, close the GUI
Ã, Ã, Ã, Ã, Ã, Ã, GUIOff (INVENTORY);
Ã, Ã, Ã, Ã, Ã, Ã, SetDefaultCursor();
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // scroll down
Ã, Ã, Ã, Ã, Ã, Ã, game.top_inv_item = game.top_inv_item + game.items_per_line;
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, if ((button == 5) && (game.top_inv_item > 0))
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // scroll up
Ã, Ã, Ã, Ã, Ã, Ã, game.top_inv_item = game.top_inv_item - game.items_per_line;
Ã, Ã, Ã, Ã, }
Ã, Ã, }
Ã, Ã, CentreGUI(3);
Ã, Ã, if (interface == 3)
Ã, Ã, {
Ã, Ã, Ã, Ã, if (button ==Ã, 8) SetGameSpeed(GetSliderValue(3,8));
Ã, Ã, Ã, Ã, if (button ==Ã, 9) SetMusicMasterVolume(GetSliderValue(3,9));
Ã, Ã, Ã, Ã, if (button == 10) game.text_speed = GetSliderValue(3,10);
Ã, Ã, Ã, Ã, if (button ==Ã, 0) SaveGameDialog();
Ã, Ã, Ã, Ã, if (button ==Ã, 1) RestoreGameDialog();
Ã, Ã, Ã, Ã, if (button ==Ã, 2) GUIOn(4);
Ã, Ã, Ã, Ã, if (button ==Ã, 3)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(6);
Ã, Ã, Ã, Ã, Ã, Ã, RestartGame();
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, if (button == 4)
Ã, Ã, Ã, Ã, Ã, Ã, Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
Ã, Ã, Ã, Ã, if (button == 11)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, InterfaceOff (3);
Ã, Ã, Ã, Ã, Ã, Ã, InterfaceOn (ICONBAR);
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode (1);
Ã, Ã, Ã, Ã, }
Ã, Ã, }
Ã, Ã, if (interface == 4)
Ã, Ã, {
Ã, Ã, Ã, Ã, if (button == 0)Ã, QuitGame(0);
Ã, Ã, Ã, Ã, if (button == 1) {
Ã, Ã, Ã, Ã, Ã, Ã, GUIOff(4);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(0);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(1);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(2);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(3);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(5);
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(0);
Ã, Ã, Ã, Ã, }
Ã, Ã, }
}
Hope that'll help, otherwise try to be as much specific as possible on what's going on wrong and how you wan t it to be.
That helped a little, but cursor 6 is not shown, just cursor 2. I'll go over the script. If I can't find why I'll modify this post.
EDIT: Yeah, I couldn't find the problem. Do you mind if I post the entire global script?
SPECIFIC PROBLEM: You see, everyone's game has an inventory GUI. The cursor looking button is the select button and that is the problem. When you click it, it was supposed to change to the 'use' cursor but gets its appearance overrided to look like the arrow:
if (button == 1)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, // They pressed SELECT, so switch to the Get cursor
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode (MODE_USE);
Ã, Ã, Ã, Ã, Ã, Ã, // But, override the appearance to look like the arrow
Ã, Ã, Ã, Ã, Ã, Ã, SetMouseCursor (6);
Ã, Ã, Ã, Ã, }
See what I mean? But now it just changes to MODE_USE and not executing SetMouseCursor (6);. Do you see now?
First of all, go to the GUI Editor and see what left click action the arrow button is set to. It has to be Run script rather than Set Cursor Mode.
If it's already set to Run Script then try calling Display from within the related part of the script:
if (button == 1)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, Display("We've just clicked on an arrow button!"):
Ã, Ã, Ã, Ã, Ã, Ã, // They pressed SELECT, so switch to the Get cursor
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode (MODE_USE);
Ã, Ã, Ã, Ã, Ã, Ã, Display("Changed cursor mode to MODE_USE!"):
Ã, Ã, Ã, Ã, Ã, Ã, // But, override the appearance to look like the arrow
Ã, Ã, Ã, Ã, Ã, Ã, SetMouseCursor (6);
Ã, Ã, Ã, Ã, Ã, Ã, Display("Changed cursor appearance to mode 6"):
Ã, Ã, Ã, Ã, }
...and see if messages are actually displayed on clicking the button.
Uh, just be careful with your semicolons.
EDIT: Ok, I figured out the problem, (thanks scorpiorus for doing the display things) now I know what happens (with the help of scorpiorus). First it switches to MODE_USE, then it changes to cursor 6 but in 1 millisecond (with the messages I found out what was fishy) it changes BACK to MODE_USE. Can you explain that?
Hmm, it is possible that you have some code in repeatedly_execute that overrides the cursor appearance back to normal, can you post your global script repeatedly_execute function?
Hmm, I think I posted the repeatedly_execute function but I'll post it again:
function repeatedly_execute() {
// LEC Statusline
string bunky;
string texty;
int cursy;
StrCopy (texty, "");
cursy=GetCursorMode();
if (cursy==0) StrCat(texty,"Walk to ");
else if (cursy==1) StrCat (texty,"Look at ");
else if (cursy==2) StrCat(texty,"Use ");
else if (cursy==3) StrCat(texty,"Talk to ");
else if (cursy==4) {
StrCat(texty,"Use ");
GetInvName (player.activeinv, bunky);
StrCat(texty,bunky);
StrCat(texty," with ");
}
else if (cursy==5) StrCat(texty, "Pick up ");
else if (cursy==8) StrCat(texty, "Open ");
GetLocationName(mouse.x,mouse.y,bunky);
StrCat(texty,bunky);
SetLabelText (0,0,texty);
if (IsGUIOn(1) || IsGUIOn(3) || IsGUIOn(4)) {
SetMouseCursor(6);
SetLabelText(0,0, " ");
}
else SetDefaultCursor();
}
Only the recent version of the repeatedly_execute function has a meaning, thus I can see what's currently being wrong with it.
So, here is a new repeatedly_execute version taking into account that a cursor shouldn't be reset if the INVENTORY GUI is on:
function repeatedly_execute() {
// LEC Statusline
Ã, Ã, string bunky;
Ã, Ã, string texty;
Ã, Ã, int cursy;
Ã, Ã, StrCopy (texty, "");
Ã, Ã, cursy=GetCursorMode();
Ã, Ã, if (cursy==0) StrCat(texty,"Walk to ");
Ã, Ã, else if (cursy==1) StrCat (texty,"Look at ");
Ã, Ã, else if (cursy==2) StrCat(texty,"Use ");
Ã, Ã, else if (cursy==3) StrCat(texty,"Talk to ");
Ã, Ã, else if (cursy==4) {
Ã, Ã, Ã, Ã, StrCat(texty,"Use ");
Ã, Ã, Ã, Ã, GetInvName (player.activeinv, bunky);
Ã, Ã, Ã, Ã, StrCat(texty,bunky);
Ã, Ã, Ã, Ã, StrCat(texty," with ");
Ã, Ã, }
Ã, Ã, else if (cursy==5) StrCat(texty, "Pick up ");
Ã, Ã, else if (cursy==8) StrCat(texty, "Open ");
Ã, Ã, GetLocationName(mouse.x,mouse.y,bunky);
Ã, Ã, StrCat(texty,bunky);
Ã, Ã, SetLabelText (0,0,texty);
Ã, Ã, if (IsGUIOn(1) || IsGUIOn(3) || IsGUIOn(4) || IsGUIOn(INVENTORY)) {
Ã, Ã, Ã, Ã, SetMouseCursor(6);
Ã, Ã, Ã, Ã, SetLabelText(0,0, " ");
Ã, Ã, }
Ã, Ã, else SetDefaultCursor();
}
I see what the problem is, some script (probably hard-coded somehow makes the cursors stay that way in GUIs and it would not let it allow it to change. And in that case, I think you should read the Global Script to find any problems. Sorry if there is too much script in this topic.
// main global script file
#sectionstart game_start // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
// called when the game starts, before the first room is loaded
}
#sectionend game_start // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
// LEC Statusline
string bunky;
string texty;
int cursy;
StrCopy (texty, "");
cursy=GetCursorMode();
if (cursy==0) StrCat(texty,"Walk to ");
else if (cursy==1) StrCat (texty,"Look at ");
else if (cursy==2) StrCat(texty,"Use ");
else if (cursy==3) StrCat(texty,"Talk to ");
else if (cursy==4) {
StrCat(texty,"Use ");
GetInvName (player.activeinv, bunky);
StrCat(texty,bunky);
StrCat(texty," with ");
}
else if (cursy==5) StrCat(texty, "Pick up ");
else if (cursy==8) StrCat(texty, "Open ");
GetLocationName(mouse.x,mouse.y,bunky);
StrCat(texty,bunky);
SetLabelText (0,0,texty);
if (IsGUIOn(1) || IsGUIOn(3) || IsGUIOn(4) || IsGUIOn(INVENTORY)) {
SetMouseCursor(6);
SetLabelText(0,0, " ");
}
else SetDefaultCursor();
}
#sectionend repeatedly_execute // DO NOT EDIT OR REMOVE THIS LINE
function show_inventory_window () {
// This demonstrates both types of inventory window - the first part is how to
// show the built-in inventory window, the second part uses the custom one.
// Un-comment one section or the other below.
/*
// ** DEFAULT INVENTORY WINDOW
InventoryScreen();
*/
// ** CUSTOM INVENTORY WINDOW
GUIOn (INVENTORY);
// switch to the Use cursor (to select items with)
SetCursorMode (MODE_USE);
// But, override the appearance to look like the arrow
SetMouseCursor (6);
}
#sectionstart on_key_press // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
// called when a key is pressed. keycode holds the key's ASCII code
if (IsGamePaused() == 1) keycode=0; // game paused, so don't react to keypresses
if (keycode==17) GUIOn(4); // Ctrl-Q
if (keycode==363) SaveGameDialog(); // F5
if (keycode==365) RestoreGameDialog(); // F7
if (keycode==367) RestartGame(); // F9
if (keycode==434) SaveScreenShot("scrnshot.bmp"); // F12
if (keycode==9) show_inventory_window(); // Tab, show inventory
if (keycode==19) Debug(0,0); // Ctrl-S, give all inventory
if (keycode==22) Debug(1,0); // Ctrl-V, version
if (keycode==1) Debug(2,0); // Ctrl-A, show walkable areas
if (keycode==24) Debug(3,0); // Ctrl-X, teleport to room
}
#sectionend on_key_press // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (button==LEFT) {
ProcessClick(mouse.x, mouse.y, GetCursorMode() );
}
else { // right-click, so cycle cursor
SetNextCursorMode();
}
}
#sectionend on_mouse_click // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart interface_click // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
if (interface == ICONBAR)
{
if (button == 4) // show inventory
{
show_inventory_window();
}
else if (button == 5) // game controls
{
InterfaceOff(1);
SetCursorMode(6);
InterfaceOn(3);
}
else if (button == 6) // save game
SaveGameDialog();
else if (button == 7) // load game
RestoreGameDialog();
else if (button == 8) // quit
{
SetCursorMode(6);
SetMouseCursor(6);
DisableCursorMode(0);
DisableCursorMode(1);
DisableCursorMode(2);
DisableCursorMode(3);
DisableCursorMode(5);
GUIOn(4);
}
else if (button == 9) // about
Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
} // end if interface ICONBAR
if (interface == INVENTORY) // They clicked a button on the Inventory GUI
{
if (button == 1)
{
Display("We've just clicked on an arrow button!");
// They pressed SELECT, so switch to the Get cursor
SetCursorMode (MODE_USE);
Display("Changed cursor mode to MODE_USE!");
// But, override the appearance to look like the arrow
SetMouseCursor (6);
Display("Changed cursor appearance to mode 6");
}
if (button == 2)
{
// They pressed LOOK, so switch to that mode
SetActiveInventory(-1);
SetCursorMode(MODE_LOOK);
}
if (button == 3)
{
// They pressed the OK button, close the GUI
GUIOff (INVENTORY);
SetDefaultCursor();
}
if ((button == 4) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))
{
// scroll down
game.top_inv_item = game.top_inv_item + game.items_per_line;
}
if ((button == 5) && (game.top_inv_item > 0))
{
// scroll up
game.top_inv_item = game.top_inv_item - game.items_per_line;
}
}
CentreGUI(3);
if (interface == 3)
{
if (button == 8) SetGameSpeed(GetSliderValue(3,8));
if (button == 9) SetMusicMasterVolume(GetSliderValue(3,9));
if (button == 10) game.text_speed = GetSliderValue(3,10);
if (button == 0) SaveGameDialog();
if (button == 1) RestoreGameDialog();
if (button == 2) GUIOn(4);
if (button == 3)
{
SetCursorMode(6);
RestartGame();
}
if (button == 4)
Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
if (button == 11)
{
InterfaceOff (3);
InterfaceOn (ICONBAR);
SetCursorMode (1);
}
}
if (interface == 4)
{
if (button == 0) QuitGame(0);
if (button == 1) {
GUIOff(4);
EnableCursorMode(0);
EnableCursorMode(1);
EnableCursorMode(2);
EnableCursorMode(3);
EnableCursorMode(5);
SetCursorMode(0);
}
}
}
#sectionend interface_click // DO NOT EDIT OR REMOVE THIS LINE
Quoteif (interface == 3)
Ã, Ã, {
Ã, Ã, Ã, Ã, if (button ==Ã, 8) SetGameSpeed(GetSliderValue(3,8));
Ã, Ã, Ã, Ã, if (button ==Ã, 9) SetMusicMasterVolume(GetSliderValue(3,9));
Ã, Ã, Ã, Ã, if (button == 10) game.text_speed = GetSliderValue(3,10);
Ã, Ã, Ã, Ã, if (button ==Ã, 0) SaveGameDialog();
Ã, Ã, Ã, Ã, if (button ==Ã, 1) RestoreGameDialog();
Ã, Ã, Ã, Ã, if (button ==Ã, 2) GUIOn(4);
Ã, Ã, Ã, Ã, if (button ==Ã, 3)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(6);
Ã, Ã, Ã, Ã, Ã, Ã, RestartGame();
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, if (button == 4)
Ã, Ã, Ã, Ã, Ã, Ã, Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
if (interface == 4)
Ã, Ã, {
Ã, Ã, Ã, Ã, if (button == 0)Ã, QuitGame(0);
Ã, Ã, Ã, Ã, if (button == 1) {
Ã, Ã, Ã, Ã, Ã, Ã, GUIOff(4);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(0);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(1);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(2);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(3);
Ã, Ã, Ã, Ã, Ã, Ã, EnableCursorMode(5);
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(0);
Ã, Ã, Ã, Ã, }
I'm pretty sure you should be using else if statements here. i.e.:
Ã, Ã, Ã, Ã, if (button ==Ã, 8) SetGameSpeed(GetSliderValue(3,8));
Ã, Ã, Ã, Ã, else if (button ==Ã, 9) SetMusicMasterVolume(GetSliderValue(3,9));
Ã, Ã, Ã, Ã, else if (button == 10) game.text_speed = GetSliderValue(3,10);
Ã, Ã, Ã, Ã, else if (button ==Ã, 0) SaveGameDialog();
Ã, Ã, Ã, Ã, else if (button ==Ã, 1) RestoreGameDialog();
Ã, Ã, Ã, Ã, else if (button ==Ã, 2) GUIOn(4);
Ã, Ã, Ã, Ã, else if (button ==Ã, 3)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, Ã, SetCursorMode(6);
Ã, Ã, Ã, Ã, Ã, Ã, RestartGame();
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, else if (button == 4) Display("The Adventures of Bob I [[Made with Adventure Game Studio v2 run-time engine[[Copyright (c) 1999-2004 Chris Jones");
I'm pretty sure...
EDIT: Also,
if (interface==ICONBAR){
//bleh
}
else if (interface==INVENTORY){
//bleh
}
else if (interface==3){
//bleh
}
else if (interface==4){
//bleh
}
I couldn't see anything wrong with the main global script and decided to test it in AGS. And it worked fine for me. Can you post a script of the room you are in when operating with GUIs?
How large is your game? Can you upload it (or send to me) so I could take a look?
So do you NOT have to use else if statements? I thought it wouldn't work right without else if statements... Ok...
Quote from: monkey_05_06 on Sun 12/09/2004 20:55:10
So do you NOT have to use else if statements? I thought it wouldn't work right without else if statements... Ok...
Yep, usually it's a good idea to have
elseifs since without them nasty things can happen, like:
if (x=1) {Display("1"); x++;}
if (x=2) {Display("2"); x++;}
if (x=3) {Display("3"); x++;}
In this case (if x initially is 1) all three Display commands will be run because x is increased to the next value.
Using elseifs sorts it out:
if (x=1) {Display("1"); x++;}
Ã, Ã, else if (x=2) {Display("2"); x++;}
Ã, Ã, Ã, Ã, else if (x=3) {Display("3"); x++;}
They are nested and thus only a single Display is called.
Provided, however, you don't change variables that are used to check the condition, you can do without elseifs. Both "interface" and "button" are not to change within the interface_click function so it's not really a problem here. But, yes, using elseifs is considered to be a good programming practice since it not only helps to avoid logical mistakes but also can save some processor time.
Gee, the part you quoted monkey_05_06, Scorpiorus did that part. And I believe the part that has been messing my things up was the part where there is the "load", "play" and "quit", so I will show it to you, and possibly the otehr room scripts.
Load/Play/Quit Room Script:
[code}
// room script file
#sectionstart room_a // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
// script for room: Player enters screen (before fadein)
//change mouse to the 'pointer' cursor and also, this might have been the problem
DisableCursorMode(0);
DisableCursorMode(1);
DisableCursorMode(2);
DisableCursorMode(3);
DisableCursorMode(4);
DisableCursorMode(5);
DisableCursorMode(7);
DisableCursorMode(8);
DisableCursorMode(9);
DisableCursorMode(10);
SetMouseCursor(6);
}
#sectionend room_a // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart hotspot2_a // DO NOT EDIT OR REMOVE THIS LINE
function hotspot2_a() {
// script for hotspot2: Any click on hotspot
RestoreGameDialog();
}
#sectionend hotspot2_a // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart hotspot3_a // DO NOT EDIT OR REMOVE THIS LINE
function hotspot3_a() {
// script for hotspot3: Any click on hotspot
GUIOn(4);
}
#sectionend hotspot3_a // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart room_b // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
// script for room: Player leaves screen
InterfaceOn(0);
InterfaceOn(1);
SetLabelText (0,0," ");
}
#sectionend room_b // DO NOT EDIT OR REMOVE THIS LINE
I believe the problem was at the disable cursor mode part. Also, it was supposed to be at cursor 6 but somehow it started at cursor 5.
Here's the other room scripts (which they should be fine) but room 1 has a script that is linked to room load/play/quit and it works fine, probable a problem to others though and ignore the score part:
Room 1:
function room_a() {
// script for room: Player enters screen (before fadein)
GiveScore(100);
}
#sectionend room_a // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart hotspot1_a // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a() {
// script for hotspot1: Use inventory on hotspot
SetLabelText (0,0,"Walk to @OVERHOTSPOT@");
}
#sectionend hotspot1_a // DO NOT EDIT OR REMOVE THIS LINE
#sectionstart room_b // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
// script for room: First time player enters screen
EnableCursorMode(0);
EnableCursorMode(1);
EnableCursorMode(2);
EnableCursorMode(3);
EnableCursorMode(4);
EnableCursorMode(5);
EnableCursorMode(6);
SetCursorMode(MODE_WALK);
}
#sectionend room_b // DO NOT EDIT OR REMOVE THIS LINE
Room 2 should be fine since this room has absolutely not script because the room script is empty :P.
Anyway, if you want to know more on what game this script is for, find "The Adventures of Bob I" in the Games in Production forum, the screenshot is from room 2.
Hmm, strange. By the way, what if you comment out the "else SetDefaultCursor();" line inside the repeatedly_execute function, does a cursor still change to the hand image when you press that GUI button?
Yeah, I kind of knew that, but I guess I just forgot. Edwin, if you want several things to run only if a specific statement is true for each, use else if statements:
if (button==1) //stuff for button 1
else if (button==2) //stuff for 2
But, if you want several things to be able to happen at once, such as if you are pressing up and right, move the cursor up AND right:
if (IsKeyPressed(372)==1) SetMousePosition(mouse.x, mouse.y-2);
if (IsKeyPressed(377)==1) SetMousePosition(mouse.x+2, mouse.y);
The first would run the whole script as a single statement, so that if the button was 1, it couldn't possibly be 2. The second script would run each if statement as a separate statement, so if you pressed up it would move the cursor up, right would move it right, and both would move it up-right. Does this help you understand where else statements are necessary? I certainly hope so... Also, please try not to confuse AGS scripting with BB scripting... The script for code should be (where bold parenthesis () are replaced with brackets []:
(code) if (blah==bleh) bah;(/code)
Not to sound rude, but your last post was confusing. Great. Scorpiouriuosyousyuouisos beat me to posting. Anyway, the Preview button is always nifty...
By the way, by clicking the Select button, it uses that cursor and cannot change to anything else. You can't even select an item!
EDIT: In the help file it states:
Quote
SetMouseCursor
SetMouseCursor(int new_cursor)
Changes the appearance of the mouse cursor to NEW_CURSOR. Unlike the SetCursorMode function (see above), this does not change the mode used if the user clicks on a hotspot. This is useful for displaying a "wait" cursor temporarily.
Example:
SetMouseCursor(8);
will change the mouse cursor to the cursor number 8 specified in the cursor's tab.
So, the the main problem is this. If I did an alternative it would be too long with the "DisableMouseCursor" so, I am asking for an alternative way to do
DisableCursorMode(INT_CURSOR);
DisableCursorMode(INT_CURSOR);
DisableCursorMode(INT_CURSOR);
DisableCursorMode(INT_CURSOR);
DisableCursorMode(INT_CURSOR);
DisableCursor...................................
Bump!
It's not necessary to disable a cursor just because it's not in use. Nor is it logical, unless you have some MAJOR reason to do so. Just leave them all enabled, and see how it works. :)
Look, what I really want to do is give my inventory GUI the normal traits of the regular Inventory GUI but there is something messing that up. And later I will PM the adress to you so you can see the main problem, ok?
EDIT: Nevermind. It's working perfectly right now. (Since I fixed the code)
Wait... Mr. I Have Problems With Cursors just said "It's working perfectly"? :o :o :o Edwin, tell us all how you reached this miraculous moment in time where YOU actually got it to work (a.k.a. Show us your script)
Now this is just a mystery, if I replace the bad script with the original script BEFORE it didn't work. Right now it works. Is there some kind of bug in AGS like that? I am using the current version (not the rc1).
What? Well maybe there's some differences. Show us the scripts so we can see what you're talking about. Also, are you saying that it works? You're kind of confusing me...
Ok, once when I had to implement the status bar, I used this script:
if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@");
if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@");
if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@");
if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@");
if (GetCursorMode()==4) {
string usinginv;
string useinvtxt;
StrCopy (useinvtxt, "Use ");
GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
StrCat (useinvtxt,usinginv);
StrCat (useinvtxt," with ");
StrCat (useinvtxt,"@OVERHOTSPOT@");
SetLabelText(0,0,useinvtxt);
}
}
The game said it didn't work when I used this.
Here is the script that worked:
if (GetCursorMode()==0) SetLabelText(0,0,"Walk to @OVERHOTSPOT@");
if (GetCursorMode()==1) SetLabelText(0,0,"Look at @OVERHOTSPOT@");
if (GetCursorMode()==2) SetLabelText(0,0,"Interact with @OVERHOTSPOT@");
if (GetCursorMode()==3) SetLabelText(0,0,"Talk to @OVERHOTSPOT@");
if (GetCursorMode()==4) {
string usinginv;
string useinvtxt;
StrCopy (useinvtxt, "Use ");
GetInvName(character[GetPlayerCharacter()].activeinv,usinginv);
StrCat (useinvtxt,usinginv);
StrCat (useinvtxt," with ");
StrCat (useinvtxt,"@OVERHOTSPOT@");
SetLabelText(0,0,useinvtxt);
}
}
Anything different with the script? Probably not. Wierd.