0 votes
by (250 points)
retagged by

One of my users is having an issue with the latest update of a game I'm making. His complaint, specifically:

"I seem to be having issues with the combat this update. It says "Error: <<FightMenu>>: cannot execute widget: Cannot read property 'toLowerCase' of undefined" when I try to fight something."

However, I can't seem to replicate his error, and I'm rather at a loss as to what the underlying issue is. Here is the primary widget in question:

<<widget "FightMenu">><span id = "FightMenu"><<ChooseTarget>><<if $charmedTurnsLeft > 0>><<Resist>><<else>><<if $tethered>><<RemoveTether>><br><</if>><<Attack>><br><<DodgeAndWait>><br><<Flee>><br><<Spellbook>><</if>></span><</widget>>

And here are the sub-widgets it calls:

<<widget "ChooseTarget">>Target: <<for $targetButtons to 0; $targetButtons < $foeRoster.length; $targetButtons++>><<radiobutton "$target" $targetButtons checked>> $foeRoster[$targetButtons]: $foeHP[$targetButtons] HP <</for>><br><</widget>>
<<widget "Resist">><<click "Try to Resist">><<replace "#fight">>You can do nothing but struggle to regain control of your body as the $foeName clouds your mind!<br><<updateStatusTimers>><<FoeActs>><</replace>><</click>><</widget>>
<<widget "RemoveTether">><<click "Remove the harpoon">><<replace "#fight">>With a tug on the filament connecting the harpoon, you untether yourself from the Ampion.<<set $tethered = false>><br><<updateStatusTimers>><<FoeActs>><</replace>><</click>><</widget>>
<<widget "Attack">><<click "Attack!">><<LoadTarget>><<replace "#fight">>You strike at the $foeName!<br><<rollStats $charCombat $wepAcc>><<rollFoeStat $foeDodge>><<if $successes >= $foeSuccesses>>$foePain, taking <<set $atkDamage = Math.round((($charStr*0.8) + $wepStr + $strMod)*either(.8,.9,1,1.1,1.2)) - $foeArmor>> $atkDamage damage!<<set $foeHP[$target] -= $atkDamage>><<Retaliation>><<else>>However, the $foeName evades the blow.<</if>><br><<CheckFoeHP>><<replace "#FightMenu">><<FightMenu>><</replace>><<updateStatusTimers>><<CheckVictory>><<FoeActs>><</replace>><</click>><</widget>>
<<widget "DodgeAndWait">><<click "Defend and wait">><<replace "#fight">><<beginFullDefense>><<set $fullDefense = 2>>You decide to wait and maintain your defense.<<if $foeCurrentHP > 0>> Foe's HP: $foeCurrentHP <<updateStatusTimers>><<FoeActs>><<else>><<replace "#foe">><</replace>><<replace "#FightMenu">>You've won the battle!<br><<updateStatusTimers>>[[Continue| $foeDeath]]<</replace>><</if>><</replace>><</click>><</widget>>
<<widget "Flee">><<click "Flee!">><<rollStats $charAgi $agiMod>><<rollFoeStat $foeChase>><<if $successes > $foeSuccesses>><<replace "#fight">>You manage to get some distance from the $foeName, eluding it for now.<</replace>><<replace "#foe">><</replace>><<replace "#FightMenu">><<updateStatusTimers>><<cleanUp>><<basicExplore>><</replace>><<else>><<replace "#fight">>You try to escape from the $foeName, but it proves too quick and cuts you off!<</replace>><<updateStatusTimers>><<FoeActs>><</if>><</click>><</widget>>
<<widget "Spellbook">><<if $bioMagicMastery >= 1>><<Boneblast>><br><<if $cooldownTurnsLeft == 0>><<TitanStrength>><<else>>Cannot cast Titan Strength while on cooldown!<</if>><br><</if>><<if $stormMagicMastery >= 1>><<Whizbang>><br><<if $cooldownTurnsLeft == 0>><<Slipstream>><<else>>Cannot cast Slipstream while on cooldown!<</if>><br><</if>><<if $fireMagicMastery >= 1>><<if $cooldownTurnsLeft == 0>><<ScorchingSphere>><<else>>Cannot cast Scorching Sphere while on cooldown!<</if>><</if>><</widget>>

My inability to replicate, along with the fact that the error occurs in a control widget, is really hurting my ability to hunt this one down. Any help would be appreciated.

1 Answer

+1 vote
by (68.6k points)
selected by
Best answer

In future.  You should always mention both the compiler and story format, and their versions (because, yes, it's important).  Generally, you do that via tags (though it doesn't hurt to also mention them in the body of your question).

Which version of SugarCube is this and is that the complete error?  Which browser and version is the player using?

If that's the entire error and your <<FightMenu>> widget code is accurate, then I haven't a clue as to what's going on because:

  1. That particular error message wording originates only within the widget handler and would require that an exception be thrown either directly within the handler or the HTML tag parser.  It cannot be coming from the rest of the widget's contents, as an error from either the <<if>> macros or the other widgets would result in a different error message.
  2. The <String>.toLowserCase() method is called in only a few of places within SugarCube and only one or two of those could possibly be involved (depending on the version).  As of the current release of SugarCube, both candidates are guarded against the possibility of being called on an undefined value.
by (250 points)
edited by
Right, sorry.
Twine version: 2.2.1
Sugarcube version: 2.21.0

The player is using Chrome, using philome.la. I don't know his browser version, but I can ask him if necessary.

In an update he gave me, he said the game works fine for him while using Firefox.
by (8.9k points)
edited by

This is happening in my game, too!  A user sent me this screenshot of the error messages.

The widgets in question:

<<widget "newFeatureIcon">><<nobr>>
<img src="http://www.femaleagentgame.com/wp-content/uploads/2018/05/rocket32.gif" />

<<widget "improvementIcon">><<nobr>>
<img src="http://www.femaleagentgame.com/wp-content/uploads/2018/05/gear32.gif" />

<<widget "fixIcon">><<nobr>>
<img src="http://www.femaleagentgame.com/wp-content/uploads/2018/05/bug32.gif" />

He said he got these error messages in Chrome, but it works fine in IE.

I compiled my game in Tweego using Sugarcube 2.23.5.

by (68.6k points)
edited by

Can either of you replicate the issue or have you had reports from other Chrome users (I doubt they're your only Chrome users)?

Are they using non-standard modes (e.g. incognito), extensions, or both?

I'll do some testing of my own tomorrow.

EDIT: Finished my tests.  I've tried just about everything I can think of, short of installing random extensions, and encountered no issues in the latest version of Chrome.  I cannot reproduce the issue, so unless your players can offer up some additional information I'm at a loss.

by (8.9k points)
I can't replicate it in Chrome either, and no other players have reported this issue.  I'll check with the player that he's still experiencing it, and if so ask for a list of the Chrome extensions he has installed.
by (8.9k points)

My user has found the cause!

It is indeed an extension that is doing it. I just disabled all the extensions and tested them one after the other and found the culprit. The extension "Pop up blocker for Crome - Poper Blocker"

I've had the extension a long time, and the first time i played Female Agent it didn't have this error. Don't know what could have changed

Link to the extension

by (68.6k points)
edited by

I'll take a look at the extension later, maybe I can workaround whatever it's doing to cause the error.

EDIT: I just ran some tests with the extension install and I still cannot replicate the error. /shrug

by (8.9k points)
I'll see if I can replicate it, and report back.