[Recommend me anything] Computer mod

Post Reply
User avatar
vqrulane
Member
Posts: 17
Joined: Thu Dec 13, 2012 16:33

[Recommend me anything] Computer mod

by vqrulane » Post

I bring teh computers to minetest!
Can you recommend me what should I add to my mod?
Currently teh computer can into:
  • Supporting simple 9x9 screen made out of wool blocks
  • Command line with some simple commands
  • Calculator

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

You did not, theres a computer in technic.

I am working on a Z80 (or 6502) computer for minetest.

But i want to know how do you plan to interface your computer to ingame objects.
Last edited by aldobr on Tue Jan 21, 2014 16:41, edited 1 time in total.

User avatar
vqrulane
Member
Posts: 17
Joined: Thu Dec 13, 2012 16:33

by vqrulane » Post

You did not, theres a computer in technic.
>:C
I am working on a Z80 (or 6502) computer for minetest.
>>:C
t i want to know how do you plan to interface your computer
D:<

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

My mod works only on linux, maybe you might be interested in an javascript source code that if translated to lua would allow emulating a 6502 computer.

If you do the translation i can work on porting the microsoft basic to it.

Currently i am working with lib6502 which is a unix only 6502 emulator library. A 6502 emulator written
in Lua would be portable across windows and linux and thus more desirable.

On the other front i still dont know how to interface the microprocessor core to the minetest "real world".

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

vqrulane wrote:I bring teh computers to minetest!
Can you recommend me what should I add to my mod?
Currently teh computer can into:
  • Supporting simple 9x9 screen made out of wool blocks
  • Command line with some simple commands
  • Calculator
Give it a spell-checker that changes "teh" to "the".

markveidemanis
Member
Posts: 211
Joined: Thu Sep 27, 2012 15:41

by markveidemanis » Post

PilzAdam wrote:
vqrulane wrote:I bring teh computers to minetest!
Can you recommend me what should I add to my mod?
Currently teh computer can into:
  • Supporting simple 9x9 screen made out of wool blocks
  • Command line with some simple commands
  • Calculator
Give it a spell-checker that changes "teh" to "the".
Maybe the mod is called "teh computers".He has used it twice in the same context.
BitCoin: 1Eq4arvykGNa1YC2DbJpWcwGfMvtFGjAoR

User avatar
Dopium
Member
Posts: 233
Joined: Sat Jun 09, 2012 15:43
Location: Australia

by Dopium » Post

aldobr wrote:My mod works only on linux, maybe you might be interested in an javascript source code that if translated to lua would allow emulating a 6502 computer.

If you do the translation i can work on porting the microsoft basic to it.

Currently i am working with lib6502 which is a unix only 6502 emulator library. A 6502 emulator written
in Lua would be portable across windows and linux and thus more desirable.

On the other front i still dont know how to interface the microprocessor core to the minetest "real world".
You know assembly language for the 6502? I am learning assembly for the 6502 at the moment, still novice stages but it seems to be a language that i can grasp and enjoy.

Stella is a great open source emulator written in C++ for the Atari 2600(6507) it uses some amazing methods to mimic the original hardware and a CRT television(from what guru's have said). Having a look through the source may give you some ideas if you're any good at C++.

Very interested in a 6502 based computer on minetest, i grew up with these beasts.
Running @1.19 MHz, 128 bytes of RAM and interchangeable 4kb ROM carts!

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

@Dopium

no, i dont know 6502 assembly, i only know general uP programming and i have a superficial knowledge of the 6502.

@vqrulane

https://gitorious.org/fooble/modplayjs/ ... cpu6502.js

this is the 6502 emulator in javascript. Keep in mind that lua has no bitwise logical operators, so you will have to use a library that implements this.

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

by BrunoMine » Post

I waited so much for this!

Button news (for servers)

Email button (for servers)

Annotation button
My small square universe under construction ... Minemacro
Comunidade Minetest Brasil
www.minetestbrasil.com

gsmanners
Member
Posts: 159
Joined: Fri Jan 10, 2014 21:37

by gsmanners » Post

There's also a PC in the craft guide mod.

like2omg
Member
Posts: 37
Joined: Sat Nov 30, 2013 20:12

by like2omg » Post

I would like to make something like that, but I'd rather have a replica of the Minecraft mod titled ComputerCraft.

Issues I see which are probably not found in the Minecraft version of the mod:

Mesecons-related (Minecraft has it good with Redstone at its best; we don't):
  • With how it is already hard to have Mesecons' block push/pullers keep a block's data intact after moving, I think ComputerCraft's Turtles are out of the question for now
  • Having the Mesecons receptor/effector thing working correctly
Single Player- / Server-related:
  • Making the code work as separate threads (forked processes is not a good idea at all!)
  • Sanity in sandboxing the code and for file saving and loading locations (any time in the process of finding a path that goes above the computer's directory should be, after verifying previous directories in the prefix are valid, stripped of that prefix)
  • All other things that would result in running code in Lua without a Java container
You can actually find the code for the ComputerCraft computers in their mod file downloads as unencrypted .lua files. Homepage is (to prevent them from finding this post, I'll "edit" the url so it doesn't auto-hotlink) www(dawt)computercraft(dawt)info

Hmm... I'll try to create my version of this now... I know the code I use to ""patch"" theirs to work with Minetest will be messy as *bleep* though... Unfortunately I cannot share this as it violates their license (I assume)

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

Running lua inside lua is dangereous due to lack of sandoboxing.

like2omg
Member
Posts: 37
Joined: Sat Nov 30, 2013 20:12

by like2omg » Post

The only sandboxing that is possible is
  1. Put it in a subprocess
  2. Manipulate (create) its library of allowed calls (read: its global environment)
  3. Make certain calls safer (like where it is allowed to open a file)
  4. Restrict runtime that it does without yielding
  5. Impose other limits that the ComputerCraft mod does not (like how many computers can be running at once, how many a player can make, etc.)
Just a basic rundown that is possible... but it WILL cause the server to slow down just like the Minecraft modpack Tekkit Classic did with them running (so it's a no-go for older hardware).

EDIT 2: It is possible to sandbox. The last one is the only one NOT implemented in ComputerCraft, the others are all done in Lua. (I read the mod's .lua file and also found a sandboxing thing on I think the Lua Users website)

EDIT 4(?): Done editing
Last edited by like2omg on Thu Jan 23, 2014 19:27, edited 1 time in total.

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

(Keep in mind that there are always variables that i can be ignoring).

The problem with lua is that the script is free to do calls like "os.fopen".

worse, we can call arbitrary libraries.

Solving this would equal to rewriting the whole lua library.

Its doable ? Yes, but who will spare his time to do this ?

I wont.

On the other hand, we might very well stumble upon someone else's work in that area. That would be a lot of luck.

PS.: I am currently divided between emulating a processor and them running a interpreter inside that processor, or, using something like this http://xmojmr.ohmygod.cz/software/Chip/ to have a interpreter in native x86 code (so removing the slow 6502 emulation).

chipmunk basic would be much better than 6502 mbasic running in a emulator.

Even better, any interpreter that can be called via a library call can be embedded inside lua via luaffi. Thats where i am planning right now.

I can even write a interpreter for a new language, provided you or someone else give me a EBNF description (it must be a simple language due to time to code constraints), embeded it on a .so/.dll and package it into a mod.
Last edited by aldobr on Thu Jan 23, 2014 20:49, edited 1 time in total.

like2omg
Member
Posts: 37
Joined: Sat Nov 30, 2013 20:12

by like2omg » Post

aldobr wrote:The problem with lua is that the script is free to do calls like "os.fopen".

worse, we can call arbitrary libraries.

Solving this would equal to rewriting the whole lua library.
Complete rewrite? No. Rewriting and removing certain hazardous default system calls in a new subprocess' global table? Yes.
If you find what I found online, it would entail giving a new subprocess a customized table for its own global variables. With this method, we can remove 100% unsafe calls and create modified calls for somewhat unsafe calls (limiting what can be opened by overriding ALL the file opening calls, redirecting the default input/output locations so we don't get a hang when someone tries to get the server to input a string at the console, etc.)

But like you worded it (with a /ignoring/ignoring or forgetting/ instead)...
aldobr wrote:(Keep in mind that there are always variables that i can be ignoring).

And I could attempt to help out, but it would be plagerization as I would be copying a lot of raw code from the CC mod (I'll try to call the ComputerCraft mod as "CC" from now on in this thread)

P.S. I hope I'm not attempting to force my opinion (as I do such things irl), but I appreciate how well you have responded (nicely). Thank you :-)

*begin really off-topic + end of post*
is you username just short for "Aldo
" or am I just pulling you leg unintentionally with this messing around?

User avatar
aldobr
Member
Posts: 316
Joined: Sun Nov 25, 2012 05:46

by aldobr » Post

its aldobr because its Aldo Brasil, i am from Brazil.

I~=Spam
New member
Posts: 9
Joined: Fri Apr 18, 2014 16:17

by I~=Spam » Post

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests