LeDark Lua, on 09 August 2015 - 07:04 AM, said:
On emulators I get 62FPS on MC 15/20-30
Minecraft has two main components. The renderer and the world. The world calculates all the things that need to be happening in the world logically. This includes things like a furnace updating its progress, a quarry breaking some blocks, or redstone updates. The world operates at 20 ticks per second (ideally). So 20 times a second, all of these things are updated.
The renderer operates at either a capped max FPS, or however fast it is capable of rendering. Ideally this is something like 60fps. In CC emulators, this is represented by the drawing of the CC screen. All this is doing is drawing everything in the world based on current world information. Ideally, you'd like this to be around 60fps, but lower end computers won't have the graphics power for this. But all the fps relates to is how fast it is capable of drawing things on screen. It isn't bound by the ticks per second.
ComputerCraft has its own component, the Lua VM, which runs all the computers' code. This is not bound by either of the other two components. It is its own thread that runs Lua code as fast as it is capable of (with limitations set by dan, but this is negligible). Lua code is in no way related to the other two components. It will run on its own, as fast as it can. The exception is code that involves pulling events. If I remember correctly, you can pull at most one event per world tick. This can possibly limit you to 20 iterations of a loop per second, but it's very rare that you need to be pulling so many events. Things that would cause event pulling are: rednet communication, some (but not many) peripheral method calls, accepting user input, etc..
So basically, the things that you think are limiting your Lua code aren't limiting it at all unless you are being irresponsible with the kind of code you're running in large loop. The only real limitation is the performance of your computer, as you've mentioned. But I promise you, any computer built in the last 20 years is capable of running a simple for loop in lua at a few million times a second. The limitation is entirely just the kind of code you're wanting to run in that loop. But unless you're calling event pulling code, that won't even be a noticeable limitation. Not to mention, if that's the source of limitation, loadstring won't help, as it will just call the same code, causing the same limitation.
Finally, you should always remember this Donald Knuth quote
Quote
Premature optimization is the root of all evil.
Always begin with naive implementations and see where performance problems arise from there. Your life will be miles easier and you'll avoid trying to do weird hacks like this that are entirely unnecessary.











