Difference between 'game.inv_activated', and 'player.ActiveInventory.ID' ?

Started by Monsieur OUXX, Sun 17/03/2013 17:47:05

Previous topic - Next topic

Monsieur OUXX

Hi,

I'm having a look at a script I didn't write myself. The game is a 9-verb game with a "Use" action and a "Give" action.

- When the scripter wants to test what object the player is about to "use" on another object (to update the status bar), he checks the value of player.ActiveInventory.ID.
- However when he wants to test what object the player is about to "give" to a NPC, he checks the value of 'game.inv_activated'.

I don't get why he doesn't always check the value of player.ActiveInventory.ID. Is there a fundamental difference between Using and Giving?
 

Crimson Wizard

According to the engine code, the 'game.inv_activated' is not a currently selected item, it is an item that was clicked upon in the inventory window (last).
Of course, under certain conditions, game.inv_activated == player.ActiveInventory.ID, but I doubt it is wise to rely on that.

Monsieur OUXX

Quote from: Crimson Wizard on Sun 17/03/2013 18:46:42
According to the engine code, the 'game.inv_activated' is not a currently selected item, it is an item that was clicked upon in the inventory window (last).
Of course, under certain conditions, game.inv_activated == player.ActiveInventory.ID, but I doubt it is wise to rely on that.

Yeah I've read that too, but I can't think of a scenario where they would have different values.
 

Crimson Wizard

They will have different values, if you set player.ActiveInventory in script.
game.inv_activated is updated only when player clicks on inventory item with mouse.

Khris

Quote from: Monsieur OUXX on Sun 17/03/2013 18:52:47Yeah I've read that too, but I can't think of a scenario where they would have different values.
I can; they only have the same value when you have just clicked with an active item on itself. In every other case, they are not the same.

Whenever you "use x on y", x is player.ActiveInventory and y is inventory[game.inv_activated].

Monsieur OUXX

Quote from: Khris on Sun 17/03/2013 19:25:51
Whenever you "use x on y", x is player.ActiveInventory and y is inventory[game.inv_activated].

Hmmmmmmmm... OK... I believe you but I fail to picture it in my head.
Because as soon as you click on an inventory item, doesn't player.ActiveInventory take the value of game.inv_activated?

EDIT: I'm answering my own question : it probably doesn't. But in that case, when does player.ActiveInventory immediately take the value of game.inv_activated ? Only when the mouse cursor is 'eModeInteract' ?
 

Khris

It depends on how you handle inventory clicks.
game.inv_activated is supposed to be used in on_mouse_click / eMouse???Inv to find out the item under the mouse.

When you are picking up an item from your inventory, then usually yes, player.ActiveInventory gets set to inventory[game.inv_activated].

But using item A on item B doesn't change the active item, does it? And clearly, the active item has no relation to the item being clicked on. I don't know how else to put it.

If I slap you, do we become the same person?

Monsieur OUXX

Quote from: Khris on Sun 17/03/2013 20:57:27
If I slap you, do we become the same person?

I guess we'll never know ;) (Never say never ;) )
Thanks for all the explanations! Now I should just read the script again and again until I understand. I'm sure that will eventually happen. At some stage. :D
 

Khris

The template is still based on the real mess that was Maniac Mansion Deluxe for 2.6, without special functions (the reason for Give being so badly implemented).
I've been wanting to rewrite it from scratch since forever, but let's face it, nobody is really using the classic 9verb GUI any longer.

Monsieur OUXX

I'm not sure if the script I'm reading here is the 9-verb template or if it's written from scratch. I see some very odd things in the code. Actually the reason why I'm trying to understand it is because I'm splitting everything into separate module scripts.
 

Monsieur OUXX

Alright, I have to confess I'm still struggling. So I'm asking the question in the revert order:

Imagine the following scenario :
- I have clicked on the "Give" action button
- Then I have clicked on one of the objects in my inventory
- Now I'm just moving the mouse on the screen, without clicking anything.

In every game loop during that final stage, isn't 'game.inv_activated' the same as 'player.ActiveInventory.ID' ?
When will they become different?
 

Crimson Wizard

Quote from: Monsieur OUXX on Mon 18/03/2013 15:03:42
Imagine the following scenario :
- I have clicked on the "Give" action button
- Then I have clicked on one of the objects in my inventory
- Now I'm just moving the mouse on the screen, without clicking anything.

In every game loop during that final stage, isn't 'game.inv_activated' the same as 'player.ActiveInventory.ID' ?
I guess they are same in this case, if clicking on inventory item will make it selected - that is.

Quote from: Monsieur OUXX on Mon 18/03/2013 15:03:42
When will they become different?
They may become different if
a) clicking on inventory item does not select it as player's active item;
b) player.ActiveInventory was set by script command.

Monsieur OUXX

OK thanks.

In this script I don't think there is any good reason for using 'game.inv_activated' for the "give" action and 'player.ActiveInventory.ID' for the "use" action, except messing with my head.
 

SMF spam blocked by CleanTalk