hoodedice wrote:Cue giant server lag because nooby programmers weren't optimizing their code. OR in the heat of battle and pressure from parents like Neuro (joke) they created bots with over 5000 lines of code. Blocks.
The way to solve that is by making a custom interpreter so, for example, infinite loops can just error out instead (see Minecraft mod ComputerCraft (shall be called CC from now on)). Telling Lua to execute custom Lua might be hard (I don't know, I'm not a Lua expert... nowhere close) although if set up correctly, allow a certain amount of commands and if it doesn't yield, error out.
That could be accomplished like in CC:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- Start a timer that will last n seconds
os.startTimer(n)
-- Wait (non-blocking) for the specific event called "timer"
os.pullEvent("timer")
Another way to accomplish would be to allow only one command per server tick / amount of real time (whichever is larger, or some other factor) per "battle bot" (which still would require a complex setup of a Lua engine)...
If we can have/find C/C++ code to emulate Lua, things should be a bit quicker / more reliable (hopefully).
Notes to consider if implementing it:
- Keeping track of position in code
- Keeping track of variable values
- Handling errors the clean way (sanity checks in "battle bot" lua code to prevent major errors)
.. Sorry if this is going nowhere, as I do know CC is a modification for a Java game (Minecraft) and Java is totally different than a mix of C/C++/Lua. I was just trying to do my best with giving ideas.
P.S. Yes, CC does cause lag on servers in Minecraft which is one of the reasons a lot of servers had that mod banned in (what is now) Tekkit Classic (Minecraft modpack).