Handle inventory clicks in scripts

Started by stryker, Sat 09/08/2003 21:49:19

Previous topic - Next topic

stryker

Hi all,
for many reasons i had to turn on the "handle inventory clicks in scripts" options, to make more customizable invenotry events.
Everything works fine BUT the MODE_USEINV thing. For now (it's only a test, to find out how the hell that USEINV works) i made the rightclick call the MODE_LOOK (and it works), and the leftclick call the MODE_USEINV, but it doesn't work. when the inventory pops up the mouse is already in USEINV (4) mode, but when i leftclick on an inventory objects it does nothing: the pointer keeps look like an hand, and doesn't pick up the object from the inventory.

this is the code in on_mouse_click:

else if (button==RIGHTINV) RunInventoryInteraction(game.inv_activated,1);
     
 else if (button==LEFTINV) RunInventoryInteraction(game.inv_activated,MODE_USEINV);


what i'm missing?

thankyou

(sorry for my english)

Download Discworld Template ODIS ver1.2
(right-click and "save as")

Proskrito

you could use

SetActiveInventory(GetInvAt(mouse.x,mouse.y));

for selecting the item that you clicked on, like:


int invitem;
invitem=GetInvAt (mouse.x,mouse.y);
...
else if (button==LEFTINV) {
if (GetCursorMode()==2){
if (IsInventoryInteractionAvailable(invitem,MODE_USE)==1)
RunInventoryInteraction(invitem, MODE_USE);
else SetActiveInventory(invitem);
}
else RunInventoryInteraction(invitem,GetCursorMode());
}



stryker


Download Discworld Template ODIS ver1.2
(right-click and "save as")

stryker

Tried. Ok, you gave me a script to "interact" the inventory if there is interaction, and to "use" if there is no interaction scripted, right?

But my question was much more simple (i think):
i really can't understand how the "use inventory item" works, and i think there is no tutorial in ags help that explain it, because they all assume that i'm using the standard sierra inventory or at least a normal system with no "handle inventory etc" enabled.
What i'm asking is how to:
1) make an inventory object active (in which mode the cursor have to be? what script must be run?)
2) keep the selected object active with its sprite on the cursor (the cursor mode must be the same as above?)
3) use the selected object on another inv object or hotspot (cursor mode? what interaction must be selected in thetarget hotspot?)
all with scripting, because i had to turn on "handle inventory.." for many reasons and all that stuff doesn't work automatically, i must script it!

is there any tutorial that explains how the thing works? or at least is there any "demo" game (whit the ags file) with the "handle inventory" turned on?
if not, pleeeze explain (stryker@ctonet.it / 13203225 if it's a long story and someone would discuss it in private)!

thankyou!

Download Discworld Template ODIS ver1.2
(right-click and "save as")

Ginny

#4
Sounds like what you want to do is exactl what the normal inventory does.

What are the reasons because of which you need to use "Handle inventory cliks in script"?

Now, if I understand correctly, you want to have the normal inventory where one of the buttons selects the inventory item and and when it's selected it uses it on something else.
I just checked and what Proskrito posted should work. Make sure there isn't an "interact" event for the inventory item, and put this the code in the on_mouse_click function.
(Note: put all the code there except for int invitem; which goes at the top of the script, before any functions.)
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

Proskrito

Quote from: stryker on Sun 10/08/2003 22:16:13
1) make an inventory object active (in which mode the cursor have to be? what script must be run?)
the code should be SetActiveInventory(int inventorynumber)
you might want to use GetInvAt(mouse.x,mouse.y) for getting the invent. number of the item you clicked on.
the cursor mode could be the one you like, as you are handling inv. clicks in script, but the default mode (and most used i think) is cursor mode 2 (use).
Quote
2) keep the selected object active with its sprite on the cursor (the cursor mode must be the same as above?)
When you have an active inventory item, the cursor mode changes to 4 (i think). for having the item sprite as the cursor, you must uncheck "dont use inventory graphics as cursor" in the general settings panel.
Quote
3) use the selected object on another inv object or hotspot (cursor mode? what interaction must be selected in thetarget hotspot?)

the interaction should be "use inventory on hotspot/object/item...", and then check which item was used by something like:
if (character[GetPlayerCharacter()].activeinv == #){//if item number # was used
// do whatever
}

Dont know if that is what you wanted to know, hope it helps

Ginny

It should work IMO, I checked it.

If you want to be able to have items that can be interacted with or used on something else, here:
http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=7694;start=20

In my last post I combined what Proskrito wrote and another condition to do this in the same mode :).
Try Not to Breathe - coming sooner or later!

We may have years, we may have hours, but sooner or later, we push up flowers. - Membrillo, Grim Fandango coroner

stryker

Thakyou all! I finally made what I had in mind.
It's a Discworld-like interaction system (now you can see wat i mean in my questions :)
It works fine, now, check it out:

http://helcaraxe.altervista.org/ODISv1.00.zip

Download Discworld Template ODIS ver1.2
(right-click and "save as")

SMF spam blocked by CleanTalk