Handleing Objects on a Script

Started by Dr Snark, Tue 05/08/2003 16:19:15

Previous topic - Next topic

Dr Snark

#20
That is exactly what happens. See? Im not Crazy!
AGS has a Big Giant BUG! :P

maybe this could ge fixed in the Next version? Hmm Chris?


until then.. im working on a "work-around" for this
Stay Tuned...


Thanks, Ginny, and all that helped

I aapriciate it!


Ginny

#21
Actually, I don't think it's a bug, I have a feeling this is how it's supposed to be when "Handle inventory clicks in script" is checked. It actually shows that though the engine isn't supposed to be able to interact with inventory, it can. A plus, not a minus IMO! :P

In any case, in the begginers forum there was a question similar but not quite, and here is a solution to the problem (all credit to Proskrito, who posted this code):
(here is the link incase you're interested:
http://www.agsforums.com/yabb/index.php?board=6;action=display;threadid=7770 )

Before any functions in the global script, put this:

int invitem;

now in the on_mouse_click function, add this:

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

This will select the item, unless there's an "interact" interaction set for the item, in which case it will run it.
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

Dr Snark

#22
Great THanks it worked liike a Charm :)

now i have to see about that "open" code or if i can just do away with it for now and just use the "interact"

Actualy it Fixed 1/2 my problem

now i can't get any hot spots or anything to click on my game

wOAH I just moved some Brackets and added some Bippity Boppity Boo and Threw in some Baked LIzard Skins and and Eye in Newt adn i havw it working the way i wanted it to work!
YEAH!

Ginny

Ok, glad everything works.

Yesterday night I was thinking though, if someone would want to have some items that could be both selected and interacted with, but wthout using Usermode1, this could be done:

at the top of the script:

int invitem;
int usebutton;

in on_mouse_click:

invitem=GetInvAt (mouse.x,mouse.y);

if (button==LEFTINV) {
if (GetCursorMode()==2){
 if (usebutton==1) {
SetActiveInventory(invitem);
}
else if (usebutton==2) {
if (IsInventoryInteractionAvailable(invitem,MODE_USE)==1) {
RunInventoryInteraction(invitem, MODE_USE);  
}
}
}
else RunInventoryInteraction(invitem,GetCursorMode());
}


in the script for the select button:

SetCursorMode(2);
SetMouseCursor(6);
usebutton=1;

in script for interact button:

SetCursorMode(2);
usebutton=2;

This way you use the same mode for both, but what happens depends on which button you click. All interactions will be put in the "interact" event. :)
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

Pumaman

Quote from: GinnyW on Mon 11/08/2003 00:59:10
It actually shows that though the engine isn't supposed to be able to interact with inventory, it can

Hehe yes, that bit of the manual was written before the "Handle inv clicks in script" option was available - at which point, it was impossible to use the Interact event :)

SMF spam blocked by CleanTalk