Unable to Save

HogardDeLauger
14 Apr 2020, 14:23

Hi everybody,

I have an issue with a game I'm creating: whenever I try to save, it gives me the error:
Function not found: 'case'.
This is the same problem the user sorro145 had, but nobody was able to solve the issue.
(http://textadventures.co.uk/forum/quest/topic/ry_13yp5c0a4sdllgekcmg/save-restore-issue#7243cdfe-3f59-45a3-844c-301e61015ed5)
I noticed that we are using both the italian lang, maybe that is connected to the problem?
And no, there isn't any word "case" in the code (except for a switch, but that's not the problem).
Any solution?

Thanks in advance.


mrangel
14 Apr 2020, 16:40

Found it.

In the Italian language file is a function that looks like this:

  <function name="Possessive" parameters="owner, object" type="string">
    if (owner = game.pov) {
      case (DoesInherit (object, "masculine") or DoesInherit(object, "male")) {
        return ("il tuo")
      }
      case (DoesInherit (object, "female") or DoesInherit(object, "female")) {
        return ("la tua")
      }
      case (DoesInherit(object, "maleplural")) {
        return ("i tuoi")
      }
      case (DoesInherit(object, "femaleplural")) {
        return ("le tue")
      }
    }
    else if (DoesInherit(owner, "maleplural") or DoesInherit(owner, "femaleplural")) {
      case (DoesInherit (object, "masculine") or DoesInherit(object, "male")) {
        return ("il loro")

There's a "case" there that isn't inside a "switch" block. If you tried to create that function in a game, you'd get an error immediately. But Quest doesn't check function validity when running, loading, or publishing. The error will only come up if you try to use the Possessive function (which you don't), or when you try to save a project that contains it.

If you copied that function into your game, it would refuse to save because it's invalid. But because it's in a library, the error goes unnoticed until it tries to save the function as part of a saved game.

If I understand the function correctly, it should be something like:

  <function name="Possessive" parameters="owner, object" type="string">
    if (owner = game.pov) {
      if (DoesInherit (object, "masculine") or DoesInherit(object, "male")) {
        return ("il tuo")
      }
      else if (DoesInherit (object, "female") or DoesInherit(object, "female")) {
        return ("la tua")
      }
      else if (DoesInherit(object, "maleplural")) {
        return ("i tuoi")
      }
      else if (DoesInherit(object, "femaleplural")) {
        return ("le tue")
      }
    }
    else if (DoesInherit(owner, "maleplural") or DoesInherit(owner, "femaleplural")) {
      if (DoesInherit (object, "masculine") or DoesInherit(object, "male")) {
        return ("il loro")

and so on… but I'm pretty sure that is not a sane way for that function to work.

If you're on the desktop version of Quest, you can find the file Languages/Italiano.aslx somewhere under where Quest is installed, and either fix or remove the Possessive function.

If you're using the web version, unfortunately you'll have to wait for someone with access to the webserver to fix it.


mrangel
14 Apr 2020, 17:10

I've rewritten this function so that it does what it looks like it was meant to do. I don't speak Italian, so I've assumed the actual text in the existing function was correct.

  <function name="Possessive" parameters="owner, object" type="string">
    switch (owner.gender + " " + object.article) {
      case ("tu lo") {
        return ("il tuo {object:"+object.name+"}")
      }
      case ("tu la") {
        return ("la tua {object:"+object.name+"}")
      }
      case ("tu li") {
          return ("i tuoi {object:"+object.name+"}")
      }
      case ("tu le") {
        return ("le tue {object:"+object.name+"}")
      }
      case ("lui lo") {
        return ("il loro {object:"+object.name+"}")
      }
      case ("lui la") {
        return ("la loro {object:"+object.name+"}")
      }
      case ("lui li") {
        return ("i loro {object:"+object.name+"}")
      }
      case ("lui le") {
        return ("le loro {object:"+object.name+"}")
      }
      case ("lei la") {
        return ("il suo {object:"+object.name+"}")
      }
      case ("lei la") {
        return ("la sua {object:"+object.name+"}")
      }
      case ("lei li") {
        return ("i suoi {object:"+object.name+"}")
      }
      case ("lei le") {
        return ("le sue {object:"+object.name+"}")
      }
      default {
        // In the unknown case, fall back on an English-style plural.
        // Someone who knows Italian can probably insert other cases above to prevent this,
        // but until that's done, we should avoid causing an error message.
        return (GetDisplayName(owner) + "'s {object:"+object.name+"}")
      }
    }
  </function>

HogardDeLauger
15 Apr 2020, 17:30

Thanks a lot Mrangel, you really are an angel! I totally overlooked that line when i checked the language file , but in my defense it was late and I was pretty tired :P.
Well, time to fix it!