# GOTO not working on html5 (SOLVED)

**URL:** <https://forum.defold.com/t/goto-not-working-on-html5-solved/2074>\
**Category:** Bugs\
**Created:** [June 8, 2016, 4:43am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074 "2016-06-08T04:43:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![StrangeAndr](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/strangeandr/32/1332_2.png) [@StrangeAndr](https://forum.defold.com/u/StrangeAndr)\
**Post date:** [June 8, 2016, 4:43am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/1 "2016-06-08T04:43:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 8, 2016, 5:44am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/2 "2016-06-08T05:44:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 8, 2016, 6:39am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/3 "2016-06-08T06:39:12Z")

</div>

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](http://luajit.org/extensions.html), 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

---

<div class="post-metadata">

**Author:** ![StrangeAndr](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/strangeandr/32/1332_2.png) [@StrangeAndr](https://forum.defold.com/u/StrangeAndr)\
**Post date:** [June 8, 2016, 7:02am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/4 "2016-06-08T07:02:20Z")

</div>

It explains everything. Thank you!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [September 1, 2016, 4:49am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/5 "2016-09-01T04:49:56Z")

</div>

> [@britzl](#):
>
> DEF-1742 - Add support for the bitop module in Lua 5.1

Fixed in [Defold 1.2.87 has been released](https://forum.defold.com/t/defold-1-2-87-has-been-released/2766)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 16, 2017, 6:17pm UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/6 "2017-10-16T18:17:38Z")

</div>

> [@britzl](#):
>
> DEF-1284 - Upgrade LuaJIT to a version which supports 64 bit ARM

Fixed in Defold 1.2.115

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [October 17, 2017, 7:11am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/7 "2017-10-17T07:11:27Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 17, 2017, 7:15am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/8 "2017-10-17T07:15:45Z")

</div>

> [@Mathias\_Westerdahl](#):
>
> 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)

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

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 3, 2018, 2:04am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/9 "2018-03-03T02:04:44Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 3, 2018, 1:03pm UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/10 "2018-03-03T13:03:48Z")

</div>

> [@Pkeod](#):
>
> HTML5 still doesn’t work with goto and labels

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 ([Extensions](http://luajit.org/extensions.html)).

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 3, 2018, 6:05pm UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/11 "2018-03-03T18:05:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 4, 2018, 7:14am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/12 "2018-03-04T07:14:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [March 4, 2018, 7:19am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/13 "2018-03-04T07:19:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [March 4, 2018, 8:07am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/14 "2018-03-04T08:07:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 3, 2019, 8:17pm UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/15 "2019-06-03T20:17:49Z")

</div>

> [@britzl](#):
>
> The other option would be that we run Lua 5.2 instead of 5.1 on platforms that doesn’t support LuaJIT

Is this ever a possibility?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 4, 2019, 3:27am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/16 "2019-06-04T03:27:22Z")

</div>

Right now no. We have no plans at all for this. It was way too time consuming to update to latest LuaJIT but in that case there was a direct need and an improvement to be had. For this upgrade to 5.2 the benefit is much smaller and not something we would like to spend time on doing.

---

<div class="post-metadata">

**Author:** ![marcopar](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/marcopar/32/12641_2.png) [@marcopar](https://forum.defold.com/u/marcopar)\
**Post date:** [September 29, 2020, 12:33pm UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/17 "2020-09-29T12:33:35Z")

</div>

Is it possible to add build warnings when using an unsupported Lua fature by the selected platform?  
Or even betterva generic build warning when using a feature that is not 100% cross platform?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [September 29, 2020, 2:00pm UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/18 "2020-09-29T14:00:23Z")

</div>

> [@marcopar](#):
>
> Is it possible to add build warnings when using an unsupported Lua fature by the selected platform?

Sure, we could spend time to implement something like that, but I’m not sure it is worth it. I’m also thinking that an editor script and the use of the luac command from Lua 5.1.x could catch the use of unsupported features.

---

<div class="post-metadata">

**Author:** ![Epitaph64](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/epitaph64/32/39288_2.png) [@Epitaph64](https://forum.defold.com/u/Epitaph64)\
**Post date:** [October 1, 2020, 1:22am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/19 "2020-10-01T01:22:17Z")

</div>

Have you guys experimented with [GitHub - openresty/luajit2: OpenResty's Branch of LuaJIT 2 · GitHub](https://github.com/openresty/luajit2) or is the LuaJIT implementation in the engine isolated so I could experiment with this? Do you know the reason for LuaJIT not supporting HTML? The engine uses emscripten for HTML5 but I’m guessing that LuaJIT isn’t fully LLVM compatible. Honestly no idea, but it sounds like an interesting side project to try to add HTML support to LuaJIT for anyone brave enough 😛

EDIT: I’m seeing the project Fengari: [https://fengari.io/](https://fengari.io/) which supports is a Lua VM rewriten in JS. Wondering if you guys have had a chance to look into this?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 1, 2020, 5:04am UTC](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074/20 "2020-10-01T05:04:28Z")

</div>

> [@Epitaph64](#):
>
> Have you guys experimented with [GitHub - openresty/luajit2: OpenResty's Branch of LuaJIT 2 · GitHub](https://github.com/openresty/luajit2) or is the LuaJIT implementation in the engine isolated so I could experiment with this?

It’s isolated and built per platform. See the packages folder of the repo. LuaJIT is widely accepted as the Lua version to use in games. We use Lua JIT 2.10-beta with support for arm 64.

The openresty version has diverged even more from Lua 5.1 so I don’t really see it as a viable option for Defold.

> [@Epitaph64](#):
>
> Wondering if you guys have had a chance to look into this?

Fengari is a reimplementation of Lua 5.3 in JavaScript. It’s not really an option and I don’t see how it could work with native extensions for instance.

[Next page](https://forum.defold.com/t/goto-not-working-on-html5-solved/2074.md?page=2)
