Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Tue 15/07/2003 15:59:11

Title: My little project.
Post by: on Tue 15/07/2003 15:59:11
I have decided to start a little project im ditching the GUIs apart from the inventory window. Ive made it so you cary around a little console that you can use to save quit and load. But my only problem is the inventory.
I decided to make Usermode 1 an inventory cursor but my problem is making it so if you click anywhere on the screen in that cursor that it brings up the inventory GUI.

Thanks --- Plog.
Title: Re:My little project.
Post by: Minimi on Tue 15/07/2003 16:42:46
check all the boxes... of the objects... make them clickable!
Title: Re:My little project.
Post by: on Tue 15/07/2003 16:51:08
Check what boxes of which objects and how do you make them clickable?
I didnt understand a word of that.  ???
Title: Re:My little project.
Post by: Hollister Man on Tue 15/07/2003 21:04:27
I have no idea what he is talking about.   ???  But the way I would do it is something like this.

If you check your Global Script, you should find an area that handles all the mouse clicks (onmouseclick).  I am not in front of my game computer now, so I can't really tell you exactly.

Somewhere in there you script a bit that works with this logic.
    If (mode==usermode1)
    {
         open inventory window
    }

That should do it.  I would give it a go, but as I said I am at work. :)
Title: Re:My little project.
Post by: on Tue 15/07/2003 22:15:17
It says parse error unexpected If.
So I change it to if and still the same what do I do now?
Title: Re:My little project.
Post by: Proskrito on Tue 15/07/2003 22:39:03
if you want the gui to pop up if the actual cursormode is 8 ,i think you should do:
on_mouse_click(int button){//cant remember the exact name of the function
if (button==LEFT){
if (GetCursorMode()==8) GUIon(#);//replace# with your gui #
else{ //what you had in the left click interaction
}
}
else if (button==RIGHT) { //whatever
}
}

Check the case in the function names, i cant remember them very well.
PS: Why using cursor mode 8 for inventory? just curious.
Title: Re:My little project.
Post by: Hollister Man on Wed 16/07/2003 00:56:16
oh yes, I for got to remind you that my "code" isn't good.  I can do it if I have my script window in front of me, but I cannot just pull it out of my ear.  It was just a hint.
Title: Re:My little project.
Post by: TerranRich on Wed 16/07/2003 04:50:02
By making the objects clickable, he meant to go through each button on the GUI you're using and make sure that their "Left Click" property is set to "Run Script". This ensures that the button code will be run when clicked.

Also, the problem with your code was that your "if" command was capitalized. Regular C++ code (like while, if, and else if) should always be lower-case, and all AGS-specific commands (like RunAGSGame, SetObjectFrame, etc.) should all be capitalized word-by-word without spaces.

Also, Proskrito, that should read:

function on_mouse_click(int button) {
(http://www.harbinger-software.com/images/space.gif)if (button==LEFT) {
(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)if (GetCursorMode()==8) {
(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)GUIOn(123); // replace with the right GUI #, perhaps it is 0?
(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)} else {
(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)// whatever you had in the left click interaction...
(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)}
(http://www.harbinger-software.com/images/space.gif)} else if {button==RIGHT) {
(http://www.harbinger-software.com/images/space.gif)(http://www.harbinger-software.com/images/space.gif)// whatever...
(http://www.harbinger-software.com/images/space.gif)}
}

This is just to (1) make things more readable,  and (2) to fix certain things. Also, if commands should be evenly bracketed. That is, if the "else if" part has braces ({}) then so should the "if" part of the set.

:)

EDIT:
I seriously thought I saved my last edit, which was the one above.  :P
Title: Re:My little project.
Post by: on Wed 16/07/2003 06:46:40
Ok my Cursor is 8 and my Inventory GUI is 0. I need to know exactly what to put on my global script because im a newbie.   :P
Title: Re:My little project.
Post by: Necro on Wed 16/07/2003 09:30:34
/me pauses to look at all those silly non breaking spaces

Dryhumps looks like what u need... but ignore his   , he was trying to indent his code for you...
Title: Re:My little project.
Post by: on Wed 16/07/2003 14:42:42
So what exactly do I type in my global script using the things I said above. I really need this because I cant really carry on with my game until I fix it.
Title: Re:My little project.
Post by: Hollister Man on Wed 16/07/2003 20:28:34
I don't think Dry quite knows what you mean.  I'll code it tonight, if I remember.  :)  Sorry for the wait, but I just bought a new computer and have not set up AGS on it yet.  

Let me get this straight exactly.  You want it to be that when you right click, an inventory box pops up.  Do you want it to pop up at the position of the cursor, or in the same place every time?  And what are you using the special inventory cursor in Usermode 1 for exactly?
Title: Re:My little project.
Post by: on Thu 17/07/2003 07:39:08
No I want it so if you left click while in Usermode 1 it brings up the inventory in the same place everytime.
Title: Re:My little project.
Post by: on Thu 17/07/2003 22:11:18
Please I really need help with this I cant do anything till this is done.  ???
Title: Re:My little project.
Post by: on Fri 18/07/2003 21:41:46
Nice idea. I think i'll use it as well.
find this function in the global source and change it like this

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() );
   if (GetCursorMode()==8) {  //////////  this is the code for  the inventory
     InventoryScreen();           //////////   you don't have to include
     }                                      //////////    this message (good luck!)
 }
 else {   // right-click, so cycle cursor
   SetNextCursorMode();
 }
}
Title: Re:My little project.
Post by: on Fri 18/07/2003 22:51:40
I sais variable 'on_mouse_click' is allready difined.

What do I do?  ???
Title: Re:My little project.
Post by: Minimi on Fri 18/07/2003 22:55:23
check in your global script, if function on_mouse_click is 2 times written in the script! if so, remove the one, you dont need!
Title: Re:My little project.
Post by: on Fri 18/07/2003 23:05:19
And which one dont I need?  :P

Sorry I am an extreme newbie.
Title: Re:My little project.
Post by: on Fri 18/07/2003 23:24:39
he dont worry.
delete the new one and type the code in the old one, so it will look just like the new one.
Title: Re:My little project.
Post by: on Fri 18/07/2003 23:28:36
Im not sure what you mean here is the old one can you put the two together please.

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();
 }
}
Title: Re:My little project.
Post by: Minimi on Fri 18/07/2003 23:33:23
keep this one, delete the other one, and test your game!
Title: Re:My little project.
Post by: on Fri 18/07/2003 23:39:28
Arrgh I cant get my head round these nested funcions can someone sort this out for me.

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() );
if (GetCursorMode()==8) { ////////// this is the code for the inventory
InventoryScreen(); ////////// you don't have to include
} ////////// this message (good luck!)
}
else { // right-click, so cycle cursor
SetNextCursorMode();
}


function dialog_request(int parameter) {
if (parameter==1) {
SetDialogOption(4,2,1);
}
if (parameter==2) {
SetDialogOption(1,3,1);
}
if (parameter==3) {
SetDialogOption(4,3,1);
}
if (parameter==4) {
SetDialogOption(0,3,1);
Title: Re:My little project.
Post by: jetxl on Fri 18/07/2003 23:45:31
You forgot the } at the end.
put on the } behind SetNextCursorMode();

example: SetNextCursorMode();}
Title: Re:My little project.
Post by: on Sat 19/07/2003 00:33:41
Now ive done this ive just realised I need to make it so if you left click while your cursor is a certain inventory item that it brings up a dialog.
Title: Re:My little project.
Post by: on Sat 19/07/2003 10:24:11
Please I need your help so I can finish my game.