Nore wrote:I had made a mod like that, but not finished it: https://github.com/Novatux/turtle. However, in that one the turtle in programmed in Forth, and there are a few commands still missing, but globally it works... feel free to use it.
Neuromancer wrote:First I guess we need to find out what files are in the apps folder, loop through them, and then do a minetest.register_chatcommand for each filename. Ideas on how to do this?
local dir = minetest.get_modpath(minetest.get_current_modname()).."/apps/"
local filenames
--code based off of https://github.com/cornernote/minetest-towntest/blob/master/towntest_chest/init.lua
--its probably linux/mac
if os.getenv('HOME') and kits_dir then
os.execute('ls "'..dir..'" | grep .lua > "'..dir..'/.apps"')
local file, err = io.open(dir..'/.apps', 'rb')
if not err then
filenames = file:lines()
end
os.execute('rm "'..dir..'/.apps"')
--its probably windows
else
filenames = io.popon('dir "'..dir..'"'):lines()
end
if not filenames then
error(Some error message)
else
for filename in filenames do
--do what you need to do
end
end
I~=Spam wrote:Hello all! First post! :-)
I am not sure what you are talking about but I have a working lua sandboxed environment in which you can specify what you want to included in the environment and you can also specify specific functions in tables that you want omitted (like string.dump). It even can't take up all of the processing power of the server because I have set a debug hook which, after running a specified number of lua expressions (not lines) it while call the debug hook which temporarily pauses the computer.
Although there is a catch. Sadly it doesn't run in luajit 2.0 or lua5.1. It only works in lua5.2 (might work in luajit1.0 using a third party addon) because in lua5.2 the c stack was changed to allow yielding across c boundaries. Even telling luajit not to compile using jit.off(function) sadly doesn't work. Using lua lanes might work but a new problem comes up (i haven't confirmed this though). All functions that are not in the base library must be re-required. And it is impossible to require the essential "minetest.*" table. Furthermore it is virtually impossible to require other mods that may want to mod comptuercraft.
In other words, I am out of ideas for how to make a lua comptuer mod written in lua due to the fact minetest uses luajit. :-(
I think that this may be possible to do if someone were willing to write some of the mod in c. Although the problem is I am not even sure where the c moder would start. All I would need to get this mod to work is the ability to run a function be able to pause execution of that program periodically (and return to the main program) after a specified number of expressions of lua code.
I~=Spam wrote:Progress! In theory I can do this using coroutines despite the problems I mentioned before. The downside though is that it is pretty hackish and abuses the stack somewhat and for this reason I am not sure how many computers will be able to be run at a time. I will post when I have something more presentable if this is possible.
BirgitLachner wrote:What about starting with a remote control? Is this too difficult?
https://youtu.be/JX_JmVp2Vt8?t=12s
Should we start with a new project? I don't want to start it at github as I'm only in the background :-/
I can create some little textures for a beginner turtle
BirgitLachner wrote:Okay ... just a try ... as github newbie I maybe had a bad start:
https://github.com/BiLachner/TurtleMiner
Anyone is welcome to participate ... just tell my your github name.
Users browsing this forum: Google [Bot] and 40 guests