goto and ::label:: not supported
Crayder opened this issue · 4 comments
Useful information to include:
-
Minecraft version
- 1.16.4
-
CC: Tweaked version
- cc-tweaked-1.16.4-1.94.0.jar
-
Logs: These will be located in the
logs/
directory of your Minecraft instance. Please upload them as a gist or directly into this editor.- (not sure these are really needed, and they are very verbose since it's Valhelsia 3, but:) latest.log
-
Detailed reproduction steps: sometimes I can spot a bug pretty easily, but often it's much more obscure. The more information I have to help reproduce it, the quicker it'll get fixed.
- Reporting this more as a questions I guess, but basically the Lua version used doesn't support goto statements and for the life of me I can't think of a better way to accomplish what I'm trying to do. Are there plans to get Lua 5.2+?
The task at hand is a base script where the turtle's will determine a plot size, find the proper way to traverse it, and perform tasks along the way (such as planting or harvesting crops). That's all working fine. Until the GPS/turtle streams out of course.
So I'm trying to add session saving and restoring. It will remember what position it was at, and if it was traversing or refueling (phases that it won't be at the home position) it will attempt to restore position... I've scripted everything for that to work... but my whole surveyPlotPhase
function is broke without goto <label>
support.
I'm going to work on another way for now but this was disappointing since I got the whole script wrote 😢
Here's the script if you're interested, it's pretty sweet, but this is the not working version because it attempts to use goto
:
sessiontest-surveyonly.zip
ComputerCraft currently uses Lua 5.1, while goto and labels were only introduced in 5.2. While some 5.2/5.3 features have been backported, this is not one of them.
I suppose it's technically possible to do, but awkward as we need to ensure any code which uses goto
as a standard identifier is still well formed. I'm petrified to go near the parser, so I'm afraid this is unlikely to change.
Thanks for the super quick response. Completely understand. Never used Lua before writing this for CC actually (one week in, Lua is awesome) so don't know anything about helping with backporting it.
OpenComputers does use Lua 5.2/5.3(?IIRC?), so you might look at what they do. I wrote a lot of code for OC, so it would be nice to be able to use it here.
OpenComputers does use Lua 5.2/5.3(?IIRC?), so you might look at what they do. I wrote a lot of code for OC, so it would be nice to be able to use it here.
They use a different lua run time and I don't think that SquidDev will be willing to switch to it, defiantly not until a new MC version as it is likely to cause a few compatibility issues.