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.
check all the boxes... of the objects... make them clickable!
Check what boxes of which objects and how do you make them clickable?
I didnt understand a word of that. ???
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. :)
It says parse error unexpected If.
So I change it to if and still the same what do I do now?
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.
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.
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
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
/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...
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.
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?
No I want it so if you left click while in Usermode 1 it brings up the inventory in the same place everytime.
Please I really need help with this I cant do anything till this is done. ???
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();
}
}
I sais variable 'on_mouse_click' is allready difined.
What do I do? ???
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!
And which one dont I need? :P
Sorry I am an extreme newbie.
he dont worry.
delete the new one and type the code in the old one, so it will look just like the new one.
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();
}
}
keep this one, delete the other one, and test your game!
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);
You forgot the } at the end.
put on the } behind SetNextCursorMode();
example: SetNextCursorMode();}
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.
Please I need your help so I can finish my game.