Quick Question About ThePixie's Zombie game

I'm using ThePixie's Zombie Game's code for my Pokemon game. I'm trying to get the attack descriptions to work. I keep getting an error that says the function Attack Report can't replace something, and something about a string. My game has this for example:

this.critdesc = player.equipped.name + " tackles the #target# and hits hard (#hits# hits)!"
this.attackdesc = player.equipped.name + " tackles the #target# (#hits# hits)."
this.missdesc = player.equipped.name + " tackles #target# but entirely misses."

Example: Chikorita tackles the target and hits hard (30 hits)!

ThePixie's game has this:

player.critdesc = "You attack #target# with your bare hands and get a critical (#hits# hits)."
player.attackdesc = "You attack #target# with your bare hands and hit (#hits# hits)."
player.missdesc = "You swing wildly and entirely miss #target#."

Attack Report looks like this.

s = Replace(s, "#Attacker#", CapFirst(GetDisplayAlias(attacker)))
s = Replace(s, "#attacker#", GetDisplayAlias(attacker))
s = Replace(s, "#Target#", CapFirst(GetDisplayAlias(target)))
s = Replace(s, "#target#", GetDisplayAlias(target))
s = Replace(s, "#hits#", "" + hits)
msg (s)

I just need the game to work without errors. Please help.


What is the error message?

And can you link to your complete game so that we can see those pieces of code in context? I'd guess that if there's an error in one of the Replace lines, then s, attacker, target, or hits aren't what they're supposed to be. So can we see where those variables are coming from?


