Skip to content

Linux support #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
__pycache__
*.pyc
_sunfish.py
raspberrymint/mcpipy/models/*.gz
raspberrymint/mcpipy/models/*.obj
raspberrymint/mcpipy/vehicles/*.schematic
raspberrymint/mcpipy/models/*.bak
90 changes: 84 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,89 @@
# raspberryjammod-minetest
Raspberry Jam Mod for Minetest
# rasPberrY MinT
#### formerly Raspberry Jam Mod for Minetest

Implements most of Raspberry PI Minecraft API in Minetest.

If you have secure.enable_security = true in minetest.conf, then make sure you have raspberryjammod
listed under secure.trusted_mods. Raspberry Jam Mod cannot be rewritten without needing to be trusted,
Original project by [Alexander Pruss](https://github.com/arpruss)

## Intro
This fork was started to add Linux servers support.

## Setup
Copy or link the `raspberrymint` dir into your `minetest/mods` dir, or into your game `mods` dir.

If you have `secure.enable_security = true` in `minetest.conf` (recommended),
then make sure you have `raspberrymint` listed under `secure.trusted_mods`.
Raspberry Mint cannot be rewritten without needing to be trusted,
because of the following essential features:
- loading tcp/ip socket dynamic library
- executing and terminating python interpreter with /py command.

- executing and terminating python interpreter with `/py` command.

`minetest.conf` fragment example:

```
secure.enable_security = true
secure.trusted_mods = raspberrymint
```

### Troubleshooting
You could need to add a row on your world's `world.mt` file:

```
load_mod_raspberrymint = true
```

## Running python scripts on Minetest

Connect to your Minetest server or run a local server and **authenticate yourself** using login and password.
Be sure to have `jammer` permissions: `\grantme jammer`.

Now try with: `\py cube`. If it works try with other script in `mcpipy` directory, omit the `.py` extension.
Some scripts needs additional parameters.

## Real work/real glory
[Original Raspberry Jam Mod project](https://github.com/arpruss/raspberryjammod) - original for Minecraft

[Original Raspberry Jam Mod project](https://github.com/arpruss/raspberryjammod-minetest) - porting to Minetest

[Lua socket libraries](https://w3.impa.br/~diego/software/luasocket/)

## About lua-socket
`lua-socket` libraries use some binary files `core.dll` / `core.so`.
I add the `core.so` file from **Raspbian** official package that works on my Raspberry Pi (ARM) server.
I add the `cx64.so` file (former `core.so`) from **Ubuntu** official package that works on my x86_64 workstation.

## Why did you fork?
Raspberry Jam Mod runs on `Windows` and use `python 2.x`. Last project activity was 2 year old.

## Why did you rename the project?
Raspberry Jam Mod was on stand by from so many years that I needed to adapt the code to Minetest's _new_ security policy,
adding missing mod setup files (like `mod.conf` file) and so on.
No radical rewriting was done, but so many small changes are diffuses everywhere.
A full **Linux support** was my primary target, Windows support is not granted.
So I prefer to change mod's name because I'm not able to grant a regression-proof code.

## What's new
Raspberry Mint's Lua code is tested on Minetest 5.5.0-dev.
Raspberry Mint's Python code is now working on `Python 3.x`,
all tests and examples (but one) actually run on `Linux`, I hope them works good on `Windows` yet.

Added `jammer` permissions.

### Weak security scripts
There are two example's scripts that could run arbitrary python's code. These scripts are renamed

* `console.py.keepsafe`
* `turtleconsole.py.keepsafe`

you need to remove `.keepsafe` extension to make them work. Do it on a security and singleplayer environment only.

### NeuroSky script

I have no Neuro Sky devices on my own. So `neurosky.py` is not tested.

### Roadmap
* Make this module working in a multiplayer environment.
* Add a usage help to all modules need it.
* Add new sample scripts.
* Add new samples scripts using Turing machine's library.
* Tune up existing code.
17 changes: 0 additions & 17 deletions raspberryjammod/mcpipy/benchmark.py

This file was deleted.

150 changes: 0 additions & 150 deletions raspberryjammod/mcpipy/input.py

This file was deleted.

1 change: 0 additions & 1 deletion raspberryjammod/mcpipy/vehicles/TIE_Fighter.py

This file was deleted.

1 change: 0 additions & 1 deletion raspberryjammod/mcpipy/vehicles/X-Wing_Fighter.py

This file was deleted.

File renamed without changes.
File renamed without changes.
24 changes: 14 additions & 10 deletions raspberryjammod/base64.lua → raspberrymint/base64.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
if minetest.request_insecure_environment then
ie = minetest.request_insecure_environment()
else
ie = _G
end
-- if minetest.request_insecure_environment then
-- ie = minetest.request_insecure_environment()
-- else
-- ie = _G
-- end
--[[--------------------------------------------------------------------------

The MIT License (MIT)
Expand Down Expand Up @@ -59,11 +59,15 @@ local Base64 = {}
----------------------------------------------------------------------------

local bit
local status,err = pcall(function() bit = ie.require 'bit' end)
if not status then
bit = ie.dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/slowbit32.lua')
local band, bor, lshift, rshift = _G, _G, _G, _G

function Base64.setup(ie)
local status,err = pcall(function() bit = ie.require 'bit' end)
if not status then
bit = ie.dofile(minetest.get_modpath(minetest.get_current_modname()) .. '/slowbit32.lua')
end
band, bor, lshift, rshift = bit.band, bit.bor, bit.lshift, bit.rshift
end
local band, bor, lshift, rshift = bit.band, bit.bor, bit.lshift, bit.rshift

----------------------------------------------------------------------------
-- Constants and tables
Expand Down Expand Up @@ -183,4 +187,4 @@ end

--Apollo.RegisterPackage(Base64, "Encoding:Base64-1.0", 1, {})

return Base64
return Base64
4 changes: 4 additions & 0 deletions raspberryjammod/block.lua → raspberrymint/block.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ block.LEAVES_DARK_OAK_DECAYABLE_CD=Block(block.LEAVES2, 9)
block.LEAVES_ACACIA_PERMANENT_CD=Block(block.LEAVES2, 12)
block.LEAVES_DARK_OAK_PERMANENT_CD=Block(block.LEAVES2, 13)

block.OBSIDIAN_GLASS =Block(1001)

local to_node={}
local from_node={}

Expand Down Expand Up @@ -412,6 +414,8 @@ translate(Block(block.STONE_SLAB,14),"stairs:slab_desert_stonebrick",20)
translate(Block(block.STONE_SLAB,8),"stairs:slab_desert_stone",0) -- FIX: quartz
translate(Block(block.STONE_SLAB,15),"stairs:slab_desert_stone",20)

translate(block.OBSIDIAN_GLASS,"default:obsidian_glass")

local function defineTrapdoor(base_num,base_name)
translate(Block(base_num,0),base_name,2)
translate(Block(base_num,1),base_name,0)
Expand Down
File renamed without changes.
Loading