Quest freezing?

Sir_Slush
25 Sept 2016, 22:16

Hi all!
I downloaded the Quest and Squiffy programs earlier this month, and am enjoying learning to use them. But I've run into a problem with Quest freezing when I try to execute a specific custom command. Here's the code for the command:

  <command name="Equipment roll">
    <pattern>Roll for loot!; Roll for loot; Roll to recieve; Roll for equipment;</pattern>
    <unresolved>Eh, what?</unresolved>
    <script><![CDATA[
      if (player.unidentified_treasures > 0) {
        while (player.unidentified_treasures > 0) {
          placeholders.encounter_dr = DiceRoll("1d100")
          if (placeholders.encounter_dr<=10) {
            placeholders.gold = DiceRoll("1d12") * 100
            player.gold = player.gold + placeholders.gold
            msg ("Recieved " + placeholders.gold + " gold!")
          }
          else if (placeholders.encounter_dr<=52) {
            msg ("Not written yet")
          }
          else if (placeholders.encounter_dr<=81) {
            lower_tier_roll
          }
          else {
            upper_tier_roll
          }
        }
      }
      else {
        msg ("You don't have any unidentified treasures!")
      }
    ]]></script>
  </command>

I've double-checked all my spelling, all of the objects and attributes exist, and I've created separate commands to test the low and high-tier loot roll functions, so I'm certain those aren't the problem.
But when I try to run the command in-game, Quest freezes up. I can close the game, but Quest no longer works properly for the rest of the session, and usually prints this error message after a minute or so:

System.ComponentModel.Win32Exception (0x80004005): Not enough quota is available to process this command
at MS.Win32.UnsafeNativeMethods.PostMessage(HandleRef hwnd, WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Can anyone tell me what's going on?


The Pixie
26 Sept 2016, 07:30

Your while loop will continue forever. It is set to keep going until player.unidentified_treasures is zero, but at no point in the loop is player.unidentified_treasures altered. Before this line:

   placeholders.encounter_dr = DiceRoll("1d100")

Put:

   player.unidentified_treasures = player.unidentified_treasures - 1

hegemonkhan
27 Sept 2016, 03:24

usually quest freezes/crashes is from infinite loops, so it's just a matter of checking your code.

loops need a way to terminate. Either: you got a counter which you raise/lower until a hitting certain value, an array/list reaching its end item / itemCount, or you ensure that the loop will hit/get a set/pre-determined terminating value, and there's probably another method, which I'm going blank with at the moment, lol.


Sir_Slush
27 Sept 2016, 03:38

Thank you both! I must have deleted that part when I switched from creating new objects to using predefined ones.