Label message second time object [SOLVED]

Started by LupaShiva, Sun 29/08/2010 19:28:48

Previous topic - Next topic

LupaShiva

Ok i wanted to create a script that show a message in a label when i take an object and dissapears after few seconds but when i click again in the object i wanted to do another script because already got the object, but it always show the label saying "new item taken".


function hSacoLixo_Interact()
{
 if (cJake.HasInventory(iPills)){
 cJake.Say("There's nothing more there.");
 GiveScore(-5);
 GUITexto.Text = ("");}
 else
 cJake.Say ("I found some Sleeping pills.");
 GUITexto.Text = ("New item taken.");
 cJake.AddInventory (iPills);
 GiveScore(5);
 SetTimer(1, (5*40));
 
}


Thank you for the help

Chrille

#1
I think you're missing some brackets. Your current code does nothing for the 'else' condition and runs the code below it every time. Here's how the code should look:

Code: ags

function hSacoLixo_Interact()
{
  if (cJake.HasInventory(iPills)){
  cJake.Say("There's nothing more there.");
  GiveScore(-5);
  GUITexto.Text = ("");
  }
  else {
  cJake.Say ("I found some Sleeping pills.");
  GUITexto.Text = ("New item taken.");
  cJake.AddInventory (iPills);
  GiveScore(5);
  SetTimer(1, (5*40));
  }
}
GASPOP software
http://www.gaspop.com

LupaShiva

Yeah it works but now it keep taking 5 from my score  :(

GarageGothic

Because you subtract five points from the score with the "GiveScore(-5);" call. Unless you want to punish the player for clicking the hotspotagain after picking up the pills that line shouldn't be there at all.

Also, the way its scripted now, the player will be able to go back and pick up more pills once he uses/loses them. I don't know if that's intentional.

Dualnames

Code: ags

function hSacoLixo_Interact()
{
  if (cJake.HasInventory(iPills)){
  cJake.Say("There's nothing more there.");
 if (Game.DoOnceOnly("pillscore")) { 
    GiveScore(-5);
  }
  GUITexto.Text = ("");
  }
  else {
  cJake.Say ("I found some Sleeping pills.");
  GUITexto.Text = ("New item taken.");
  cJake.AddInventory (iPills);
  GiveScore(5);
  SetTimer(1, (5*40));
  }
}


That should do it.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

LupaShiva


SMF spam blocked by CleanTalk