How do I debug/get rid of this error?

How do I debug/get rid of this error?

It has something to do with my attributes. It is my online Pokémon game. The game is currently mistaking a few of the attributes (attack and dead) for commands.
There is also some problem with an attack list, or something, but I thought it may have something to do with this.
Game link. http://textadventures.co.uk/games/view/0p9uxrxu2ueatixrnt1ixg/pokemon-type-harley-johto-and-sinnoh


This error???

Search
Split ("anime?;game/manga?;card game?;combat system;heal;finish game",";")

I don't think you can just print a split like that.
Try:

{random:anime?:game/manga?:card game?:combat system:heal:finish game}

Hmmm... But I don't think that is what you are after...


just to add more commentary/info to DL's post:

the 'split' Function/Script returns a List Value (Data), and you can't have a Value (Data) floating/hanging around in code doing nothing.

You got to either:

  1. store it into a VARIABLE, for example:

game.my_pointer_list_attribute = split ("red;blue;yellow", ";")

  1. use it as an argument (input) for another Function (or whatever scripting), for example:

show menu ("Color?", split ("red;blue;yellow", ";"), false) { /* scripting* / }


You need to be wary of parsing issues/conflicts too, for an example:

<command name="attack_command">
  <pattern>attack</pattern>
</command>

<command name="attack_object_command">
  <pattern>attack #object#</pattern>
</command>

when you type 'attack orc', which Command does it do? See/Understand the parsing issue/conflict?


No, that has nothing to do with that. Just me messing around.


K.V.

Attack is a default command.

You can alter how the game reacts when the player enters ATTACK #object#, but I don't know if you could easily erase the command.

Would the player ever need to use the attack command, jmnevil54? (Also, do you mind if I start referring to you as JMNE?)


K.V.

Here's why DEAD is a command:

  <verb>
    <property>dead</property>
    <pattern>dead</pattern>
    <defaultexpression>"You can't dead " + object.article + "."</defaultexpression>
  </verb>

K.V.
Error running script: Error compiling expression 'object.dead': RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'

Silver didn't have a dead attribute.


How do I debug/get rid of this error?

What error? I had a quick play and found a few; not sure if they are what you are talking about.

> add health Oran Berry
Error running script: Error compiling expression 'player.pcurrenthealth + 20': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'

You need to add an attribute "pcurrenthealth" to the player, and set it to be an "int"

> heal mom
Error running script: Health is not configured. To enable health, go to 'game' and tick 'Show health' on the Player tab.

I would guess you used the IncreaseHealth function, which boosts the player's health, not Mum's, and only if the built-in health system is used. You probably want something like (depending on what Mum is actually called, when the attribute name is; also remember to give her a start value):

mum.currenthealth = mum.currenthealth + 20
You can see a Silver.

Make silver a named male, and it should drop the "a".

> speak to Agatha; Silver's mom
Hello, Gold. You must excuse Silver. He's in a rush. By the way, did you know you can save in the right hand corner? Sometimes it's on the right side. Use it.
Error running script: Error compiling expression 'player.badge = 2': CompareElement: Operation 'Equal' is not defined for types 'Object' and 'Int32'

You need to add an attribute "badge" to the player, and set it to be an "int". That said, I wonder how this is set up. I am guessing it is part of the achievement system?


K.V.

Error running script: Error compiling expression 'object.dead': RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'

NOTE: This is from the last version of the game. I think the error may have been fixed, but the new version is different. I never found the same Pokemon to test the command out on it.


JMNE is fine.

"
K.V. Sep 27, 2017 11:48 PM new
Here's why DEAD is a command:
"

Strange. I didn't see anything like that. I guess I'll have to download the game myself.


Alright, so I downloaded the game, and tried deleting all offending verbs.
But now I can't equip Chikorita at all, so that's confusing.


K.V., I edited the game since then. It should be fine.

This is all my fault, I messed the game up.

Would anyone like to see the file? I can probably e-mail it.


Me, Quest Forum Monster, like games!

Me help you: Chikorita equipped!

You, jmnevil54, e-mail me, Monster, the game? Monster domain at Gmail.


Is it [email protected]?


Monster is thequestforummonster at dot com thingy.


jmnevil54,

Monster got your email and looking at code now!

What should Silver do?

What does Monster type?


Uh....
I locked the way out. (For game story) Go to Silver's house.
Then you have to follow Silver out.
Then you have to go to Lake of Rage, west. There is a Pokemon bag. Open the bag and get the Chikorita.
Look at the verbs of Chikorita. Some should not be there.
There are verbs on enemies that shouldn't be there either.

I hope this helps!


Monster made thing1 and thing2.

thing1 does not have attack verb.
image


thing2 does have attack verb.

image


image

image


See? All is good!

Now, Monster add thing1.attack = 3 and see what happen...

image

image


Oh, no!

Now thing1 has attack verb listed!!!

Monster thinks this is because thing1 has attack attribute, and attack is a command (same as verb). Quest thinks the attack attribute is the attack script!

Monster would use thing1.hitpoints, not thing1.attack.

BUT, jmne could put check by Disable automatically generated display verb list for this object.

image


This would fix like this:

image


...but, if jmne disable generated verbs for thing1, jmne would have to set up verbs he wanted on thing1 in Display Verbs and Inventory verbs!


(I'm laughing at how dramatic all of this is...)

Thanks. I figured something like that happened.

I'll try checking the disable verbs thing.


But wait, how do I get rid of the extra verbs (dead) for the enemies?

I don't have any problems like this in my other games! Is this because it's so old, or did I do something to it...?


Monster find same kind of thing.

dead is setup as verb:

image

  <function name="SpawnSentret" parameters="room"><![CDATA[
    if (HasInt(game, "crittercount")) {
      game.crittercount = game.crittercount + 1
    }
    else {
      game.crittercount = 1
    }
    create ("critter" + game.crittercount)
    obj = GetObject("critter" + game.crittercount)
    obj.parent = room
    obj.displayverbs = Split("Look at;Attack;Shoot", ";")
    obj.dead = false
    obj.changedhitpoints => {
      if (this.hitpoints < 1) {
        msg ("It is dead!")
        this.dead = true
        player.exp = player.exp + 20
        player.gold = player.gold + 20
        RemoveObject (this)
        this.displayverbs = Split("Look at;Search", ";")
      }
    }
    names = Split("decrepit;decomposing;shambling;disgusting;filthy;falling-apart", ";")
    obj.alias = StringListItem(names, game.crittercount % ListCount(names)) + " Sentret"
    obj.listalias = CapFirst(obj.alias)
    obj.look = ProcessText("A " + obj.alias + ", {random:covered in maggots:missing an arm:one eye hanging out}.")
    obj.hitpoints = 30
    obj.damage = 2
    obj.attack = 4
    obj.defence = 0
    obj.armour = 0
  ]]></function>

this.dead will make Quest think this have dead script because it has dead attribute. Same thing as attack problem.

jmnevil54 can fix the same way as attack problem, or jmne can delete dead verb from game. Monster would delete verb this time.

  <verb>
    <property>dead</property>
    <pattern>dead</pattern>
    <defaultexpression>"You can't dead " + object.article + "."</defaultexpression>
  </verb>

Monster no type DEAD SOMETHING in text game anyway...


PS

Monster learned from Pixie.

Monster once was normal, then Pixie TEACH him things, and MONSTER born!!!

Monster think Pixie is good person.

Monster think jmnevil54 good person, too!


K.V.

I just posted something in the wrong thread.

Sorry!


K.V.

Whoops!

Wrong thread!


I actually do not want to download the game permanently, it would take up space at the library (which I use because the home computer is vulnerable to viruses/hackers). I will lose a fash drive.

I do not want to start the game over from scratch, by which I mean, I copy and paste code over, so I'd like to postpone that as long as possible.

I really just need another solution.


K.V.

You should be able to delete the dead verb online, jmnevil54.

Just click on it in the tree to the left.

...oh, you can't (just now checked).

In fact, in the online editor, I just made a dead verb on an object. Then, I deleted the verb from the object. Then, I downloaded the game.

  <verb>
    <property>dead</property>
    <pattern>dead</pattern>
    <defaultexpression>"You can't dead " + object.article + "."</defaultexpression>
  </verb>

Yeah... it's there online, now, and there appears to be no way to delete it in the editor.

> dead me
You can't dead yourself.


...but...

foreach (o, AllCommands()) {
  msg (o)
  msg (o.pattern)
}

In the long list that printed, I found the verb's/command's name:

Command: k6
^dead (?.?)( (with|using) (?.))?$


So, I'll move the command to the player object, rendering it useless.

Start script:

k6.parent = player

...and...

> dead me
I don't understand your command.


No more dead verb.


Command: k6
^dead (?.?)( (with|using) (?.))?$
Is that the code to move the verb?
Thanks for the work around, at least.

I guess one day I may download the game and work out some of the bugs... a long ways from now...

Anyways, I tried the thing The Quest Forum Monster suggested. It seems to work for now.

Actually, at the moment I have The Pixie busy because I somehow managed to explain the combat aspect of Pokémon to him, then I ran into a bunch of programming errors all at once, and I got him on that, sooooo.... I don't want to busy him further, and it might be anywhere between now and 2 weeks before he replies again. Maybe longer. He doesn't like to reply until he has the code done, or if he has a question.


You can't delete a verb in the online editor. But in the start script, you could put something like:

foreach (cmd, AllCommands()) {
  pattern = cmd.pattern
  if (Left(pattern, 5) = "^dead") {
    destroy (cmd.name)
  }
}

it will go through all the commands in your game and remove the "dead" one; meaning that it's invisible to someone playing the game. It's just there as an invisible thing in the editor, that's removed every time the game starts.


@mrangel Is that exact, or will I have to change it?


Well... K.V.'s solution at least half way works... "dead" still shows up though.

As I said, it's a problem with the underlying code, or something.


K.V.

mrangel's code should work exactly as he has it, jmne.

In fact, if I'd known you could destroy commands using their .name, I would have advised the same thing.

When using the desktop editor, the verbs show up in the object tree, making it easy to delete them. The web editor is a horse of a different color.


I made a game online. Then made 'thing' and 'thing2'. Then created a dead verb on 'thing'.

image

image


Now, I'll add the dead attribute to thing2, which will make Quest think it has a dead verb/command script, seeming how dead is now a verb/command.

image

image

image


Now, let's delete the verb from 'thing' BEFORE applying any fix.

image

image


'thing2' has a dead attribute, and the dead command, although it's been deleted from all objects as a verb, still exists.

There is more than one way to skin this rabbit, but we'll stick to getting rid of the dead command altogether, since that makes the most sense in this scenario.

So, let's put mrangel's code in the start script:

image

image


Curses!!!

It DID destroy the command, but 'Dead' is still added to the generatedverbslist for thing2 because thing2.dead exists when the game loads, as does the command.

So...

How about using the User interface initialisation script instead of the start script?

image

image


Ha!

Booya!

How about that teamwork, everybody?!?

Isn't it grand?

Whoo-hoo!


As expected, the code didn't work exactly. I now can't pick up my character's hat, or do any other command. And that was my favorite hat!


Oh wait. This popped up.

Error running script: Error compiling expression 'IsRegexMatch(cmd.pattern, command, cmd.name)': FunctionCallElement: Could find not function 'IsRegexMatch(Object; String; String)'

Oh great. I delete BOTH codes and the error still pops up! Now my game is broken!


OK ... that error looks like AllCommands() is storing an internal list of commands, and doesn't remove any that have been destroyed (?). The parser maybe falls over when it tries to compare your input to a command that no longer exists. (Just guessing here) So let's tweak the script; instead of destroying the command, we just change its pattern to a regular expression which is guaranteed never to match anything.

Also, as KV noticed, that doesn't prevent the command popping up in generatedverbslist. Moving the script to the UI initialisation is a bit too inefficient for my tastes; I think it will be better to delete both the command and the corresponding verb. So you should be able to put it back in the start script.

foreach (cmd, AllCommands()) {
  pattern = cmd.pattern
  if (Left(pattern, 5) = "^dead") {
    cmd.pattern = "^(?!.?)"
  }
  if (HasString(cmd, "property")) {
    if (ListContains(game.verbattributes, cmd.property)) {
      list remove (game.verbattributes, cmd.property)
    }
    if (DictionaryContains(game.verbattributeslookup, cmd.property)) {
      dictionary remove (game.verbattributeslookup, cmd.property)
    }
  }
}

(generatedverbslist is built from game.verbattributes the first time an object is presented in the UI; which will be after the start script runs)


Wait, you removed the script and still get that error?
I'd think the editor has screwed up somehow, then.

I tested the script I previously pasted again, and I don't see that error.


K.V.

It doesn't do anything like that to me:

image


Can we see the script you added? Or is it already deleted, and gone the way of the dodo?


K.V.

This is what I'm using to destroy the dead verb/command:

foreach (cmd, AllCommands()) {
  pattern = cmd.pattern
  if (Left(pattern, 5) = "^dead") {
    destroy (cmd.name)
  }
}

This is a dangerous script...

If you forgot the IF..., it would delete all commands from the game.

...BUT removing that bit from your start (or initialisation) script should make it just like it was before you added it.


(I couldn't pick the hat I created up at first, but I went back and made it so it could be taken, and... yeah... I just forgot.)


I'm sorry, jmne!

(We may need you to download the game file and paste the code, if that's possible.)


Actually, I just started a new game, and started copying the old one. I like the improvements already!


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

Support

Forums