Error Running script: Error compiling expression 'Replace (s, "#Attacker#", CapFirst(GetDisplayAlias(attacker)))':
FunctionCallElement: Could not find function (Replace (Object;String,String)'

Game here. http://textadventures.co.uk/games/view/5jllte-m4e2e2whw4gf5jq/pokemon-type-harley-johto-and-sinnoh


I'm looking over the zombie game now, and it sets the values of attackdesc/critdesc/etc in initialisation scripts.

Unless you've moved that code to somewhere else, these lines would cause a problem:

this.critdesc = player.equipped.name + " tackles the #target# and hits hard (#hits# hits)!"
this.attackdesc = player.equipped.name + " tackles the #target# (#hits# hits)."
this.missdesc = player.equipped.name + " tackles #target# but entirely misses."

Because it would be looking at the value of player.equipped before the game starts. Probably not what you want.

Without seeing more of your game, this is just a guess. But maybe you could change those lines to:

this.critdesc = "#Equipped# tackles the #target# and hits hard (#hits# hits)!"
this.attackdesc = "#Equipped# tackles the #target# (#hits# hits)."
this.missdesc = "#Equipped# tackles #target# but entirely misses."

And then change the code in AttackReport to:

if (HasObject (attacker, "equipped")) {
  equipped = GetDisplayAlias(attacker.equipped)
}
else {
  equipped = GetDisplayAlias (attacker)
}
s = Replace(s, "#Equipped#", CapFirst(equipped))
s = Replace(s, "#equipped#", equipped)
s = Replace(s, "#Attacker#", CapFirst(GetDisplayAlias(attacker)))
s = Replace(s, "#attacker#", GetDisplayAlias(attacker))
s = Replace(s, "#Target#", CapFirst(GetDisplayAlias(target)))
s = Replace(s, "#target#", GetDisplayAlias(target))
s = Replace(s, "#hits#", "" + hits)
msg (s)

so that the value of player.equipped is handled something like the other variables in the game.

Although this is old code; all the #Attacker# stuff could be done more easily using text_processor_vars if you're using a recent version of Quest.


I tried your suggestion. Same error.

I think I'll just stop AttackReport from being called in DoAttack. I just left it the same because I feared glitches, but I don't think there will be glitches if I remove it.


Nevermind, I'm still having the same problems. I'm up for suggestions.


Game here. http://textadventures.co.uk/games/view/5jllte-m4e2e2whw4gf5jq/pokemon-type-harley-johto-and-sinnoh

OK, as soon as the game starts you have a bunch of error messages:

Error running script: Invalid variable name '' in '='
Error running script: Error compiling expression 'player.equipped.name + " smash the spade down on #target# (#hits# hits)."': Object reference not set to an instance of an object.
Error running script: Error compiling expression 'player.equipped.name + " tackles the target# and hits hard (#hits# hits)!"': Object reference not set to an instance of an object.
Error running script: Error compiling expression 'player.equipped.name + " tackles the target# and hits hard (#hits# hits)!"': Object reference not set to an instance of an object.
Error running script: Error compiling expression '"#attacker# struggles hard, and hits hard " + player.equipped.name + "(#hits# hits)!"': Object reference not set to an instance of an object.
Error running script: Error compiling expression '"#attacker# tackles the " + player.equipped.name + "and hits hard (#hits# hits)!"': Object reference not set to an instance of an object.
Error running script: Error compiling expression '"#attacker# uses twister on " + player.equipped.name + "and gets a critical hit (#hits# hits)!"': Object reference not set to an instance of an object.
Error running script: Error compiling expression '"#attacker# gives a well placed scratch on " + player.equipped.name + "(#hits# hits)."': Object reference not set to an instance of an object.
Error running script: Error compiling expression '"#attacker# shoots gust at " + player.equipped.name + "and get a critical hit #hits# hits)!"': Object reference not set to an instance of an object.

These errors could be causing more errors later on, so you need to start by fixing them.

The first one is because at the bottom of your "start" script, you have an = on a line by itself. You should remove that.

The rest of the messages are because you are trying to make the attack messages for all your pokemon include player.equipped.name - which isn't set to anything at the point where the Pokemon are created.

So, your line: this.attackdesc = player.equipped.name + " tackles the #target# (#hits# hits)." needs to be fixed. Here's a few alternatives I could think of:

  1. As I think those messages will only be printed when that pokemon is equipped, use 'this':
    this.attackdesc = this.name + " tackles the #target# (#hits# hits)."

  2. Hard-code the messages (each pokemon has its own copy of these lines, so there's no need to use a variable at all)
    this.attackdesc = "Cyndaquil tackles the #target# (#hits# hits)."
    and a similar message for each of the others

  3. Use the text processor
    this.attackdesc = "{=player.equipped.name} tackles the #target# (#hits# hits)."
    This makes it use the value of player.equipped.name when the message is printed, rather than when the object is created.

  4. Add an #equipped# parameter, like I previously suggested.


The this.name thing worked. Thank you.


Okay, so different problem. The description for the Pokemon's attack is working fine and well. The description for the enemy Pokrmon's attack either doesn't show up, or the

Error Running script: Error compiling expression 'Replace (s, "#Equipped#", CapFirst(GetDisplayAlias(equipped)))':
FunctionCallElement: Could not find function (Replace (Object;String,String)'

Error shows up. I'm hoping it's just update lag again, like the times I broke my entire game by messing with the commands. I'm not messing with commands though. I can refresh and publish my game again, and see if that helps.

I'm also wondering why there's an error that says:

Error running script: Error compiling expression 'this': Unknown object or variable 'this'

It wasn't there before Quest 5.8. Or maybe Quest 5.7. But now it's here.

It could all just be lag, I don't know.
My game is really slow as well, but it does that when I have more than 4 tabs open. Just thought I'd mention it, it might mean something.

-+-
blah

Here's the code for the starter/main Pokemon attack description. It works.

this.critdesc = this.name + " tackles the #target# and hits hard (#hits# hits)!"
this.attackdesc = this.name + " tackles the #target# (#hits# hits)."
this.missdesc = this.name + " tackles #target# but entirely misses."

Here's the code for the enemy/other Pokemon attack description. I think it should work, I'm hoping it's lag.

this.critdesc = "#Attacker# tackles the " + this.name + "and hits hard (#hits# hits)!"
this.attackdesc = "#Attacker# tackles the " + this.name + "(#hits# hits)."
this.missdesc = "#Attacker# tackles " + this.name + "but entirely misses."

No, refreshing did nothing, closing the tab and then re opening the game did nothing, and closing multiple tabs did nothing.

My game is haunted! My games are cursed! (Joke)


Error Running script: Error compiling expression 'Replace (s, "#Equipped#", CapFirst(GetDisplayAlias(equipped)))': FunctionCallElement: Could not find function (Replace (Object;String,String)

If you're not using #Equipped# in your messages, you don't need those lines in AttackReport.

If you are using it, the code in my previous message was:

if (HasObject (attacker, "equipped")) {
  equipped = GetDisplayAlias(attacker.equipped)
}
else {
  equipped = GetDisplayAlias (attacker)
}
s = Replace(s, "#Equipped#", CapFirst(equipped))
s = Replace(s, "#equipped#", equipped

The code according to your error message seems to include:

Replace (s, "#Equipped#", CapFirst(GetDisplayAlias(equipped)))

You need to either have GetDisplayAlias in both of the equipped = lines at the top of the function, or in both of the Replace( lines that relate to it.

I assume there's some update lag, because the version I can currently download has GetDisplayAlias in one of the equipped = lines, and wouldn't cause the error you quote here (though it could yield the similar error Could not find function (GetDisplayAlias(String))


No, I went back fo the old AttackReport function.


Nevermind, I did not go back to the old AttackReport function. I'm fixing it.


Everything works! I still want hitpoints to show up when I one hit KO the Pokemon, when it just prints it whited out without printing the other attacks, but that's not an error, that's something Pixie did, I think. Thank you!


Okay, nevermind, this.name makes it say Sentret tackles the tackle and hits hard!

I think the only way is to take everything into the game - scripts - start script. Then I will try everything.

No more thank yous for a while now. Very sorry.

Another Error.
Error running script: Error compiling expression 'Intr(dice, "d")':
FunctionCallElement: Coule not find function 'Intr(Ojbect; String)'

This is my whole game - scripts - start script.

player.alias = "Gold"
player.currenthealth = 4
game.notarealturn = false
player.hitpoints = 25
player.max = 25
player.damage = 2
player.maxdamage = 2
player.attack = 0
player.maxattack = 0
player.defence = 0
player.maxdefence = 0
player.armour = 0
player.maxarmour = 0
player.catchrate = 0
player.exp = 0
player.level = 0
player.ammo = 50
player.potion = 0
player.hyper_potion = 0
player.fullrestore = 0
player.pokedollar = 0
player.statusattributes = NewStringDictionary()
dictionary add (player.statusattributes, "hitpoints", "Hit points: !")
dictionary add (player.statusattributes, "equippedname", "Pokemon: !")
dictionary add (player.statusattributes, "ammo", "Spare PP: !")
dictionary add (player.statusattributes, "ammonote", "Power Points: !")
dictionary add (player.statusattributes, "potion", "Oran Berries: !")
dictionary add (player.statusattributes, "hyper_potion", "Sitrus Berries: !")
dictionary add (player.statusattributes, "fullrestore", "Full Restores: !")
player.changedhitpoints => {
  if (player.hitpoints > 0) {
    msg ("Hits points now " + player.hitpoints)
  }
  else {
    msg ("A stray enemy attack hits you! You were killed!")
    finish
  }
}
game.pokemonget = false
player.badge = 0
game.minute = 0
game.hour = 9
game.rooms = NewObjectList()
list add (game.rooms, The Lab)
game.firstteleport = false
player.critdesc = "You attack #target# with your bare hands and get a critical (#hits# hits)."
player.attackdesc = "You attack #target# with your bare hands and hit (#hits# hits)."
player.missdesc = "You swing wildly and entirely miss #target#."
game.pokeballcount = 0
player.team = 0
player.ammomax = 50
player.pokeballs = 0
player.greatballs = 0
player.ultraballs = 0
playerballs = NewObjectList()
list add (playerballs, pokeballs)
list add (playerballs, greatballs)
list add (playerballs, ultraballs)
Struggle.damage = 1
Struggle.attack = 0
Struggle.critdesc = "#Attacker# struggles hard, and hits hard against " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)!"
Struggle.attackdesc = "#Attacker# struggles against " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)."
Struggle.missdesc = "#Attacker# struggles but entirely misses " + GetDisplayAlias(player.equipped.name) + "."
Tackle.damage = 3
Tackle.attack = 1
Tackle.critdesc = "#Attacker# tackles the " + GetDisplayAlias(player.equipped.name) + " and hits hard (#hits# hits)!"
Tackle.attackdesc = "#Attacker# tackles the " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)."
Tackle.missdesc = "#Attacker# tackles " + GetDisplayAlias(player.equipped.name) + " but entirely misses."
Twister.damage = 4
Twister.attack = 1
Twister.critdesc = "#Attacker# uses twister on " + GetDisplayAlias(player.equipped.name) + " and gets a critical hit (#hits# hits)!"
Twister.attackdesc = "#Attacker# uses twister on " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)."
Twister.missdesc = "#Attacker# uses twister but entirely misses " + GetDisplayAlias(player.equipped.name) + "."
Scratch.damage = 4
Scratch.attack = 1
Scratch.critdesc = "#Attacker# gives a well placed scratch on " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)."
Scratch.attackdesc = "#Attacker# scratches " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)."
Scratch.missdesc = "#Attacker# scratches but entirely misses " + GetDisplayAlias(player.equipped.name) + "."
Gust.damage = 4
Gust.attack = 1
Gust.critdesc = "#Attacker# shoots gust at " + GetDisplayAlias(player.equipped.name) + " and gets a critical hit #hits# hits)!"
Gust.attackdesc = "#Attacker# shoots gust at " + GetDisplayAlias(player.equipped.name) + " (#hits# hits)."
Gust.missdesc = "#Attacker# shoots gust but entirely misses " + GetDisplayAlias(player.equipped.name) + "."

Scratch.attackdesc = "#Attacker# scratches {=player.equipped.name} (#hits# hits)."

And similar.
When you do "some string" + object.attribute + "another string", it takes the value of the attribute when the start script runs, not the one that's equipped when the attack actually happens. Using the text processor forces it to look up the attribute when it's passed to the msg() function.

And the = at the start of makes it treat the contents of the {=} block as an expression, so the text processor doesn't break down when it sees an attribute path with more than one dot in; although I'd still say {=GetDisplayAlias(player.equipped)} is a better habit to get into.


@mrangel Last time I pasted
this.attackdesc = "{=player.equipped.name} tackles the #target# (#hits# hits)."
in there was a whole page filled with errors that I can't paste because I'm on my tablet and I would have to type the whole thing out. I can't get onto the computer at home, so I would have to wait until Saturday to get on their computer to paate the whole thing.

Or you could just download the game, paste it in and see what happens.


It's impossible to code in, mrangel.

See here.
http://imgur.com/0UYbpm6
http://imgur.com/fbhWOVs


Or you could just download the game, paste it in and see what happens.

I don't have a Windows PC, so I can only use the web version of Quest. So, can't open someone else's game for editing.

See here.

That screenshot shows the lines:

Tackle.critdesc = "#Attacker# tackles the " + =player.equipped.name
+ " and hits hard (#hits# hits)!"

Two errors there:

  • The {= construct allows you to put an expression inside a string. You use it instead of " +. This is already an expression, so the " + = just confuses it.
  • You've got a line break in the middle of the expression

Those lines should be:

Tackle.critdesc = "#Attacker# tackles the {=player.equipped.name} and hits hard (#hits# hits)!"

or

Tackle.critdesc = "#Attacker# tackles the {=GetDisplayAlias(player.equipped)} and hits hard (#hits# hits)!"

Later in the same code you have:
Tackle.missdesc = "#Attacker# tackles " + GetDisplayAlias(player.equipped.name) + " but entirely misses."

Two problems here as well:

  • There are two ways to turn an object into a name. You could use GetDisplayAlias (player.equipped) (which is good), or you could use player.equipped.name (which is less good). You appear to be using both, so you're asking Quest to get the name of the name of the object.
  • It looks up what object is in player.equipped once, when the start script runs, and sets missdesc to use that name permanently. If you want it to look at what the player has equipped when the message is printed, you need to replace " + and + " with {= and }

So that line should be:

Tackle.missdesc = "#Attacker# tackles {=GetDisplayAlias(player.equipped)} but entirely misses."

It now says "Sentret tackles Chikorita (equipped) but entirely misses."


I tried doing GetDisplayAlias(player.equipped.alias) but it made things worse so I changed it back. It still says "Sentret tackles Chikorita (equipped) but entirely misses."


Also, I typed rest instead of rest nurse on accident, and I got the message "No time for lounging about now." How do I remove or block a command?


Also, I typed rest instead of rest nurse on accident, and I got the message "No time for lounging about now." How do I remove or block a command?

In this case, the command you're looking at is sleep, which has the pattern ^sleep$|^rest$.

If you want to make it so that "rest" isn't an alias for "sleep", you could do:

sleep.pattern = "^sleep$"

Or if you want to block it in a particular area, you could create a command in that room which gives a more sensible message.

Or if you want to remove the sleep command entirely, you could do either:

sleep.pattern = "^(?!)$" (a special pattern which is guaranteed not to match anything)

or

destroy("sleep")


Thanks for the sleep thing.

It still says "Chikorita (equipped)."

Also, is this how you make/do lists?

player.pokeballs = 0
player.greatballs = 0
player.ultraballs = 0
playerballs = NewStringList()
list add (playerballs, "pokeballs")
list add (playerballs, "greatballs")
list add (playerballs, "ultraballs")

Can someone tell me what is wrong with this code?

Tackle.damage = 3
Tackle.attack = 1
Tackle.critdesc = "#Attacker# tackles the {=GetDisplayAlias(player.equipped.name)} and hits hard (#hits# hits)!"
Tackle.attackdesc = "#Attacker# tackles the {=GetDisplayAlias(player.equipped.name)} (#hits# hits)."
Tackle.missdesc = "#Attacker# tackles {=GetDisplayAlias(player.equipped.name)} but entirely misses."

It either keeps having error messages or it displays no message at all.


How do you make an equip parameter, and would it work for me?


You want {=GetDisplayAlias(player.equipped)} OR {=player.equipped.name} OR {=GetString(player.equipped,\"name\")}.


Sentret tackles Chikorita (13 hits).

Okay. The 2 later things work. Thank you.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums