Ye old game.command error (Solved)

I have went and done it now... I uploaded a restart of a game to GitHub. After a few videos I was able to do it.
Anyway, I have updated Quest to the 5.8, found the latest versions of the libraries I need. Now before I start coping all my objects from the old version of a game to the new, piece by piece, I want to make sure everything works.

I get an error after the player creation screen. The pixie solved it for me before concerning the CombatInitialise(true) function. However now when the 'done' button is pressed on the creation screen I get the error,



The only change I made was to the "Boris" name.
I have spent the last day trying to fix it but to no avail.

Everything involved in the game is here.

If you feel froggy have a look. I'm at a loss to find the problem.


Create an attribute on the game object called "command_successful" and set it to be a Boolean.


Sometimes I really hate you. Thanks for replying


K.V.

The power of The Pixie compels you!!!


The times between the two were only a half hour. I was at the docs waiting and she walked in as I was replying and had to cut it short. It was indeed a fix! Thanks again Pixie!


K.V.

>Sometimes I really hate you. Thanks for replying

I bet that makes Pixie grin wider than I did!

Ha-ha-ha!

That's the best compliment I've read all year!


ya, it's not fun when you're pulling your hair out trying to figure something out... and then someone helps you with: a only a few lines, no effort, and quickly.... GRR... laughs. Or, you do a massive wall of text trying to explain something... and then others come and explain it in only like a paragraph of typing... lol (this is exclusively HK's annoyance!)


K.V.

I think it's fun, but I'm a weirdo.


I learn more with everyone's input.

HK's walls of text are always packed with informative nuggets.

The paragraph posted by someone else afterwards may explain something in the wall of text which may be confusing to non-coders.

The short, effortless scripts posted afterwards are usually examples of efficiency.


I like to see all the different ways things can be done.


Is that a new avatar? K.V.


K.V.

Why, yes!

Thanks for noticing!

Just last week, I asked my doctor how to liven things up a little, and she said to always try out new positions.


My doctor...

She's a great gal, ya' know. Her name is Doctor Vicky Boombotz.

One time I asked her how I could stop chewing gum, and she suggested I take up smoking.

A month later, I asked how to stop smoking, and she said to only smoke after sex.


Har de har...Ba doom tssh

Oh I see The Pixie is sporting a new one too!
Awesome.


K.V.

Hey, thanks!

This is a great audience, I tell ya'! A great audience!


..and I didn't notice Pix's new one, either!

It is pretty nice, huh?


I tried to do an avatar at Gravatar about a year ago, and something went wrong, and it would not let me do anything. When I saw KV's new one, I gave it another try.

For future reference, when you do get an error like this, look at it in two parts:

Error running script: Error compiling expression '[whatever]':
RootExpressionElement: Cannot convert type '[something]' to expression result of 'Boolean'

The first line tells you where it is; it is in a section of code "whatever". You can search for that in the desktop version.

The second line says what it is - but needs some translating. The "something" will be a type, and when it says "Object", it really means null. That particular error is when the condition for an if is not a Boolean.

If you try doing maths with null, you will see:

ArithmeticElement: Operation 'Add' is not defined for types 'Int32' and 'Object'

You get this if a variable or object does not exist (or misspelt):

Unknown object or variable '[something]'

K.V.

Did you make that on Gravatar, Pix?

I tried that forever this time.

I went to the Gravatar site and clicked "Sign-in with WordPress," sending sign-in links for WordPress to my email, which never led me anwhere but... WordPress?

I tried about 20 times.

I ended up just using Paint 3D to make one.


EDIT

I see now. You just upload your own image to Gravatar. (I was thinking there was an online avatar creator hiding somewhere.)


Thanks for the heads up Pixie! Sometimes the error messages leave me at a complete loss. I am learning to make a single change then test, single change and test. But sometimes I think I know what I'm doing and will make a bunch of changes and forget to test and then can't remember all the changes I made. Even forgetting to save a working master during several hours of editing and find I've screwed things up and have to restart from scratch. It is an education for sure. Especially for a hard head like me. I tend to get excited when I do something that works and rush forward without precautions.


You're not the only one... I do it all the time. I do massive amounts of coding, and then try it, only to find a ton of errors, and have to pain-stakingly and time-consumingly backtrack and etc, to find those errors in my mass of code... I't definitely best to do one operation/line + testing of coding at a time.


(usually, the errors are actually quite minor/easy fixes.... but trying to locate/find them when you got a ton of code... that's the pain-staking time-consuming hard part)


You're not the only one... I do it all the time. I do massive amounts of coding, and then try it, only to find a ton of errors, and have to pain-stakingly and time-consumingly backtrack and etc, to find those errors in my mass of code... I't definitely best to do one operation/line + testing of coding at a time.

(usually, the errors are actually quite minor/easy fixes.... but trying to locate/find them when you got a ton of code... that's the pain-staking time-consuming hard part)

Me too! Missing a ) is especially popular.


yep, it's usually a parenthesis '(,)', tag-arrow/greater-than/lesser-than': '<,>', or back-slash/forward-slash '/,\' issue, or sometimes some other simple mistake (spelling, typo, syntax, wrongly using 'inherit' instead of 'include', or vice versa, lol, highlighting-copying-pasting mistakes, etc etc etc)

rarely is it your actual code design/logic/etc

but those simply mistakes are very hard to locate/realize/find... as you got to examine tons of coding/scripting all over the place in your entire game code, to find the culprit part/piece of it, which is why it's best to not do a tons of code and then test it, but instead to test after very small parts/pieces/operations of code. HK is lazy though and thinks he can code better or more flawlessly than he actually can, lol)

K.V.

It really sucks when you edit a script in full Code View, and you add something which needs to be wrapped in <![CDATA[]]>! (This very much applies to libraries, too!)

Quest will tell you the wrong line contains an error.

I think the same thing happens if you forget to close out an element, too.


I'm also bad about having an extra } when my if statements get too thick.


As I said before, I am revamping a game using CombatLib3. I am going through the introduction again, step by step, to ensure I prepare all the library xml's properly.

In part two, I add a silver goblet. I can look at it but when I try to take it I get,

Error running script: Cannot foreach over 'Object: silver_goblet' as it it not a list.

I have found one or two references in the forum but am unable to use the info found to fix the error.


K.V.

I got that error using the beta version because I had a modified TAKE script.

Allow me time to find the information, Kemosabe, and I shall return.


You know why The Lone Ranger and Tonto split up don't you?

Because the Lone Ranger found out that Kemosabe meant knuckle head....

K.V.

Ha!

I thought it meant "white devil"!


K.V.

Which version of Quest are you using, and which was the last version which allowed you to take the silver_goblet?


I'm on a computer now. Let's tear something up!

...er... I mean let's fix something!


Using 5.8. Using CombatLib3, never tried this combination before.


K.V.

This may not effect anything at all, but try dropping the DoTake() function from 5.7.1 in your game. (I can't find the correspondence between Pixie and myself, but it seems like this might fix it.)


NOTE:
You may or may not be aware of this "trick", but, when I add things like this to full Code View, I make sure to test the game out by pressing play directly from code view. If it doesn't work (or causes problems), I just stop the game and UNDO the addition/change I just made. Once you flip to GUI, you can't undo a change you just made in code view.

...and it's still wise to save a backup of the game first, of course, especially when you're trying my ideas. (Just ask Anonynn! (Sorry, Anonynn! Ha-ha-ha! We fixed it, though, right?))



<function name="DoTake" parameters="object, ismultiple"><![CDATA[
    prefix = ""
    if (ismultiple) {
      prefix = GetDisplayAlias(object) + ": "
    }
    if (object.parent = game.pov) {
      msg (prefix + DynamicTemplate("AlreadyTaken", object))
    }
    else if (not ListContains(ScopeReachable(), object)) {
      msg (prefix + DynamicTemplate("ObjectNotOpen", GetBlockingObject(object)))
    }
    else {
      volume = 0
      continue = true
      foreach (obj, GetAllChildObjects(game.pov)) {
        if (HasInt(obj, "volume")) {
          volume = volume + obj.volume
        }
      }
      if (not Contains(game.pov, object)) {
        volume = volume + GetVolume(object,true)
      }
      if (HasInt(game.pov, "maxvolume")) {
        if (volume > game.pov.maxvolume) {
          continue = false
          if (HasString(game.pov, "containerfullmessage")) {
            message = prefix + game.pov.containerfullmessage
          }
          else {
            message = prefix + DynamicTemplate("FullInventory", object)
          }
        }
      }
      children = GetDirectChildren(game.pov)
      if (HasInt(game.pov, "maxobjects")) {
        if (game.pov.maxobjects > 0) {
          if (ListCount(children) >= game.pov.maxobjects) {
            continue = false
            if (HasString(game.pov, "containermaxobjects")) {
              message = prefix + game.pov.containermaxobjects
            }
            else {
              message = prefix + DynamicTemplate("MaxObjectsInInventory", object)
            }
          }
        }
      }
      if (continue = false) {
        msg (message)
      }
      else {
        found = true
        takemsg = object.takemsg
        switch (TypeOf(object, "take")) {
          case ("script") {
            if (ismultiple) {
              OutputTextNoBr (prefix)
            }
            do (object, "take")
            takemsg = ""
          }
          case ("boolean") {
            if (object.take = true) {
              object.parent = game.pov
              if (takemsg = null) {
                takemsg = DynamicTemplate("TakeSuccessful", object)
              }
            }
            else {
              found = false
            }
          }
          case ("string") {
            object.parent = game.pov
            takemsg = object.take
          }
          default {
            found = false
          }
        }
        if (not found and takemsg = null) {
          takemsg = DynamicTemplate("TakeUnsuccessful", object)
        }
        if (LengthOf(takemsg) > 0) {
          msg (prefix + takemsg)
        }
        if (HasScript(object, "ontake")) {
          do (object, "ontake")
        }
        if (found and GetBoolean (object, "scenery") and object.parent = game.pov) {
          object.scenery = false
        }
      }
    }
  ]]></function>

I CAN TOO POST THIS HERE!!!


I had noticed there were several 'take' functions. I'll let you know....


Ok, DoTake removed from combatstuff.xml. Now take does nothing.


K.V.

Okay, I messed that up. I'm very sorry.

Here's the DoTake() script from combatstuff.xml, just in case you need it:



  <!--
  This version of DoTake first checks to see if this is a spell and TAKE ALL,
  and skips everything if it is
  -->
  <function name="DoTake" parameters="object, ismultiple"><![CDATA[
    if (not ismultiple or not GetBoolean(object, "skipmultitake")) {
      prefix = ""
      if (ismultiple) {
        prefix = GetDisplayAlias(object) + ": "
      }
      if (object.parent = game.pov) {
        msg (prefix + DynamicTemplate("AlreadyTaken", object))
      }
      else if (not ListContains(ScopeReachable(), object)) {
        msg (prefix + DynamicTemplate("ObjectNotOpen", GetBlockingObject(object)))
      }
      else {
        volume = 0
        continue = true
        foreach (obj, GetAllChildObjects(game.pov)) {
          if (HasInt(obj, "volume")) {
            volume = volume + obj.volume
          }
        }
        if (not Contains(game.pov, object)) {
          volume = volume + GetVolume(object,true)
        }
        if (HasInt(game.pov, "maxvolume")) {
          if (volume > game.pov.maxvolume) {
            continue = false
            if (HasString(game.pov, "containerfullmessage")) {
              message = prefix + game.pov.containerfullmessage
            }
            else {
              message = prefix + DynamicTemplate("FullInventory", object)
            }
          }
        }
        children = GetDirectChildren(game.pov)
        if (HasInt(game.pov, "maxobjects")) {
          if (game.pov.maxobjects > 0) {
            if (ListCount(children) >= game.pov.maxobjects) {
              continue = false
              if (HasString(game.pov, "containermaxobjects")) {
                message = prefix + game.pov.containermaxobjects
              }
              else {
                message = prefix + DynamicTemplate("MaxObjectsInInventory", object)
              }
            }
          }
        }
        if (continue = false) {
          msg (message)
        }
        else {
          found = true
          takemsg = object.takemsg
          switch (TypeOf(object, "take")) {
            case ("script") {
              if (ismultiple) {
                OutputTextNoBr (prefix)
              }
              do (object, "take")
              takemsg = ""
            }
            case ("boolean") {
              if (object.take = true) {
                object.parent = game.pov
                if (takemsg = null) {
                  takemsg = DynamicTemplate("TakeSuccessful", object)
                }
              }
              else {
                found = false
              }
            }
            case ("string") {
              object.parent = game.pov
              takemsg = object.take
            }
            default {
              found = false
            }
          }
          if (not found and takemsg = null) {
            takemsg = DynamicTemplate("TakeUnsuccessful", object)
          }
          if (LengthOf(takemsg) > 0) {
            msg (prefix + takemsg)
          }
          if (HasScript(object, "ontake")) {
            do (object, "ontake")
          }
          if (found and GetBoolean (object, "scenery") and object.parent = game.pov) {
            object.scenery = false
          }
        }
      }
    }
  ]]></function>


I CAN DEFINITELY POST THIS HERE.


K.V.

Hrmm...

Pixie!

Help!


Well that was anti-climatic!


Ok. I was working with a clearscreen/ShowRoomDescription function I had created as a turnscript when we decided to remove the dotake function. which I forgot to turn off. Duh.

The original error message still pops up without the dotake function. so it is not being called at this point.

Anything I create in the room and try to take gives the error.

Is this the latest combat3 instructions?


I think this is because Quest 5.8 handles ALL a bit differently (it tries to do it more intelligently, so it excludes NPCs). HGowever, CombatLib overrides the take command, and is still working with the 5.7 system.

To fix, add an updated TAKE command. You can either edit the TAKE command in commands.xml, or add a new command to your game file.

Hopefully this should work. Let me know if it does so I can update CombatLib for when 5.8 is officially rekeased.

  <command name="take">
    <pattern>take #object#; get #object#; pick up #object#</pattern>
    <multiple>
      takeList = NewObjectList()
      foreach (obj, ListExclude(ScopeVisibleNotHeldNotScenery(), game.pov)) {
        if (obj.parent = game.pov.parent) {
          list add (takeList, obj)
        }
      }
      return (takeList)
    </multiple>
    <scope>notheld</scope>
    <multipleobjects type="script">
      game.pov.currentcommandpendingobjectscope = NewObjectList()
      foreach (obj, ListExclude(ScopeVisibleNotHeldNotScenery(), game.pov)) {
        if (obj.parent = game.pov.parent and not DoesInherit(obj, "npc_type")) {
          list add (game.pov.currentcommandpendingobjectscope, obj)
        }
      }
    </multipleobjects>
    <script><![CDATA[
            if (IsUnableToHold()) {
        msg ("You cannot pick anything up with <i>" + GetDisplayAlias(game.pov.currentspell) + "</i> active.")
      }
      else if (multiple and ListCount(object) = 0) {
        msg ("Nothing here to take.")
      }
      else {
        foreach (obj, object) {
          DoTake (obj, multiple)
        }
      }
    ]]></script>
  </command>

That did it. I replaced the take2 command with the script you provided. Checked with the debugger to ensure all was well. Good to go so far.


K.V.

I chose my words poorly.

I wrote: "try dropping the DoTake() function from 5.7.1 in your game."

English translation: "try adding the DoTake() function from 5.7.1 to your game."

You were probably wondering why I was bothering to post a script which was to be removed...

Sorry about that.


Also, once I saw the DoTake() in combatstuff.xml, I realized I was just bumbling, so I cried "Pixie". (The power of Quest compelled me.)


You did point me in the right direction.


K.V.

Well, that's good, and thank you for saying so.


I still feel appropriately guilty for leading Forgewright astray, though.

...and I know this error is especially frustrating because it got me once. (Me and my modified take command! I always want to exclude something that's not scenery from TAKE ALL in every game I write, for one reason or another.)

I'll make it up to you, Forgewright!


If that's the worst thing that happens to me today, then I'll be having a great day. It was a misunderstanding on my part.
You Wrote:"try dropping the DoTake() function from 5.7.1 in your game."
I Read: try dropping the DoTake() function from 5.7.1, which is the latest Quest, not 5.8.(thought you were correcting me) , I'm writing "in your game" just to avoid argument and to not make you feel so embarrassed for calling it 5.8.(which is entirely possible)

What you wrote makes perfect sense. It was late here in the states and I was tired and should have reread it.
Just don't let it happen again...Ha!


K.V.

Well, thank you.

...although I still say the misunderstanding was all thanks to me.

Tell ya' what. We'll split it. We were both thinking too hard.

It wouldn't have worked, anyway, because you need the DoTake() for CombatLib.


I think avoiding the word "drop" when I'm talking about adding something will be much less confusing in the future, at any rate.


I'm still learning to communicate. It's a process.

I am from "the hood", you see...

The statement initially formed like this in my mind:

Yo, dawg.  Fi was you, I'd drop that ol', five-seven-one DoTake script off up in the mix, and see what cooks up.

That evolved into "try dropping the DoTake() function from 5.7.1 in your game", which is definitely more similar to English...

Anyway, my dear, departed, English-teaching aunt would be rolling in her grave if I didn't point out my faux pas and learn from it, so...

Yeah.

I f--ked that up a little bit.


You know, that same aunt used to always say, "nobody likes a smart-ass!"


Am I rambling?

I'm rambling again, aren't I?

Did you laugh, though? Just a little bit?

I hope so...

(KV laughs maniacally, does a little dance, and exits, stage right.)


I was raised in Texas. So, I would say:

Drop them thar 5.7.1 yammerin's from the DoTake script like a hot horseshoe into a cold bucket of 5.8. 

Or not...it's been 40 years since I lived thar... I mean there.


@The Pixie, since I'm using the 5.8 would you prefer any issues to be posted in the forum or GitHub?
I posted there once and thought I'd better ask first.

  • Capitalized aliases are lowercase in-game
  • Objects selected as object/room do not have the notes tab when annotations are selected in the game features.

K.V.

Ha-ha!

I am in Mississippi, so I understand it that way, too!

(Stuff it, XanMag! I can only imagine what you're thinking!)


@The Pixie, since I'm using the 5.8 would you prefer any issues to be posted in the forum or GitHub?

PM me, preferably.


Capitalized aliases are lowercase in-game

This is CombatLib. If you want if to stop remove GetDisplayAlias from CombatStuff.xml. It is part of an optional system to have items colour-coded in the inventory list.


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

Support

Forums