VictorNorman / ScratchFoot

A Scratch emulation layer in Greenfoot.
4 stars 1 forks source link

Converting Peg_solitaire fails. #164

Open VictorNorman opened 7 years ago

VictorNorman commented 7 years ago

Stack trace:

b'Proceesing var: Peg#' Adding varInfo entry for Sprite2 : Peg# --> (PegNum, Int) Exception in Tkinter callback Traceback (most recent call last): File "s2g.py", line 1099, in mathExpr return str(int(tokenOrList)) ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/vtn2/anaconda/lib/python3.5/tkinter/init.py", line 1549, in call return self.func(*args) File "s2g.py", line 2879, in convertButtonCb convert() File "s2g.py", line 2698, in convert sprite.genCodeForScripts() File "s2g.py", line 831, in genCodeForScripts codeObj = self.genScriptCode(script) File "s2g.py", line 2280, in genScriptCode self.whenIReceive(codeObj, script[0][1], script[1:]) File "s2g.py", line 1361, in whenIReceive cbStr += self.block(1, tokens) + "\n" # add blank line after defn. File "s2g.py", line 867, in block genIndent(level) + "}\n" File "s2g.py", line 878, in stmts retStr += self.stmt(level + 1, aStmt, deferYield) File "s2g.py", line 993, in stmt return genCodeFunc(level, tokenList, deferYield) File "s2g.py", line 1433, in doIfElse resStr += self.block(level, tokens[3]) File "s2g.py", line 867, in block genIndent(level) + "}\n" File "s2g.py", line 878, in stmts retStr += self.stmt(level + 1, aStmt, deferYield) File "s2g.py", line 993, in stmt return genCodeFunc(level, tokenList, deferYield) File "s2g.py", line 1736, in setVariable val = self.mathExpr(tokens[2]) File "s2g.py", line 1102, in mathExpr return str(float(tokenOrList)) ValueError: could not convert string to float:

Project is https://scratch.mit.edu/projects/96456069/.

This might be a duplicate of an open bug already -- I don't know.

VictorNorman commented 7 years ago

Converting Emoji Memory Game (https://scratch.mit.edu/projects/163456722/) may have same problem:

Part of stack trace is: [['procDef', 'data', [], [], True], ['setVar:to:', 'ready?', 0], ['setVar:to:', 'completed', 0], ['setVar:to:', 'right?', 'derp'], ['setVar:to:', 'guess', 0], ['deleteLine:ofList:', 'all', 'IDs'], ['doRepeat', 12, [['append:toList:', 'derp', 'IDs']]], ['setVar:to:', 'idek', '1'], ['doRepeat', 12, [['doUntil', ['=', ['getLine:ofList:', ['readVariable', 'y'], 'IDs'], 'derp'], [['setVar:to:', 'y', ['randomFrom:to:', 1, 12]]]], ['setLine:ofList:to:', ['readVariable', 'y'], 'IDs', ['readVariable', 'idek']], ['changeVar:by:', 'idek', 1]]], ['setVar:to:', 'idek', '1'], ['doRepeat', 12, [['doIf', ['>', ['getLine:ofList:', ['readVariable', 'idek'], 'IDs'], '6.1'], [['setLine:ofList:to:', ['readVariable', 'idek'], 'IDs', ['-', ['getLine:ofList:', ['readVariable', 'idek'], 'IDs'], 6]]]], ['changeVar:by:', 'idek', 1]]]] Exception in Tkinter callback Traceback (most recent call last): File "s2g.py", line 1099, in mathExpr return str(int(tokenOrList)) ValueError: invalid literal for int() with base 10: 'derp'

I'm thinking that the choice to auto-convert 'derp' to string was a mistake. In this case, we should catch this error, and pop up a dialog box that that says it seems like 'derp' is supposed to be an integer/double, and suggest the user use that type... Might be hard to do, but, oh well, life is hard.