Page 1 of 2

[Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Sun Jan 29, 2017 23:48
by octacian
Image


Digital Computers [digicompute]

Version 0.5.2, beta
Licence: MIT
GitHub Repository
Issue Tracker
Download: This, is the first mod ever to attempt to provide fully functional computer and networking devices to the Minetest players. Originally inspired by digiterm, the mod has begun to take an entirely new direction. Computers are completely stand alone. They require no other mods to function, and can run alone or as a group.

To get started, just place down a computer, right click on it to power it up, and right click again once it's on to set the computer name. From there on it's all up to you. If you aren't satisfied with the default operating system, see the API section below and learn how to make your own.

Planned / WIP Features
  • [wip] turtles
  • gui operating system support
  • package-like applications
  • routers (internet)
  • digiline support
  • mesecon support
API
digicompute is a mod that is meant to be customized, and tweaked by both modders and players. Along with the computers available out of the box, a powerful API is provided allowing modders to easily and quickly register their own computers, and soon peripherals, internal components, and other devices.

The OS API allows anybody to create their own operating system to run and distrubute right on their digicomputers. The possibilities are becoming endless, as operating systems will soon be able to further use the formspec to create a graphical experience right inside Minetest.

To learn more about the API, see the Wiki. Or, see the files on GitHub.

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Mon Jan 30, 2017 16:23
by Laser0073
Cool! Gonna check this out...

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Mon Jan 30, 2017 16:42
by GreenXenith
No matter what I type into the terminal, I always get " [string "whateveritype"]:1: '=' expected near '<eof>' "
unless I type something like "time = 0" which does nothing btw.

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Mon Jan 30, 2017 21:02
by octacian
GreenDimond wrote:No matter what I type into the terminal, I always get " [string "whateveritype"]:1: '=' expected near '<eof>' "
unless I type something like "time = 0" which does nothing btw.
See the API documentation that documents all the functions available under the environment. Right now, the computer just directly executed code typed in. An update is coming soon, however, that will form a fill Linux-like operating system with commands like ls, touch, mkdir, etc...

However, before that, I have to fix an issue with loops.

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Tue Jan 31, 2017 03:39
by Sirvoid
... ?

Image
Image

I wrote something in the computer ...

I crashed too when I pressed on the help button in the computer and when I wrote the name of the computer.

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Tue Jan 31, 2017 04:31
by TheReaperKing
I'm sooooo excited about this!! I think this is the perfect way to help my students learn about linux and Lua. They are actually already using linux but I'm scared to let them go nuts with the commands :) This is a much safer Sandbox!

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Tue Jan 31, 2017 04:50
by maikerumine
Wow...


You are a smart feller.

Great job, this is pretty intense, I would need a week to figure this all out.

+1000

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Tue Jan 31, 2017 06:05
by octacian
Sirvoid wrote:... ?
I wrote something in the computer ...

I crashed too when I pressed on the help button in the computer and when I wrote the name of the computer.
This is interesting. Errors like that should be redirected through the sandbox, meaning the game shouldn't crash but the error should be shown in the computer console. With that in mind, I wonder if this is an issue with the version of Lua installed on your computer, as I believe sandboxes differ between some versions.

Could you open an issue on GitHub with the following information included? The log (as you did here), the exact text you typed in the input, anything else you did before this happened, and the version of Lua installed on your computer (type lua -v in the command prompt).
TheReaperKing wrote: I'm sooooo excited about this!! I think this is the perfect way to help my students learn about linux and Lua. They are actually already using linux but I'm scared to let them go nuts with the commands :) This is a much safer Sandbox!
Yeah, one command and you could destroy the entire OS. Here though, it doesn't really matter. I'll soon be working on an update to add an entire set of linux commands to BiosOS (soon to be called octOS - thanks for the idea OldCoder), meaning that they'll really be able to get an idea as to how Linux works without even using it :P
maikerumine wrote: Wow...

You are a smart feller.

Great job, this is pretty intense, I would need a week to figure this all out.

+1000
Well, believe it or not, this project has been ongoing for the past 5 months. Yeah, I've been quite busy, but it's no simple mod :D

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Tue Jan 31, 2017 06:28
by TumeniNodes
Woohoo!!! http://www.softpedia.com/get/System/OS- ... a-OS.shtml

