My little project.

Started by , Tue 15/07/2003 15:59:11

Previous topic - Next topic

Plog

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.

Minimi

check all the boxes... of the objects... make them clickable!

Plog

Check what boxes of which objects and how do you make them clickable?
I didnt understand a word of that.  ???

Hollister Man

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. :)
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

Plog

It says parse error unexpected If.
So I change it to if and still the same what do I do now?

Proskrito

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.

Hollister Man

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.
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

TerranRich

#7
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) {
if (button==LEFT) {
if (GetCursorMode()==8) {
GUIOn(123); // replace with the right GUI #, perhaps it is 0?
} else {
// whatever you had in the left click interaction...
}
} else if {button==RIGHT) {
// whatever...
}
}

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
Status: Trying to come up with some ideas...

Plog

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

Necro

#9
* Necro 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...

Plog

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.

Hollister Man

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?
That's like looking through a microscope at a bacterial culture and seeing a THOUSAND DANCING HAMSTERS!

Your whole planet is gonna blow up!  Your whole DAMN planet...

Plog

No I want it so if you left click while in Usermode 1 it brings up the inventory in the same place everytime.

Plog

Please I really need help with this I cant do anything till this is done.  ???

Jet X.L.

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();
 }
}

Plog

I sais variable 'on_mouse_click' is allready difined.

What do I do?  ???

Minimi

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!

Plog

And which one dont I need?  :P

Sorry I am an extreme newbie.

Jet X.L.

he dont worry.
delete the new one and type the code in the old one, so it will look just like the new one.

Plog

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();
 }
}

SMF spam blocked by CleanTalk