The need to use a Inventory item 2 times [solved]

Started by aRno, Wed 14/10/2009 03:08:38

Previous topic - Next topic

aRno

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:

Code: ags

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:

monkey0506

#1
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:

Code: ags
function WindowHalf_UseInv()
{
  if (cNevrly.ActiveInventory == iSkull) {
    // ...
    WindowHalf.Visible = false;
    WindowBroken.Visible = true;
    cNevrly.Say("Now the window's completely broken!");
  }
}

aRno

 :-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

monkey0506

No worries, all of us overlook simple things at times. Let us know if you have any other problems. ;)

Khris

Another way would be to use a single object and check for/change its graphic slot.

Code: ags
  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.");
    }
  }

SMF spam blocked by CleanTalk