textadventures / quest

Create text adventure games
http://textadventures.co.uk/quest
MIT License
304 stars 69 forks source link

Eval inside an if statement causes an error #820

Closed F2Andy closed 8 years ago

F2Andy commented 9 years ago

This works fine: msg (Eval ("true"))

This generates an error: if (Eval ("true")) { msg("yes") } -> Error running script: Error compiling expression 'Eval ("true")': RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'

alexwarren commented 9 years ago

It's a limitation of the current script runner. The return type of "Eval" is not a boolean - it can't know what the return type is until it evaluates the expression. It might work if you use

Eval("true") = true

though maybe.

On Tue, 24 Nov 2015 at 14:22 F2Andy notifications@github.com wrote:

This works fine: msg (Eval ("true"))

This generates an error: if (Eval ("true")) { msg("yes") } -> Error running script: Error compiling expression 'Eval ("true")': RootExpressionElement: Cannot convert type 'Object' to expression result of 'Boolean'

— Reply to this email directly or view it on GitHub https://github.com/textadventures/quest/issues/820.