inventory is not always removed when it has to.

Started by passer-by, Sat 23/04/2005 18:58:35

Previous topic - Next topic

passer-by

Hi,

When I combine inventory items or use them and want to lose them, they don't always disappear, sometimes they remain in the inventory. I don't have the "don't automativcally lose inventory " checked. I mainly use the ready-made interactions in ags , as I'm useless in scripting. When I say "If player does this, remove item from inventory" and then test the  game , it won't always obey. I tried "before action" "after action" etc... Any help with the least scripting possible??  :(

cp

Ishmael

#1
You might try replacing the "lose inventory" interaction with a runscirpt where you enter:
character[GetPlayerCharacter()].inv[##] = 0;

and replace the ## with the inventory item number...

EDIT: Righto... that's curious, an extra E stroke in...
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.

passer-by

I'm doing something stupid, because now it won't save the game due to a "scripting error", something like "inve is not member of  characters ". I guess I have to leave it until my brains decide to wake up...

Ishmael

Post the code you used, and the complete error message. There's probably a typo somewhere, but I can't tell where just yet...
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.

passer-by

I used it for a hotspot interaction

For character[GetPlayerCharacter()].inve[18] = 0;    and  for  character[GetPlayerCharacter(0)].inve[18] = 0;

it says  "inve' is not a member of "GameCharacter"

It gives me this one to fix:

// script for hotspot12: Interact hotspot
character[GetPlayerCharacter()].inve[18] = 0; 
}

thanks

cp
(knows more about spaceships than about scripting)

Huw Dawson

#5
I thik it's suppost to be

Code: ags

character[GetPlayerCharacter()].inven[18] = 0;


you missed out an "N" - And I think this is better...

cEgo.inven[##] = 0;

As I'm assuming this is a one character game. Change EGO for you char's script name, and the ## for the item number.

edit: After double checking, I made this up:

Code: ags


cEgo.i*Name of Object here* == 0 //I'm not sure of this. May or may not work.



Good luck with your game.Ã,  :)

Huw
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

passer-by

Still the same error message :inven is not a memebr of Game character

Huw Dawson

Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

passer-by

I already checked it, it says cEgo is undefined something (have closed it now)


Huw Dawson

Hmmmm... What version of AGS are you using?  ???
Post created from the twisted mind of Huw Dawson.
Not suitible for under-3's due to small parts.
Contents may vary.

strazer

In AGS v2.62 it's
  character[GetPlayerCharacter()].inv[18] = 0; // player character loses ALL of inv item 18
  LoseInventory(18); // player character loses ONE instance of inv item 18
  LoseInventoryFromCharacter(MAN, 18); // character MAN loses ONE instance of inv item 18

cEgo and the like will only work with the upcoming AGS v2.7.
And there it's
  player.InventoryQuantity[iThing.ID] = 0; // player character loses ALL of inv item iThing
  player.LoseInventory(iThing); // player character loses ONE instance of inv item iThing
  cMan.LoseInventory(iThing); // character MAN loses ONE instance of inv item iThing

Ishmael

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.

passer-by

Quote from: strazer on Sat 23/04/2005 22:13:48
In AGS v2.62 it's
Ã,  character[GetPlayerCharacter()].inv[18] = 0; // player character loses ALL of inv item 18
Ã,  LoseInventory(18); // player character loses ONE instance of inv item 18
Ã,  LoseInventoryFromCharacter(MAN, 18); // character MAN loses ONE instance of inv item 18

cEgo and the like will only work with the upcoming AGS v2.7.
And there it's
Ã,  player.InventoryQuantity[iThing.ID] = 0; // player character loses ALL of inv item iThing
Ã,  player.LoseInventory(iThing); // player character loses ONE instance of inv item iThing
Ã,  cMan.LoseInventory(iThing); // character MAN loses ONE instance of inv item iThing


It works for some items but not all. Does the fact that I want the action to happen only when character has this inventory item keeps the script from running? I mean "If player has item, things happen and then item disappears" but if item disppears then conditional is invalid anyway?I have 2.62 by the way and although I have more characters none of them has an inventory.


I'll go and buy my character a freight train... :(

strazer

Note that if you do

Code: ags

  if (character[GetPlayerCharacter()].inv[18] == 1) { // if player character has EXACTLY ONE inv item 18


the condition will only be true if the character has exactly one inv item 18.
So if you picked up inv item 18 two times or more, the following code won't be executed.

To be on the safe side, do it like this:

Code: ags

  if (character[GetPlayerCharacter()].inv[18]) { // if player character has ONE OR MORE of inv item 18

passer-by

Quote from: strazer on Sun 24/04/2005 12:00:28

So if you picked up inv item 18 two times or more, the following code won't be executed.
It's picked during a dialogue , which I run once...

From all the things I tried this one
LoseInventoryFromCharacter(EGO, 18);  seems to work

strazer

Strange. There must be something wrong with your script or where you've put it.
Can you please restate your problem (what should happen, what does happen) and post the actual code you're using?

passer-by

Quote from: strazer on Sun 24/04/2005 13:02:27
Strange. There must be something wrong with your script or where you've put it.
Can you please restate your problem (what should happen, what does happen) and post the actual code you're using?

Something wrong with my script?! Can't be!Ã,  :P
Ã,  // script for hotspot12: Use inventory on hotspot
LoseInventoryFromCharacter(EGO, 18);Ã, 

This is the one that worked when I tested it.

I put it in the interaction editor "if character does this, run script" . I don't really mess with global or room scripts yet. :-[Ã,  I tried the other codes but although all the other interactions worked (another hotspot was enabled, an object was switched on, 1 point was added) the character still carried the item throughout the game.
The "remove an item from the inventory" interaction works fine for mostÃ,  items but I just can't make it remove others or it sometimes does sometimes doesn't.

strazer

Hm, if this "Run script" action isn't a child action of an interaction editor conditional, using any inv item on hotspot 12 will remove one instance of inv item 18 from EGO's inventory. That doesn't make a lot of sense.

I still don't quite know what you're trying to do.
Please describe in more detail what you want to happen in the game so we can give a step-by-step solution.
I don't mean "I want to remove an item" but rather something along the lines of "If the player uses inv item A on hotspot 1, item A should be removed from the player character's inventory and the player character should say 'Hello'" or something.

passer-by

Quote from: strazer on Sun 24/04/2005 18:19:56
Hm, if this "Run script" action isn't a child action of an interaction editor conditional, using any inv item on hotspot 12 will remove one instance of inv item 18 from EGO's inventory. That doesn't make a lot of sense.

I still don't quite know what you're trying to do.
Please describe in more detail what you want to happen in the game so we can give a step-by-step solution.
I don't mean "I want to remove an item" but rather something along the lines of "If the player uses inv item A on hotspot 1, item A should be removed from the player character's inventory and the player character should say 'Hello'" or something.


In a dialogue, character gets her friends coat (item 18). Then she hangs it (hotspot 12). It should appear in the room (object 3 on in my case) and disappear from inventory. When I use item on hotspot, object is switched on and coat appears and 1 point is added, but character still has theÃ,  coat in theÃ,  inventory.



I put many codes in script
character[GetPlayerCharacter()].inv[18] = 0;Ã,  Ã,  andÃ,  LoseInventory (18) ; and LoseInventoryFromCharacter(EGO, 18);
I test it once , it usually works , I close and test it again,Ã,  it doesn't.

editÃ, 
LoseInventoryFromCharacter(EGO,18);
works if I repeat the action, I mean if I hang the coat twice.
character[GetPlayerCharacter()].inv[18] = 0;Ã,  doesn't work at all.

I could find some way to dodge it (eg I made character lose her mobile because I couldn't fix a dialogue) but this happens in other rooms too and I can'tÃ,  go on like that for every single item. Or should I? :-\

cp

P.S."Why doesn't the friend go and hang her coat herself FFS?!"Ã,  :P


strazer

Hm, looks okay to me.

Quote
I test it once , it usually works , I close and test it again,  it doesn't.

That's hard to believe if you do the same things both times. Very strange.

QuoteLoseInventoryFromCharacter(EGO,18);
works if I repeat the action, I mean if I hang the coat twice.

That would indicate that you have the coat twice in your inventory (as a single item).

Do you directly add the inv item via a dialog script command or do you do it via dialog_request?
Could you please post the dialog script and the dialog_request function in case you use it?

Quote
character[GetPlayerCharacter()].inv[18] = 0;  doesn't work at all.

Do you change player characters somewhere?
Does
  character[EGO].inv[18] = 0;
work?

If all else fails, you could upload the game for us to take a look at.

SMF spam blocked by CleanTalk