Handleing Objects on a Script

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

Previous topic - Next topic

Dr Snark

 
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.


Pumaman

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.

Dr Snark

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.




Dr Snark



No one can help?

I guees my game will be "put off" for a while.

Ishmael

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

Proskrito

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
}

Ishmael

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.
}
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.

Dr Snark

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.



Pumaman

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.

Dr Snark

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



Dr Snark

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)

Dr Snark

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?

Proskrito

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

Dr Snark

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.


Pumaman

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

Dr Snark

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!

Ginny

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

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.

Ginny

#19
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.
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

SMF spam blocked by CleanTalk