Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: aRno on Wed 14/10/2009 03:08:38

Title: The need to use a Inventory item 2 times [solved]
Post by: aRno on Wed 14/10/2009 03:08:38
Already searched the forums but haven't found a clue, sorry if I oversaw something...

I want the character to use a skull two times to crack open a window.
On first usage the window breaks a bit and after the second use it cracks completely open, so now the charakter can do something with it (doesn't matter here what)...
How do I put that in?

the code for this:


function WindowFull_UseInv()
{
 if (cNevrly.ActiveInventory == iSkull) {
     cNevrly.Walk(857, 493, eBlock, eWalkableAreas);
     WindowFull.Visible = false;
     WindowHalf.Visible = true;
     cNevrly.Say("Great now I made a small hole in my Window.");
     cNevrly.Say("And I even don't know why.");
     cNevrly.Say("Maybe I should do it again...");
 }



WindowFull is the unbroken window
WindowHalf is the slightly broken Window
and WindowBroken is obviously the broken Window...

I expect it to be a check the usage of the item script, but I, shame on me, have no idea how to do it...

Thanks a lot for your help...

:insert cookie smiley here:
Title: Re: The need to use a Inventory item 2 times
Post by: monkey0506 on Wed 14/10/2009 03:11:32
Well when you're using the skull on the "full" unbroken window, you're then turning the full window off and the half-broken window on. So the next time the player interacts with the skull on the window, they're using the skull on the half-window. So the same way you set up this first part of the interaction, do that for the half-window, only there turning off the half-window and turning on the broken window.

So for example you would want to define the function for WindowHalf_UseInv (make sure it's properly linked in the events pane!), somewhat like this:

function WindowHalf_UseInv()
{
  if (cNevrly.ActiveInventory == iSkull) {
    // ...
    WindowHalf.Visible = false;
    WindowBroken.Visible = true;
    cNevrly.Say("Now the window's completely broken!");
  }
}
Title: Re: The need to use a Inventory item 2 times
Post by: aRno on Wed 14/10/2009 03:13:17
 :-X

I could shoot myself in the knee for beeing so stupid....
Goddamnit...

Thanks a lot monkey...

Maybe I should make some breaks in my coding time...

In deep sorrow,
aRno
Title: Re: The need to use a Inventory item 2 times [solved]
Post by: monkey0506 on Wed 14/10/2009 03:14:40
No worries, all of us overlook simple things at times. Let us know if you have any other problems. ;)
Title: Re: The need to use a Inventory item 2 times [solved]
Post by: Khris on Wed 14/10/2009 03:47:05
Another way would be to use a single object and check for/change its graphic slot.

  if (cNevrly.ActiveInventory == iSkull) {
    cNevrly.Walk(857, 493, eBlock, eWalkableAreas);
    if (Window.Graphic = full_window_sprite_number) {
      Window.Graphic = cracked_window_sprite_number;
      cNevrly.Say("Great now I made a small hole in my Window.");
      cNevrly.Say("And I even don't know why.");
      cNevrly.Say("Maybe I should do it again...");
    }
    else if (Window.Graphic = cracked_window_sprite_number) {
      Window.Graphic = broken_window_sprite_number;
      cNevrly.Say("I smashed the window.");
    }
    else {
      cNevrly.Say("No.");
    }
  }