Minetest, Luajit, and Javascript

Minetest, Luajit, and Javascript

Postby dulsi » 25 Oct 2016, 02:57

My son took a simple "Coding with Minecraft" class at the public library. It used scriptcraft mod for minecraft. We don't have minecraft at home so I was thinking of modifying minetest to run some scriptcraft code.

(Why do this? Wouldn't it be easier to teach your son lua? Yes it probably would. It could probably build equivalent lua functions that he used very easily. Mapping minecraft block IDs would minetest values would be annoying but would need to be done if javascript is implemented. Alternatively I could modify the api to use minetest values which would be easier but even less compatible with scriptcraft. So in other words, this idea is much harder than it needs to be. Now we return to original discussion where I'm trying to do this despite it being harder.)

I found instructions for calling a C shared library very easily for lua. I tried the code in minetest and it failed. Minetest uses luajit not lua. Luajit has ffi to easily call a C function but I don't see anything to call back into luajit. Ideally I want to run C function for example which run javascript. When javascript hits box('5'), it calls back to C which calls back to luajit to place a block. Is it possible to do this in luajit?

EDIT: Found how to do it. It has the same api that lua has you just need to include/link to the luajit-devel files not lua-devel files. It also looks for the shared library in the current directory or a few other places. So I can't simply put the file in the mod directory. If the shared library is found it works.
dulsi
 
Posts: 75
Joined: 18 Feb 2016, 15:24

Re: Minetest, Luajit, and Javascript

Postby dulsi » 26 Oct 2016, 12:11

Scriptmine project has been created. Right now all it does is allow you to call javascript functions and echo. I don't have compiling/installing instructions up yet.
dulsi
 
Posts: 75
Joined: 18 Feb 2016, 15:24

Re: Minetest, Luajit, and Javascript

Postby mdtrooper » 28 Oct 2016, 01:38

Good job, I follow this project. Thanks
User avatar
mdtrooper
 
Posts: 86
Joined: 26 Jul 2012, 13:24

Who is online

Users browsing this forum: No registered users and 1 guest