Once again I come to you all with a easy problem that I can’t solve. :-[
In my game the player starts with 3 things. When he has loosed all items the game is over.
But I gets this: Error: type mismatch: cannot convert ‘InventoryItem*’ to ‘int’
This is what I have tried:
function room_RepExec()
if ((player.InventoryQuantity[iRuberband_1]==0)&&(player.InventoryQuantity[iRubberband_2]==0)&&(player.InventoryQuantity[iRubberband_3]==0))
{
player.ChangeRoom(8, 0, 0);
}
When that didn’t work I put in
// main global script file
int player.InventoryQuantity[3];
but that didn’t help. :(
You can replace this with:
function room_RepExec()
if ((player.HasInventory(iRubberband_1)) &&(player.HasInventory(iRubberband_2)) &&(player.HasInventory(iRubberband_3))) {
player.ChangeRoom(8, 0, 0);
}
Quote from: Dualnames on Sat 10/04/2010 10:43:16
You can replace this with:
function room_RepExec()
if ((player.HasInventory(iRubberband_1)) &&(player.HasInventory(iRubberband_2)) &&(player.HasInventory(iRubberband_3))) {
player.ChangeRoom(8, 0, 0);
}
But isnt that if the player got all things? I want the player to change room when he loose all the 3 items. ???
Oh, right.
function room_RepExec()
if ((player.HasInventory(iRubberband_1)==false) &&(player.HasInventory(iRubberband_2)==false) &&(player.HasInventory(iRubberband_3)==false)) {
player.ChangeRoom(8, 0, 0);
}
Thanks! that worked for me! :D
Good to know, I misread your post at first, that's why the code I originally posted would word exactly opposite from what you wanted. I suggest you read a little about the function:
bool character.HasInventory(InventoryItem*)
because it's tremendously useful. ;)
Just to elaborate a bit:
You can use
if (!player.HasInventory(iRubberband_1) && ...
(Note the "!", signifying "not")
Alternatively, .InventoryQuantity needs an int as index; you can get that by appending ".ID":
if ((player.InventoryQuantity[iRubberband_1.ID] == 0) && ...
Quote from: Khris on Sat 10/04/2010 11:13:16
Just to elaborate a bit:
You can use if (!player.HasInventory(iRubberband_1) && ...
(Note the "!", signifying "not")
Alternatively, .InventoryQuantity needs an int as index; you can get that by appending ".ID": if ((player.InventoryQuantity[iRubberband_1.ID] == 0) && ...
Aha, so it was the "ID"and the right int that I was missing. Good to know for the future, thanks.