Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Question about item amount  (Read 4046 times)

0 Members and 1 Guest are viewing this topic.

benkovici

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 23
    • View Profile
Question about item amount
« on: February 11, 2009, 03:53:09 PM »

Hello again!

I have a trouble with item amount. In my game the actor must collect 6 pieces of an item called "dead_memory". The problem is that the amount of the item doesn't increase. It displayes always amount "1".
Here is the code written in items.items:

ITEM
{
   CURSOR_COMBINED = TRUE
   CAPTION = "dead memory"
   NAME = "dead_memory"
   SPRITE = "items\dead_memory.sprite"
   CURSOR = "items\dead_memory.sprite"
   SCRIPT = "items\dead_memory.script"
   FONT = "fonts\outline_white.font"
   
    DISPLAY_AMOUNT = TRUE
   AMOUNT_ALIGN = right
   AMOUNT_OFFSET_x = 7
   AMOUNT_OFFSET_Y = 36
}
----------------------
And the code written in items\dead_memory.script:

var DeadMemoryItem = Game.GetItem("dead_memory");
DeadMemoryItem.Amount = DeadMemoryItem.Amount + 1;
--------------
Tell me please what am I doing wrong?
Logged

Birdline

  • Supporter
  • Occasional poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 57
    • View Profile
    • Birdline Web Site
Re: Question about item amount
« Reply #1 on: February 11, 2009, 04:39:48 PM »

If you want to interact with the item in the inventory,
then in the dead_memory.script, you should only have :
on "LeftClick"
{
  Game.SelectedItem = "dead_memory";
}

The other code you wrote:
var DeadMemoryItem = Game.GetItem("dead_memory");
DeadMemoryItem.Amount = DeadMemoryItem.Amount + 1;
must be in the object's script.
(I mean the object that when clicked gives the item)
(Of course the code must be in "LeftClick")

Spyros

benkovici

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 23
    • View Profile
Re: Question about item amount
« Reply #2 on: February 11, 2009, 06:36:42 PM »

Thanks a lot it worked!!!!!!!!!!!!!!!!!!!!!

But I have another little question.
I would like that only when the amount of item "bone" reaches 3 the actor  could be able to enter a scene. Till then when he enters this scene the game will always change to previous scene. This is the code I wrote in scene.init of that scene:

if(!StateGraveyard_exit.Visited)
{
  StateGraveyard_exit.Visited = true;

  // this is our first visit in this scene...
  Game.Interactive = false;
  global FirstVisit = true;//it's for bone to be taken in another scene
  Sleep(500);
  var BoneItem = Game.GetItem("bone");
  if(Game.IsItemTaken("bone") && BoneItem.Amount == 3) actor.Talk("Now I can distract his attention");

  else if(!Game.IsItemTaken("bone"))
  {
   Sleep(1000);
   actor.Talk("I'd better go away");
   Sleep(300);
   actor.TurnTo(DI_DOWN);
   Game.ChangeScene("scenes\Bizzare_graveyard\Bizzare_graveyard.scene");
  }
   Game.Interactive = true;
}
---------------
Help me please!
Logged

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: Question about item amount
« Reply #3 on: February 11, 2009, 07:35:45 PM »

Well, if I follow you, for one thing, you need an || (or) condition to test for bone item taken less than 3. 

else if((!Game.IsItemTaken("bone") || (BoneItem.Amount < 3))

Did you try that?  Do you get a script error or it just doesn't work?

Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

benkovici

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 23
    • View Profile
Re: Question about item amount
« Reply #4 on: February 12, 2009, 01:23:48 PM »

Thanks for trying to help me! I solved it myself. The whole code I put after:

// here comes the stuff which initializes the scene

and it worked!!!!
« Last Edit: February 12, 2009, 01:52:33 PM by benkovici »
Logged
 

Page created in 0.049 seconds with 21 queries.