Want to see what kicked my butt for two hours?!?

This is in a library file I'm writing which is 879 lines at the moment. This bit of code spans from line 639 - 649.


  <object name="curtains">
    <parent type="object">Bedroom</parent>
    <alias>your curtains</alias>
    <synonym>curtain curtains shade shades</synonym>
    <adjective>your</adjective>
    <scenery/>
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <action type="routine">
      return(CurtainsF(cmd,var))
    </action>
  </object>"



The editor wouldn't even load the game.

image


I commented code out from where I knew it had worked to the end of the file and moved it down block by block until I found the problem. (Honestly, I went back and forth past it, and then around and eventually just below it a few times before I saw the stupid thing that was driving me INSANE.)

The problem is right there in front of you!

Can YOU find it?!? (Bwahahahaha!)

(If you spot it immediately, give me a handicap, as it was buried in nearly 900 lines of code.)


I'm not sure, but to me it looks like you have <scenery/> on line 6 without a matching opening <scenery>
or <scenery/> should be </scenery>.


Good try, but <scenery /> denotes a boolean set to true. It is allowed. (I had to double-check that myself. I thought maybe this was the issue at one point.)

That is the same thing as <scenery type="boolean">true</scenery>.


I'll make it even harder.

Click to see the same code after I fixed it:



  <object name="curtains">
    <parent type="object">Bedroom</parent>
    <alias>your curtains</alias>
    <synonym>curtain curtains shade shades</synonym>
    <adjective>your</adjective>
    <scenery/>
    <usedefaultprefix type="boolean">false</usedefaultprefix>
    <action type="routine">
      return(CurtainsF(cmd,var))
    </action>
  </object>


HINT

It's a stupid thing. It got there because I was using a text editor that was automatically filling things in while coding, and I didn't notice it when things went haywire.


Bummer. A simple closing quote. No wonder it took a while to find it. It would be one of thse things that you see but don't see.
Reminds me of the old dys of typing in listings from magazines and then debugging them. Sometime they were my mistakes as I typed and a few were caused by the scanners/typesetting of the listing.

At my age, my eyesight can also be a problem. But that is the subject for another forum.


At my age, my eyesight can also be a problem.

Actually, I didn't see the " until I hooked my laptop up to my TV via HDMI. (I need new glasses.)

The TV is too small for movies, but too big for computing.

...but it sure came in handy in this particular instance!


Editors that add a second quote character really annoy me too.

What is type="routine"? At first I thought it might be that?

In situations like this, you might find it useful to use an XML checker.


Example XML validator:
https://www.xmlvalidation.com/

You can paste in your whole file or just an element as you did here.


What is type="routine"? At first I thought it might be that?

I would assume routine is the name of a delegate; although I'm not sure why that would be beneficial in this case.


What is type="routine"? At first I thought it might be that?

As mrangel assumes:

routine is the name of a delegate

That is another good guess, but the editor actually gave me a detailed error when I didn't have that delegate's code in the proper place. (It was initially in the game's main code, but if a library uses it, it has to be read before the code that uses it in the library.)


Example XML validator

Cool!

I didn't know these existed!


I'm not sure why [a delegate] would be beneficial in this case.

It might not be, but it's the only way the easiest way I could find to handle the game I'm porting.

CurtainsF is a function that may or may not handle verbs for the curtains.

If CurtainsF does not find a situation where it handles any verbs during a command, it will not return true and the default stuff will handle the command.

It's like a way to kind of set up verbs on an object, but not really.

If a verb script could return a boolean, I wouldn't need the delegate.


  <function name="CurtainsF" parameters="cmd,var" type="boolean">
    if(cmd = open or cmd = look_inside_cmd){
      bulldozer.visible = true
      msg("As you part " + GetDisplayAlias(curtains) + " you see that i{global.nice_day}, and a large yellow " + GetDisplayAlias(bulldozer) + " is advancing on " + GetDisplayAlias(home) + ".")
      return (true)
    }
    return (false)
  </function>

If object, object1, or object2 has the attribute "action", the action delegate . . . Well, I'll let that bit of code explain itself:

      if (HasScript(game.pov.currentcommandpattern, "script")) {
        handled = false
        // This is the bit that actually runs the commands
        if (global.dont_flag) {
          DontF (game.pov.currentcommandpattern, game.pov.currentcommandresolvedelements)
          handled = true
        }
        else if (objFound) {
          // msg(TypeOf(obj))
          if (IsDefined("obj2")) {
            if (HasFlag(obj2,"unimportant")) {
              handled = true
              UnimportantThingF
            }
            else if (HasDelegateImplementation(obj2,"action")) {
              handled = RunDelegateFunction(obj2,"action", game.pov.currentcommandpattern, game.pov.currentcommandresolvedelements)
            }
          }
          if (not handled and TypeOf(obj) = "objectlist") {
            // msg("multiple")
            foreach (o, obj) {
              if (HasFlag(o, "unimportant")) {
                Tell (GetDisplayAias + ": ")
                UnimportantThingF
                handled = true
              }
              else if (HasDelegateImplementation(o,"action")) {
                // msg ("ResolveNextName found 'action': " + o)
                handled = RunDelegateFunction(o,"action", game.pov.currentcommandpattern, game.pov.currentcommandresolvedelements)
              }
              else if (not handled) {
                handled = true
                do (game.pov.currentcommandpattern, "script", game.pov.currentcommandresolvedelements)
              }
            }
          }
          else if (not handled and HasDelegateImplementation(obj,"action")) {
            // msg ("ResolveNextName found 'action': " + obj)
            handled = RunDelegateFunction(obj,"action", game.pov.currentcommandpattern, game.pov.currentcommandresolvedelements)
          }
        }
        if (not handled) {
          do (game.pov.currentcommandpattern, "script", game.pov.currentcommandresolvedelements)
        }
      }

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

Support

Forums