I ripped apart the MI2 and DOTT templates and found them all to Confusing, I want to Interact with inventory objects while in the Inventory screen is open
Im making a custom Inventory. if this helps.
You'll have to be more specific about what you've done so far, and where you're having a problem, in order to get help.
Ok..
what ive done so far is create a Hacked-up version of MI2.
what i am Trying to Accomplish is:
1. hit tab to bring up the inventory Screen (did that, FROZE MY GAME)
2. and i want to be able to:
Open an Inventory object (in the inventory screen), revaling another object.
and i can't get ANYthing to work.
No one can help?
I guees my game will be "put off" for a while.
To fix the froze up you'll need to go throught the script carefully and check if it's a bug... And the opening inv object can (As far as I know) be done like this:
Interact/Open/whateve can be done to the object ->
SetPlayerCharacter(CHARID); to be the char who has the inv item which are inside the other object ->
When the object is closed, SetPlayerCharacter(); to return to the main char...
Dunno if any help, but that's what I came up with your discription...
dont know if this could be the problem, but if your inventory gui is set to "popup mode" it will pause the game, and maybe the clicks arent proccessed(sp?) , and the game could look frozen. if so, you could set the gui to "always on" and write 'GUIOff(yourgui);' in the game_start() function.
For the 'opening a inv item' thing, just write in the Usemode1 interaction (the one that uses cursormode 8) in the inventory item interaction:
(or in the 'any click' interaction, i cant remember if inv. items have usemode1 and usemode2)
if (UsedMode("open")){
//your script, maybe turn off some items and turn on some
}
No, I have script only GUI's, and they work (I have tweaked the on_mouse_click a bit, but it would work anyway) well. The game might froze because of something else... post the inv screen opening scritp so we can see...
Mine is:
if(keycode==9) {
GUIOff(0); // hide statusline, coz the inv has its own
GameGUIOff(); //my own function for turning off all the Menu and so on GUI's
GUIOn(3);
SetGlobalInt(101,1); //so the game automatic set's cursormode 6 and don't let it change off until globalint 101 is 0 again.
}
OK I jus think this is way to KORNfeWZing for me, LOL
i can't even geyt the friggin objects to interact when i click on them, i've tried EVERYTHING.
i even tried "make the Game For me" and that didn;t help
i understand how to Temporaly give the item to someone else. but actualy CLICKIng on them doesn;t seem to want to work.
It sounds like you might be trying to do too much too quickly. Start off by simply using the built-in default inventory window. As you become more comfortable with using AGS, you'll better understand how it works, and have a better chance of writing a custom inventory that you understand, rather than simply having a script handed to you which you probably wouldn't know how to modify.
Ok I Used the Interfae and I quite understand how to use it and modify it. I have a medicie bottle i want to open in Inventory
I've made 3 custom GUI's already. all i need is the inventory to work and I'm in Business.
yeah, the Medicine Bottle is a Key Part in my Adventure
JUmpin Geejosaphatz!
I figured out how to do it!
I just Read:
Q58: HOW-TO: Handling inventory clicks in the script
it helps to REad Stuff!!!!!!!!!!!!!!!!!!!!!!!! :D ;D 8)
Here is My Code:
function on_mouse_click(int button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (button == LEFTINV) {
RunInventoryInteraction (game.inv_activated, GetCursorMode() );
}
else if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
else if ((button == RIGHTINV) && (GetCursorMode() == MODE_USE)) {
RunInventoryInteraction (game.inv_activated, MODE_USEINV);
}
}
why can't I get it to click?
have you deleted the LEFT and RIGHT mouse clicks? if so, any click outside the inventory wont be proccessed. you'll need left, right, leftinv and rightinv mouse clicks for the game, i think
OK, I guess N OTHING I do works.
Ive tried EVERYTHING and i do mean EVERYTHING!
i DONT want the item to be selected when you go to use it.
I want the item to:
WHEN YOU SELECT IT: i want a custom Command (Open) and it will do just that OPEN the bottle and gives the player the lid and the Opened PIll Bottle.
else if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
else if ((button == RIGHTINV) && (GetCursorMode() == MODE_USE)) {
RunInventoryInteraction (game.inv_activated, MODE_USEINV);
}
the first part of this will always get run on RIGHTINV, the second "else if" clause will never happen. Change the order round:
else if ((button == RIGHTINV) && (GetCursorMode() == MODE_USE)) {
RunInventoryInteraction (game.inv_activated, MODE_USEINV);
}
else if (button == RIGHTINV) {
RunInventoryInteraction (game.inv_activated, MODE_LOOK);
}
man Justb forget the whoe THing--
Dont bother that I asked!
It won't do what i want it to do!
That is:
1. Open a CUSTOM inventory Window (that Iv'e done)
2. Be able to INTERACT with the inventory object while its on the inventory Screen
3. be able to select the object and use it.
You mean to tell me after like 4 years of devloping AGS, There is NO WAY to do this? (COME ON!!!!)
4. be able to select stuff on the main screen.
likei said. Until THis Chris guy can allow us to do this.. I am not using AGS!
First of all, Pumaman is "This Chris guy", and you don't have to use AGS, but you'd be missing out on a great program. Everything you listed is possible, though I didn't understand what you meant in number 4. What main screen? Please be more specific.
Now, about the custom inventory, here's a good tutorial:
http://ags.slaveinostudios.com/customize.html
Thi includes selecting the inventory item too. What do you mean by interacting? This is ussually the same as selecting. Do you want this to be something else?
Please clarify what you mean by number 4. Do you mean the main menu? What do you want to select there?
LIke I said BEFORE....
I have a CUSTOM inventory!
I DON'T want the item to get selected so i can use it
i want to select it so i can "OPEN" it and not use it with another item
What the default does is "select it" so i can use with another item
I don't want that!
andc ik can't click on ANYTHING in the game,
Yanow, it would help if you didn't throw a hissy fit at people who were trying to help. Just a thought. ._.
As for the 4 year thing, you go away and code a better engine and come back in 4 years and then rant. Until then, just be grateful you even have AGS.
Ok, I'm still fairly a beginner, but this is what I think you need to do.
Create a sprite for Use/Open and import it. Set this sprite to be the cursor for cursormode 8, which is usermode1. Create a button in your custom inventory and change it's text to "Use". Now in it's properties set it's "Left click" property to "Set cursor mode" and it's "New mode number" to 8.
Go to the inventory items pane, where you have your 'medicine box' item, and create two more items: "Open medicine box" and what you want to be in the box, I presume it's "medicine", if not use something else. Create sprites for these and import them, or use placeholders for now. Now, if for example the "medicine box" is item number 1, "open medicine box" is 2, and "medicine" is 3, put the following script in the "other click on inventory item" interaction for the "medicine box":
LoseInventory(1);
AddInventory(2);
AddInventory(3);
Hopefully this'll work.
For selecting etc follow the tutorial in the link I posted.
P.s. there's no need to use all caps, contrary to what some may think, this makes it harder to read.
:P
edit: I tried this out on an empty game, and something quite strange happened:
I checked "Handle inventory clicks in script" and added the on_mouse_click inventory interaction for left click to use the current mode, and right click to look. I created a quick custom inventory almost identical to the normal one, and created 4 buttons: look, select, use, and ok.
They work fine when it comes to selecting the mode, but when I use any of the modes on the item, it cycles through modes, that is, every time I click, a new mode. (The only interaction I used on the item, in this case the default key, is a "look at" interaction which displays speech.) What I find strangest is that when cycling through the modes, when it reaches the walk mode and I click, it performs the script that happens when you look at the item.
Interestingly, when I turn off "Handle inventory clicks in script" evrything works like a charm. It even looks when I right click! :P
edit2: Ok, I dunno why, but I fixed this by setting the visible option for the GUI to "Popup modal" (I set it to "Normal" before, and turned off the GUI in the game_start funtion).
However now what doesn't work is the select button. It changes the cursor, but nothing happens when I click, that is, the item isn't selected.
And when I uncheck "handle inventory clicks in script" again, it all works, select included.
Hmm..
edit3: Now this is interesting.
It says in the manual that it is currenty immpossible to use the interact with inventory interaction, and yet with the problem I described, when I use the select cursor, it performs the "interact" interaction. I checked this by adding a DisplaySpeech command in the interactions editor, to be run when interacting with the inventory item.
I am very confused now, lol.. Is my computer going crazy? :P
Btw, I did all this with the newest (2.56) version.
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!
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.
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!
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. :)
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 :)