Use Item on clicking, not hotspot or npc

Started by Daddyman, Sun 12/06/2005 23:35:09

Previous topic - Next topic

Daddyman

Hello guys, i'm working on a simple yet funny Adventure game, and AGS is truly awesome if amazing,
i have absolutely no idea how to script at all, so bear with me here please :)

My problem is this:

In the scenery there's a ALIEN ARTIFACT, i picked it up, put in the inventory, it shows up fine and dandy,
what i wanna do is when i open the inventory by clicking the bag, and then click the item in there, i want it to USE it , not USE ON ANOTHER ITEM....

for example, i want to click that item in the inventory and it sends me to another room,
i don't want to take the item, use it on a HOTSPOT or Another object ...simply click the item and it uses it.

that's it.

How in the name of the mighty gods to do that?

I read the help, and the site and cannot find reference, and if this question was asked before, I AM TOTALLY SORRY....just help me please.

Thank you eternally. :)

monkey0506

For that, try going to the interaction editor and under "Use item" redefining what it does.  You may have to check "Inventory clicks handled in script" to do this.  Not 100% sure about this though.

ilSilente

#2
Mmm... in "General settings" you have to check the option "Handle inventory clicks in script", then you have to manually handle the inventory interactions.

Look in the manual the chapter Scripting -> Inventory item functions and properties -> RunInteraction (Inventory)

EDIT:
Also, check Reference -> Scripting event reference, and look for on_mouse_click(MouseButton button). You will discover eMouseLeftInv and eMouseRightInv...

Daddyman

Thanks will check it out...although i don't have any idea what goes where in scripts.

i'll be back in a few.

Babar

since it was brought up here, I thought I might ask that the Inventory GUI in the default template have the "Interact" button included in it. I realise it is simple to do, but it would be most helpful to many of us n00bs
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Daddyman

I'm having a problem guys...

I checked HANDLE IN SCRIPT option, then went to the INVENTORY item (7) and interaction, add SCRIPT and added this :

if (button == 2)
  RunInventoryInteraction(game.inv_activated, GetCursorMode()); 

when i run the game, it tells me LINE 127 is wrong....wanna fix now?  LOL

how or where to add the script?

My inventory got to things...the EYE (to look at) and the ARROW (it grab an inventory to use on something)....

hmmmmm.....i'm puzzled.....can you please give it to me step by step, sorry for the trouble.

Daddyman

note: i cut n paste wrong earlier , if (button == 2) , when it had to be

if (button == LEFTINV)
  RunInventoryInteraction(game.inv_activated, GetCursorMode()); 


i still get the same error.


Ashen

#7
1. You can edit your posts, instead of double posting.
EDIT: It's the 'Modify' link, top-right of the post.

2. That script needs to go in the on_mouse_click section of the global script, not in the inventory item bit, where it sounds like you've got it.

However, an easier way would probably be to leave Handle clicks in script unchecked, and add a button to use a different cursor mode (e.g. 'Talk', or one of the 'Usermode's) for directly using items in the inventory. Just a thought.
I know what you're thinking ... Don't think that.

Daddyman

Sorry for double-posting, didnt mean it, i can't see where's the EDIT button to edit my post LOL!!!!!

Ok, will try what you said , i think i understood it and might work.

will get back to you in a few, gotta love AGS :D

Akumayo

Daddyman, I have a simple solution that doesn't require any scripting at all.  Simply give the player another inventory item that is a picture of the word "Use" (or examine or whatever) then the player can highlight the ALIEN ARTIFACT and use it on the USE item.
"Power is not a means - it is an end."

Daddyman

Daddyman, I have a simple solution that doesn't require any scripting at all.  Simply give the player another inventory item that is a picture of the word "Use" (or examine or whatever) then the player can highlight the ALIEN ARTIFACT and use it on the USE item.
----------------------------------

Can you tell me how to do that please?

Step by step.

How do i give a picture of USE?   where , how ...

i managed to have the artifact use it on itself and it does what i want, but i want to make it that when you click it ,it don't GRAB it, it just run the command directly without having to grab and use on itself.

You seem to understand what i'm talking about. :)

Akumayo

Hmm....If you want to do it without scripting, the game will -have- to grab it.  But I think the "use" item should work.  Simply draw a 10x10 sprite of the word "use".  Then make an inventory object (we'll call it "use") and assign the "use" sprite to it.  Then make an interaction in your script.  I think it's a conditional "If use inventory on inventory" or something like that (i haven't used them in a long time).  In the "if use inventory on inventory" function assign it so that it is inventory ALIEN ARTIFACT used on USE.  Then put whatever other code you need after that.

(if you need more help, pm me)
"Power is not a means - it is an end."

SMF spam blocked by CleanTalk