Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sun 20/07/2003 01:41:50

Title: Click In Inventory Item.
Post by: on Sun 20/07/2003 01:41:50
I need it so when you left click in a certain inventory item that it will bring up a dialog how do I do this?  ???
Title: Re:Click In Inventory Item.
Post by: Ishmael on Sun 20/07/2003 11:58:40
in on_mouse_click in global script:

if ((button==LEFTINV) && (game.inv_activated==x)) {
 // code here
}

and replace the x with the inv items number...
Title: Re:Click In Inventory Item.
Post by: on Sun 20/07/2003 12:03:00
Thanks TK.
But I still dont understamd where to put it.
This is my on_mouse_click thingy at present.

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

And do I put RunDialog(Whatever) after all this.
Title: Re:Click In Inventory Item.
Post by: Ishmael on Sun 20/07/2003 12:06:14
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!)
if ((button==LEFTINV) && (game.inv_activated==x)) {
// code here
}
else { // right-click, so cycle cursor
SetNextCursorMode();}
}

I think...
Title: Re:Click In Inventory Item.
Post by: on Sun 20/07/2003 12:21:19
This is the code in my dialog but it says RestoreGameDialog uknown request or something like that.

// dialog script file
@S  // dialog startup entry point
return
@1  // option 1
RestoreGameDialog();
stop
@2  // option 2
SaveGameDialog();
stop
@3  // option 3
QuitGame;
stop
Title: Re:Click In Inventory Item.
Post by: Scavenger on Sun 20/07/2003 15:15:29
For your last problem, you can't put text scripts in dialogs. You need to use dialog requests. They are explained in the manual, under Conversations. Do something like this in your Dialog:

// dialog script file
@S // dialog startup entry point
return
@1 // option 1
set - global 1, 1
dialog req 1
stop
@2 // option 2
set - global 1, 2
dialog req 1
stop
@3 // option 3
set - global 1, 3
dialog req 1
stop

And in the function Dialog Request:
if(MODE == 1) && (GetGlobalInt(1) == 1)
{
RestoreGameDialog ();
}
else if(MODE == 1) && (GetGlobalInt(1) == 2)
{
SaveGameDialog ();
}
if(MODE == 1) && (GetGlobalInt(1) == 1)
{
QuitGame ();
}

Check it up in the Manual, I doubt my dialog functions are right.
Title: Re:Click In Inventory Item.
Post by: on Sun 20/07/2003 17:50:32
How do I fuse the requests together?

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

} //end of dialog_request()
Title: Re:Click In Inventory Item.
Post by: Ishmael on Mon 21/07/2003 08:42:42
Fuse them together? What do you mean..?
Title: Re:Click In Inventory Item.
Post by: on Mon 21/07/2003 11:12:48
I cant have two dialog requests so I have to put my old one with my new one but becuase im a newbie I cant work out where the new one goes and how many "}"s
and ";"s go in there.
Title: Re:Click In Inventory Item.
Post by: Wolfgang Abenteuer on Mon 21/07/2003 16:02:33
Try this:

// dialog script file
@S // dialog startup entry point
return
@1 // option 1
run-script 5
stop
@2 // option 2
run-script 6
stop
@3 // option 3
run-script 7
stop

Then, in your function dialog_request:

if (parameter == 5) {
RestoreGameDialog ();
}
if (parameter == 6) {
SaveGameDialog ();
}
if (parameter == 7) {
QuitGame(1);
}

That last part should go right above the last "}" in your function dialog_request code.

~Wolfgang
Title: Re:Click In Inventory Item.
Post by: on Mon 21/07/2003 21:26:23
The click thing wont work now.

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!)
if ((button==LEFTINV) && (game.inv_activated==1)) {
// code here
RunDialog(7);}
}
else { // right-click, so cycle cursor
SetNextCursorMode();}
}

I left clcik while in it but its not working!!
Why?
Title: Re:Click In Inventory Item.
Post by: Wolfgang Abenteuer on Tue 22/07/2003 01:07:49
When you bring up an inventory window GUI, it pauses the game.

if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}

This line tells the game not to accept any mouse clicks while the game is paused.  Try moving your inventory interaction inside of those brackets instead, like such:

if (IsGamePaused() == 1) {
 if ((button == LEFTINV && game.inv_activated == 1)) {
 RunDialog(7);
 }
}

~Wolfgang
Title: Re:Click In Inventory Item.
Post by: on Tue 22/07/2003 07:08:49
I still cant make it work.