edit> DOH! Nvrmind.... it's not what I thought it was : /

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Tue Feb 07, 2017 22:03
by octacian
BiosOS has been renamed to octOS. I am also progressing through the process of making a Linux-like OS for digicomputers. HDDs and some other cool things will be coming soon!

The mod is now fully functional on Windows from this commit onwards.

Note: I have not yet released a new version with the above changes, it is recommended that you download the master for now, or download from the commit linked above if you prefer not to directly download the master.

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Tue Feb 07, 2017 22:48
by Linuxdirk
The day you can run the Linux kernel in it, you won the modding game ;)

(You can run Linux in JavaScript so Lua should be able to do that, too ...)

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Wed Feb 08, 2017 03:12
by octacian
Linuxdirk wrote:The day you can run the Linux kernel in it, you won the modding game ;)

(You can run Linux in JavaScript so Lua should be able to do that, too ...)
That is essentially my goal, but it a slightly more simplistic form.

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Wed Feb 08, 2017 05:40
by hajo
octacian wrote:
GreenDimond wrote:I always get " [string "whateveritype"]:1: '=' expected near '<eof>' "
unless I type something like "time = 0" which does nothing btw.
See the API documentation that documents all the functions available under the environment.
Right now, the computer just directly executed code typed in.
To make it useful, some simple, working examples would be nice:

Basics:
* helloWorld - output text to chat / logfile / sign / ...
** maybe also how to set color of output / errorlevel of log-entry
* play a sound
* input - listen to chat, keypads, ..
* process input - e.g. input 2 numbers, calculate & output sum
* store&access data

Look at the world:
* clock - tell time & date (real-world, as well as ingame)
* tell position of computer
* tell name / position of player
* calculate distance/bearing between them
* look at player-data, e.g. hp, skin, inventory ...
* look at node at x,y,z -- see if it exists yet, if there is a door, chest, torch...
* find the position of a door/torch/etc. nearest to x,y,z
* tell light-level at x,y,z --> greet with "good morning" / "good night" ...
* look at contents of chest at x,y,z -- see how many torches / empty slots in it
* watch for changes -- e.g. door / chest-contents / plant at x,y,z

Interact with the world
* open/close door at x,y,z
* place/remove a torch at x,y,z
* give/take a torch into chest at x,y,z
* switch on light at x,y,z when player is near, and lightlevel is too dark
** plus greet player, using the above infos (day/night, name, skin, inventory...)
--> "Good morning sam ! You have done well upgrading to steel tools since your last visit"

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Wed Feb 08, 2017 15:30
by octacian
Wow hajo! That was a LOT in one post xD
So, let's get started.

I have not yet been able to finish the OS itself, meaning that all the basics will be unavailable until then. There will unlikely be many examples built in as this is meant to be a Linux-like OS, however, commands will be documented in the help command and the rest of the API is rigorously documented as well. I am unsure as to whether I will allow computers to play sound as it could get really annoying. Computers will not be able to listen to chat, they already have an input in the formspec. As documented, you can use set_userdata(key, value) and get_userdata(key) to store data.

I hadn't thought about making the computers tell the MT-world time. ATM, they can tell the time of the host computer in the real-world. Will add soon. The computer itself will not be able to interact with the MT at all world past telling the time. Breaking a node and other things like that will be left for the robots which I will soon bring over from TurtleMiner. However, the computers will be able to be able to open doors, so my previous statement is not entirely correct. I have considered external devices to be able to check chests and stuff like that, but it's more likely that I'll leave that for turtles as it makes more sense. One thing to keep in mind is that not even the turtles will be able to do something at a specific coordinate, as it would allow for griefing.

Now, I will soon implement admin computers which will have access to the entire Minetest API and possibly all mod APIs, which would allow it do things like open a specific door.

Re: [Mod] Functional Lua Computers [0.5] [digicompute]

Posted: Fri Feb 10, 2017 13:28
by hajo
octacian wrote:The computer itself will not be able to interact with the MT world at all ..
Well, considering that we already have lua, so we can run any program we want,
I was wondering what use a 'Functional Lua Computer' in minetest would have.

BTW, have a look at rnd's basic_machines and basic_robots.
The naming is somewhat misleading - they are fairly advanced.

In short, the robots can run any lua program you would care to write,
they can communicate, do input/output via chat, keypads, displays,
and can also activate all of the basic_machines (which can move stuff, craft items, etc.).

So, if you find something they cannot do, just tell rnd,
and it might get implemented, soon (or even sooner :-)
I'll leave that for turtles
Have the turtles now gained an inventory, so they can build something ?

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Fri Feb 10, 2017 15:44
by octacian
hajo:

Well, I guess that statement isn't quite correct. Computers will be able to do numerous things that would be considered "interacting with the world," but they will definitely not be able to break blocks and stuff like that as it wouldn't make sense because they cannot move. The will, however, be able to send mesecons and digilines signals, allowing the opening of doors and other things.

Overall, computers will have a lot of use. That use would be to use them as normal computers. Aside from the above, they will be able to communicate via WiFi (with other computers, turtles, phones, etc...), host data for remote access, print, access the internet, and more. Overall, they will act as a nicer yet fully functional replacement for Lua Controllers and digiterms (though you will still be able to communicate with them via digilines).

Now, about turtles. I posted a while back in the TurtleMiner thread that turtles now have inventories. In fact, probably nearing a month ago. Once I get some basic things done in digicompute, the tech turtle and API from TurtleMiner will be merged into digicompute as robots. Because of the huge framework already completed in digicompute, it will be very easy to add a Lua command line/editor (unsure which yet) to turtles. Now, turtles will unlikely be able to write to the chat, just FYI. This is because someone could easily write a loop to spam the chat.

Now, about basic_robots. If rnd ends up reading this, in advance, you should know that this is just my personal thought of your mod. Personally, I am not at all a fan of basic_robots. I think that both the formspec and overall design are messy. Not only that, but I dislike several (if not many) of the choices rnd has made during development. And yes, I have tried the mod. However, there are too many things that I don't like to list them. basic_machines is pretty good, but basic_robots is not at all to my liking.

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Fri Feb 10, 2017 19:22
by Byakuren
Any plans to allow computations to take longer than one tick, without manual handling of program state?

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Fri Feb 10, 2017 19:47
by octacian
Byakuren wrote:Any plans to allow computations to take longer than one tick, without manual handling of program state?
EDIT: Oh, I think I did misunderstand. You're asking if computations will get lost if they take longer than one tick because the program state could be lost. From my testing, this is not an issue at all. I'll leave my original answer as it may still be relevant.

I believe that computations already can, but I may have misunderstood. What I have at the moment, is just debug.sethook(10000, ...) (may be incorrect syntax, not looking at the code right now).

I have considered assigning each player a different thread on which their computers would run. I would probably still use debug.sethook so that infinite loops wouldn't create major issues for all of the player's computers at once. However, I'm not quite sure how to assign different threads, maybe it has something to do with coroutines (which you mentioned in the basic_robots thread)? I'll have to do something related to this, though, as players can still create and copy large files also slowing the server (I haven't implemented filesystem size or max file size yet).

I have also considered using one of kaeza's "libraries" to allow assigning computers RAM. If I remember correctly, it just checks how long the code is taking to execute.

Anyways, I hope I understood correctly. I'm always opened to suggestions or even better, pull requests :P

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Sat Feb 11, 2017 05:45
by Byakuren
octacian wrote:
Byakuren wrote:Any plans to allow computations to take longer than one tick, without manual handling of program state?
EDIT: Oh, I think I did misunderstand. You're asking if computations will get lost if they take longer than one tick because the program state could be lost. From my testing, this is not an issue at all. I'll leave my original answer as it may still be relevant.

I believe that computations already can, but I may have misunderstood. What I have at the moment, is just debug.sethook(10000, ...) (may be incorrect syntax, not looking at the code right now).

I have considered assigning each player a different thread on which their computers would run. I would probably still use debug.sethook so that infinite loops wouldn't create major issues for all of the player's computers at once. However, I'm not quite sure how to assign different threads, maybe it has something to do with coroutines (which you mentioned in the basic_robots thread)? I'll have to do something related to this, though, as players can still create and copy large files also slowing the server (I haven't implemented filesystem size or max file size yet).

I have also considered using one of kaeza's "libraries" to allow assigning computers RAM. If I remember correctly, it just checks how long the code is taking to execute.

Anyways, I hope I understood correctly. I'm always opened to suggestions or even better, pull requests :P
An example would be something like

Code: Select all

while true do
  x = x + 1
end
And not have it get interrupted, if it doesn't finish in one frame it just continues in the next.

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Sun Feb 12, 2017 02:03
by octacian
Byakuren wrote: An example would be something like

Code: Select all

while true do
  x = x + 1
end
And not have it get interrupted, if it doesn't finish in one frame it just continues in the next.
Ah, I understand. First off, executing a command like that will cause the computer to time out, rather than creating any major issues.

Second, from my knowledge, this isn't an issue in the first place. Unless I am mistaken about the actual design of Lua put into Minetest, my setup causes this to be a non-issue. Code is provided as a string and executed in the environment (I assume you've got that part), when executing a file, I simply read the file and provide the code (yeah, IK there's other ways to do it, but this turned out to be the best).

Now, a single command would not cause an issue in the first place, I think what you're getting at is if a "larger" command were executed. Well, from my testing, in the current setup the code below will time out have 237 iterations. Now, if I were to disable the timeout, the code would continue to execute even if Minetest were to freeze. After Minetest had recovered, I would then find that the execution would be complete.

Code: Select all

for i=1,10000 do print(i) end
So, I'm not sure if the above covers your question or not. Are you suggesting that I implement some method to allow a long loop like that to continue executing without causing Minetest to freeze? If yes, then, I have no idea how and am open for suggestions :D

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Sun Feb 12, 2017 08:40
by Byakuren
octacian wrote:
Byakuren wrote: An example would be something like

Code: Select all

while true do
  x = x + 1
end
And not have it get interrupted, if it doesn't finish in one frame it just continues in the next.
Ah, I understand. First off, executing a command like that will cause the computer to time out, rather than creating any major issues.

Second, from my knowledge, this isn't an issue in the first place. Unless I am mistaken about the actual design of Lua put into Minetest, my setup causes this to be a non-issue. Code is provided as a string and executed in the environment (I assume you've got that part), when executing a file, I simply read the file and provide the code (yeah, IK there's other ways to do it, but this turned out to be the best).

Now, a single command would not cause an issue in the first place, I think what you're getting at is if a "larger" command were executed. Well, from my testing, in the current setup the code below will time out have 237 iterations. Now, if I were to disable the timeout, the code would continue to execute even if Minetest were to freeze. After Minetest had recovered, I would then find that the execution would be complete.

Code: Select all

for i=1,10000 do print(i) end
So, I'm not sure if the above covers your question or not. Are you suggesting that I implement some method to allow a long loop like that to continue executing without causing Minetest to freeze? If yes, then, I have no idea how and am open for suggestions :D
I've implemented it as a C module here: https://github.com/raymoo/datamine/blob ... reempter.c

The key is to set a debug hook that forces the thread to yield, instead of error out. It's necessary to do this in C rather than Lua, because the C Lua API's debug hook setters are a little bit different from Lua's, so that it's possible to yield in them. You cannot use coroutine.yield through a debug.sethook hook.

If you go that route though your mod will require mod trust to run.

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Fri Mar 03, 2017 00:35
by BBmine
Octacian's TODO List:
Add LAN - Ethernet or Wi-Fi switches to connect them. The Wi-Fi switch must be X nodes from the computer or it won't be connected to the LAN.

Add Routers. Routers must be connected to other routers with fiber-optics cables to make an Internet.

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Sun Mar 05, 2017 18:46
by octacian
BBmine wrote:Octacian's TODO List:
Add LAN - Ethernet or Wi-Fi switches to connect them. The Wi-Fi switch must be X nodes from the computer or it won't be connected to the LAN.

Add Routers. Routers must be connected to other routers with fiber-optics cables to make an Internet.
Internet of some type will be coming soon, I have other things to fix here first, though. Plus, I've been pretty busy with MicroExpansion as of late. I haven't forgotten about this though :D

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Tue Jun 06, 2017 11:27
by Web_44
Wow. This is a great mod. I found it because of your video. I will test this Mod soon and maybe use it for my Server. Keep working on it.
I am a Mod Programmer too so maybe I'll try to make some code for this Mod.

Re: [Mod] Functional Lua Computers [0.5.2] [digicompute]

Posted: Thu Jun 22, 2017 17:17
by BBmine
Um... I finnally got around to testing this. Is there a command to list files and folders? Also, how would I edit a file?