GOTO not working on html5 (SOLVED)


#1

The game object is no longer working on HTML5, if I try to add the following code in the object’s script:

goto point ::point::
While it works fine on Windows and Android.

What is wrong can not be found, because the browser console not written any errors. It looks like HTML5 build only supports Lua 5.1, while other platforms work with version 5.2 or later. Is it true? Or is it a bug?


HTML5 Print to Console
#2

Tested and couldn’t get goto to work with HTML5 builds either.


#3

Ah, you’ve stumbled across one of a few discrepancies between the different platforms Defold supports. On HTML5 and iOS 64 bit platforms we use plain old Lua 5.1 and on all other platforms we use LuaJIT.

goto is a part of Lua 5.2 and upwards but LuaJIT which is based on Lua 5.1 has a couple of added extensions, one being the support for goto.

To ensure that your game will run on all platforms it is not recommended to use any language features other than the ones provided by Lua 5.1.

We have three separate tickets in our backlog to make the platforms using Lua 5.1 more in line with LuaJIT:

DEF-1742 - Add support for the bitop module in Lua 5.1
DEF-1439 - Add support for pcall and xpcall inside coroutines in Lua 5.1 (using the Coco extension)
DEF-1284 - Upgrade LuaJIT to a version which supports 64 bit ARM


#4

It explains everything. Thank you!


#5

Fixed in Defold 1.2.87 has been released


#6

Fixed in Defold 1.2.115


#7

Well, we updated to v2.0.5, and added support to 64bit OSX. The 64 bit arm will have to wait until we update to version 2.1.0 (which is in beta right now)


#8

Ah, yes, my bad. Thank you for clarifying!


#9

HTML5 still doesn’t work with goto and labels

goto and labels would be really very convenient with dialog based scripting to jump around to different paths within the same script file!


#10

It probably never will. There’s no LuaJIT version (that I know of) that runs in a browser.

The other option would be that we run Lua 5.2 instead of 5.1 on platforms that doesn’t support LuaJIT and on LuaJIT build with DLUAJIT_ENABLE_LUA52COMPAT (http://luajit.org/extensions.html).


#11

I think then my options are to use while loops for sections within dialog based scripts for repeatable sections, or to parse scripts before running and break them down into labeled chunks before running.


#12

I have a chunk parser/loader working now and now am trying to improve it. I’ll only activate it for HTML5 builds and otherwise use goto/label features.

Is
_,label,_ = string.match(file, "^(::)(.*)(::)$")
an acceptable way to check if a line matches a label or is there a better way?


#13

That looks about right. How are you using labels by the way? I’ve never really considered them that useful.


#14

The VN dialog scripts are generally executed linearly via a coroutine. Usually line by line one at a time with some commands having a wait period or waiting on user input. Labels can be used to make sections which should be on a loop a little cleaner in this style of scripting. While loops would also be possible but it’s less ideal for this style I think. And at some point I’d like to make a visual editor for dialog scripts and labels would be better for that. Labels can also be used to skip sections within a linear dialog script without wrapping everything in if statements.