function on_mouse_click(int button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
if ((button == LEFTINV && game.inv_activated == 1)) {
RunDialog(7);
}
}
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!)
if ((button==LEFTINV) && (game.inv_activated==1)) {
// code here
RunDialog(7);}
}
else { // right-click, so cycle cursor
SetNextCursorMode();}
}
Title: Re:Click In Inventory Item.
Post by: on Wed 23/07/2003 12:29:14
I need help with this before it gets knocked off the page.
Title: Re:Click In Inventory Item.
Post by: Proskrito on Wed 23/07/2003 21:03:06
why dont you put a "RunDialog(#);" in the "Any click" interaction in that inv. item?
Title: Re:Click In Inventory Item.
Post by: on Thu 24/07/2003 12:40:07
That dosnt work either
Grah! Whats wrong wit it. >:(
Title: Re:Click In Inventory Item.
Post by: Proskrito on Thu 24/07/2003 13:09:45
oh yes, it should work! (i've tried it right now) but you have to leave the 'onmouseclick' function as you had it before.
Anyway, you could try to read the manual for this kind of questions, you´ll find the answer faster and get more confident with ags if you figure it out by yourself  ;)
Title: Re:Click In Inventory Item.
Post by: on Sat 26/07/2003 11:21:34
Still dosnt work.
I thought maybe its because I dont have a Any Click interaction I dont know what version of AGS you have but mine certainly dosnt have it.
Title: Re:Click In Inventory Item.
Post by: on Mon 04/08/2003 11:40:47
Hey this script is a real delay in my game making pocess I cant test my game till it is finished im sorry for bumping but honestly if I dont I wont get an answer.
Title: Re:Click In Inventory Item.
Post by: Ishmael on Mon 04/08/2003 13:12:01
Maby you should explain what each if (GetCursorMode()==#) { should do, and get rid of the comment's, they make it a bit confusing... as you dont really need them. And by comments I mean the lines, or line ends, starting with //.
Title: Re:Click In Inventory Item.
Post by: on Thu 07/08/2003 12:13:27
function on_mouse_click(int button) {
if (IsGamePaused() == 1) {
}
else if (button==LEFT) {
ProcessClick(mouse.x, mouse.y, GetCursorMode() );
if (GetCursorMode()==8) {
InventoryScreen();
}
}
else {
SetNextCursorMode();}
}

There I took them out or did I take something out I wasn't supposed to.

And I don't know what they are supposed to do this is my first game and im trying to get to grips with scripting all I can do is explain as best I can so here it goes.

What I need is when you open the inventory window inside a game and click on the inventory item which is number 1 and then the cursor turns into that inventory item right. Then I need it so when you click anywhere on the screen while in that cursor that the Load Sava and Quit dialog appears and the dialog being number 7.
Title: Re:Click In Inventory Item.
Post by: Ishmael on Thu 07/08/2003 20:15:27
Um... sorry if I'm bieng stupid, but I don't understand... could you put that in steps, like

1. Click a button
2. Open GUI #

etc. (just an example)
Title: Re:Click In Inventory Item.
Post by: on Fri 08/08/2003 00:24:43
1. Open inventory
2. Click on inventory item 1.
3.Inventory item 1 appears as cursor.
4. Click anywhere on the screen.
5. Open Dialog 7.

4 and 5 are the ones I need scripted.
Title: Re:Click In Inventory Item.
Post by: Ishmael on Fri 08/08/2003 14:51:40
the script you need: (I believe)

in on_mouse_click:

if ((button==LEFT) && (character[EGO].activeinv==1) && (GetCursorMode()==4)) {
 RunDialog(7);
}
Title: Re:Click In Inventory Item.
Post by: on Tue 12/08/2003 13:32:21
What do Itake out of this and where do I put the new script you just gave me?

function on_mouse_click(int button) {
if (IsGamePaused() == 1) {
}
else if (button==LEFT) {
ProcessClick(mouse.x, mouse.y, GetCursorMode() );
if (GetCursorMode()==8) {
InventoryScreen();
}
}
else {
SetNextCursorMode();}
}
Title: Re:Click In Inventory Item.
Post by: on Wed 13/08/2003 06:10:47
function on_mouse_click(int button) {
if (IsGamePaused() == 1) {
}
if ((button==LEFT) && (character[EGO].activeinv==1) && (GetCursorMode()==4)) {
RunDialog(7);
}
else if (button==LEFT) {
ProcessClick(mouse.x, mouse.y, GetCursorMode() );
if (GetCursorMode()==8) {
InventoryScreen();
}
}
else {
SetNextCursorMode();}
}  

:P

and btw

Quoteif (GetCursorMode()==8) {
InventoryScreen();
}

What is this supposed to make? I mean whats the idea of opening inv screen if the cursor mode is 8 when you click on the screen..? :J
Title: Re:Click In Inventory Item.
Post by: on Wed 13/08/2003 11:51:22
I Just didnt like the GUI so I made anew way to make the inventory come up and now im working on geting save load and quit  up you see.
Title: Re:Click In Inventory Item.
Post by: on Fri 15/08/2003 09:18:24
...
Title: Re:Click In Inventory Item.
Post by: Ishmael on Fri 15/08/2003 15:46:48
Very offtopic, and unneeded, but: what does that mean?