Error running script: Too few parameters passed to DoAttack function - only 3 passed, but 4 expected

Hello. I am new to this program.
I am taking my first steps and I am following the tutorial Zombie apocalypse.
But I get that error when I attack the zombie without any equipped weapon.
How can I solve that?
Thank you very much.


Look for places where DoAttack is called in your scripts.

Is there one that only has 3 parameters? That's the problem.


Hello.

As mrangel says, you have code in your game that is only passing three parameters to DoAttack().

This is because of the way the tutorial leads you through the process.

For the first 3/4 of that tutorial page, all the code with DoAttack() only has 3 parameters. So, if you copied and pasted all of that, you have to go back and change it all after you modify DoAttack() to allow for weapons, which happens towards the end of that page of the tutorial.


FROM THE TUTORIAL

Finally, we need to change other places where we used DoAttack so they have the new parameter (which should be false). In the attack command, the last but one line now needs to be:

DoAttack (player, player.equipped, object, false)

In the turn script, the sixth line needs to be this:

DoAttack (obj, obj, player, false)

Finally, the tenth line of SpawnZombie (and any other spawn functions) should be changed to:

obj.displayverbs = Split("Look at;Attack;Shoot", ";")

PERSONAL NOTE

While following one of The Pixie's tutorials, when I get to a point like this -- where I have to go back and change code I've already written, I get a little frustrated.

...but I do definitely learn (and remember) more things from Pixie's tutorials than any other tutorials I've ever followed.

So, I bet you think I'm about to say, "the good outweighs the bad," but no. I think the process Pixie leads us through is the very thing that makes Pixie's tutorials work so well.

The process seems a bit redundant (not quite the word I'm looking for), but that's how we learn; is it not?

Repetition works.

Repetition works.

Plus, having to go back through and update bits of your code after changing something is a big part of coding.


Thank you very much.
Thanks to your help I have been able to learn a little more.
Excuse me for my english.
I don't know how to speak this language.


I usually get that error when the attack command isn't working...
Oh, it looks like you fixed your problem. Never mind.
Here is the code I use:

if (not HasBoolean(object, "dead")) {
  msg ("That's not something you can attack.")
}
else if (object.dead) {
  msg ("That one is already dead.")
}
else {
  if (player.equipped = null) {
    DoAttack (player, player, object, false)
    attackturnscript
  }
  else {
    DoAttack (player, player.equipped, object, false)
    attackturnscript
  }
}

Thank very much, jmnevil54.
I'm going to test your code because it hadn't fixed the problem yet.


Log in to post a reply.

Support

Forums