Scripting Trouble

Started by Melee Island Resident, Sat 23/04/2011 15:49:39

Previous topic - Next topic

Melee Island Resident

okay i've got this code here, could someone please explain to me what's wrong with it?


function cGhost_UseInv()
{

  if (player.ActiveInventory == iFlowerPot) {
    dFlowers.Start();
    player.AddInventory(iCode);
    Display ("The Code is now in your inventory");
  }

}

when i use the flower pot on the character it does nothing

Khris

Is the function properly linked?

Try this:

Code: ags
function cGhost_UseInv()
{
  Display("test");
  if (player.ActiveInventory == iFlowerPot) {
    dFlowers.Start();
    player.AddInventory(iCode);
    Display ("The Code is now in your inventory");
  }
}


Does it say "test"?

Also note that dFlowers.Start(); ends up in the queue and the dialog is only started after the function has finished, i.e. the player will get iCode, then the message, then see the dialog.


Melee Island Resident

okay by making this change i've gotten it to show the dialogue

function cGhost_UseInv()
{
  if (player.ActiveInventory == iFlowerPot) {
    dFlowers.Start();
    }
}

but the player still needs to get iCode

Khris

Wait, so now the function is called? So you got it to be linked properly but chose not to mention that, correct? Just trying to get us on the same page here, because other people might look at this thread when they're having a similar problem and wonder why removing commands makes functions get called that previously weren't.

Anyway, you can put standard script commands into dialog scripts, you just need to out a space at the start of the line.

Please read the manual and especially the complete tutorial though first.

Melee Island Resident

// Dialog script file
@S  // Dialog startup entry point
Ghost: Oh my god, you stole Dracule's prized Flower Pot.
Ghost: You Truly are evil
return
@1
Ghost: Of course it does
Ghost: Here it is

player.AddInventory(iCode);
    Display ("The Code is now in your inventory");
  }
stop

i tried it but it gave me an error

am i on the right track at least?

Khris

Like I said, put a space before player.AddInventory(iCode);
Also remove the }, what is it doing there?

And I'd appreciate it if you addressed what I wrote previously and also if SPELL OUT THE ERROR MESSAGE YOU GET in the future.

Melee Island Resident

k done that

Dialog 1(10): Unknown command: player .addinventory(icode). The command may require parameters which you have not supplied.

im sure im doing something really stupid

Khris

Shouldn't it be:

Code: ags
   player.AddInventory(iCode);


Capitalization is important, and there can't be a space before or after the dot.

Melee Island Resident

in the script it's capitalized

and there's no space inbetween the dot

and im still getting the same error

Sephiroth

#10
Quote
andI'm still getting the same error

You seem to have an obvious problem with spelling, even when you're writing a post, you're not using capitals and you forget to put spaces sometimes.

There's nothing wrong with your code, every script command needs a space before, when it's inside the dialog, and the command should be written carefully, when you start to write "player.add" it should pop up a quick window to auto complete your code, it will take care of the spelling for you.

Code: ags

// Dialog script file
@S  // Dialog startup entry point
Ghost: Oh my god, you stole Dracule's prized Flower Pot.
Ghost: You Truly are evil
return
@1
Ghost: Of course it does
Ghost: Here it is

 player.AddInventory(iCode);
 Display("The Code is now in your inventory");

stop


Melee Island Resident

okay i have advanced further and have gotten stuck at a similar problem
// Dialog script file
@S  // Dialog startup entry point
Troll: You can't go in there without the code.
return
@1
Troll: Well what is it then?
    if (player.ActiveInventory == iCode) {
    dTroll2.Start();
   
    else player.Say("I don't know.");
return

Dialog 2(10): Error (line 10): PE04: parse error at 'else'

what exactly am i doing wrong?


Matti

This part:

Code: ags

  if (player.ActiveInventory == iCode) {
    dTroll2.Start();
   
    else player.Say("I don't know.");


should look like this:

Code: ags

  if (player.ActiveInventory == iCode) dTroll2.Start();
  else player.Say("I don't know.");

Dualnames

Code: ags

// Dialog script file
@S  // Dialog startup entry point
Troll: You can't go in there without the code.
return
@1
Troll: Well what is it then?
    if (player.ActiveInventory == iCode)    dTroll2.Start();
    else player.Say("I don't know.");
return


EDIT: Beat by Matti (WTF!)
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)

SMF spam blocked by CleanTalk