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
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'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...
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 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)
I thik it's suppost to be
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:
cEgo.i*Name of Object here* == 0 //I'm not sure of this. May or may not work.
Good luck with your game.Ã, :)
Huw
Still the same error message :inven is not a memebr of Game character
Check my edit. :)
I already checked it, it says cEgo is undefined something (have closed it now)
Hmmmm... What version of AGS are you using? ???
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
Note to self: SPELLCHECK, GODDAMNIT! :|
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... :(
Note that if you do
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:
if (character[GetPlayerCharacter()].inv[18]) { // if player character has ONE OR MORE of inv item 18
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
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?
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.
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.
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.
(http://www.2dadventure.com/ags/runscript.gif)
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
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.
Quote from: strazer on Sun 24/04/2005 22:18:37
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?
I don't use dialog_request
Quote
friend: Well, if that's the way it is...can you make some coffee?
ego: Sure. Give me your coat.
add-inv 18
option-off 3
It seems that somehow I add the item twice, but I can't remember how. So I put
Quote//script for hotspot12: Use inventory on hotspot
LoseInventoryFromCharacter(EGO,18);
LoseInventoryFromCharacter(EGO,18);
and it worked...