Click In Inventory Item.

Started by , Sun 20/07/2003 01:41:50

Previous topic - Next topic

Plog

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?  ???

Ishmael

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...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Plog

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.

Ishmael

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...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Plog

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

Scavenger

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.

Plog

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

Ishmael

Fuse them together? What do you mean..?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Plog

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.

Wolfgang Abenteuer

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

Plog

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?

Wolfgang Abenteuer

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

Plog

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

Plog

I need help with this before it gets knocked off the page.

Proskrito

why dont you put a "RunDialog(#);" in the "Any click" interaction in that inv. item?

Plog

That dosnt work either
Grah! Whats wrong wit it. >:(

Proskrito

#16
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  ;)

Plog

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.

Plog

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.

Ishmael

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 //.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk