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

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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.
Last edited by octacian on Tue Jan 31, 2017 05:50, edited 3 times in total.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
Laser0073
Member
Posts: 59
Joined: Fri Jun 03, 2016 01:26
GitHub: Laser0073
In-game: Laser0073

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

by Laser0073 » Post

Cool! Gonna check this out...
i5 6500 OC @3.5GHz, EVGA GTX 960 4GB, 8GB DDR4, ASROCK Pro4S, 128GB.SSD, MT 0.4.17, Linux Mint 18.3 (Ubuntu 16.04)
OwOOOg9CphnceB30eUFX6BOCW8W3jT4i

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

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

by GreenXenith » Post

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.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
Sirvoid
Member
Posts: 47
Joined: Thu Feb 04, 2016 22:12
GitHub: Sirvoid
IRC: Sirvoid
In-game: Sirvoid
Location: Canada
Contact:

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

by Sirvoid » Post

... ?

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.

User avatar
TheReaperKing
Member
Posts: 531
Joined: Sun Nov 22, 2015 21:36
Contact:

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

by TheReaperKing » Post

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!
Become A Real Life Superhero - http://SuperheroHill.com
Project Lead of the Doom 3 Mod Last Man Standing - http://Doom3Coop.com
Project Lead of Platinum Arts Sandbox Free 3D Game Maker - http://SandboxGameMaker.com
Youtube Channel - https://www.youtube.com/user/PlatinumArtsKids

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

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

by maikerumine » Post

Wow...


You are a smart feller.

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

+1000
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
TumeniNodes
Member
Posts: 2941
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

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

by TumeniNodes » Post

Woohoo!!! http://www.softpedia.com/get/System/OS- ... a-OS.shtml

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

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

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

by Linuxdirk » Post

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 ...)

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

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

by hajo » Post

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"

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

hajo
Member
Posts: 606
Joined: Thu Oct 13, 2016 10:45
Location: DE
Contact:

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

by hajo » Post

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 ?

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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.
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

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

by Byakuren » Post

Any plans to allow computations to take longer than one tick, without manual handling of program state?
Every time a mod API is left undocumented, a koala dies.

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

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

by Byakuren » Post

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.
Every time a mod API is left undocumented, a koala dies.

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

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

by Byakuren » Post

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.
Every time a mod API is left undocumented, a koala dies.

BBmine
Member
Posts: 3476
Joined: Sun Jul 12, 2015 22:51
GitHub: BBmine
IRC: BBmine
In-game: Baggins
Location: USA

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

by BBmine » Post

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.

User avatar
octacian
Member
Posts: 597
Joined: Mon Dec 21, 2015 22:18
GitHub: octacian
IRC: octacian
In-game: octacian
Location: Canada

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

by octacian » Post

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
MicroExpansion, Working Computers, All Projects - Check out my YouTube channel! (octacian)
I'm currently inactive in the Minetest community! So if I don't respond, that's why.

User avatar
Web_44
Member
Posts: 17
Joined: Sat Feb 25, 2017 16:48
In-game: Web_44
Location: Germany
Contact:

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

by Web_44 » Post

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.
Admin on:
my-web.xyz Public Czech Server (by joint007)

Owner of:
Survivors Build (offline)
German Survival (WIP)

If you are German you can write me in german because im german too

BBmine
Member
Posts: 3476
Joined: Sun Jul 12, 2015 22:51
GitHub: BBmine
IRC: BBmine
In-game: Baggins
Location: USA

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

by BBmine » Post

Um... I finnally got around to testing this. Is there a command to list files and folders? Also, how would I edit a file?

Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests