Commit bd352744 authored by Petter Reinholdtsen's avatar Petter Reinholdtsen

New upstream version 0.20+git20180331.0376a0a

parent 114d4043
The MIT License (MIT)
Pycraft Mod Copyright (c) Giuseppe Menegoz (@gmenegoz) & Alessandro Norfo (@alenorfo)
RaspberryJamMod Copyright (c) 2015 Alexander R. Pruss
Lua Copyright (c) 1994–2015 Lua.org, PUC-Rio.
luasocket Copyright (c) Diego Nehab (with socket.lua changed by ARP to load x64/x86 as needed)
tools.lua adapted from lua-websockets Copyright (c) 2012 Gerhard Lipp (with base64 inactivated)
base64.lua Copyright (c) 2014 Mark Rogaski and (C) 2012 Paul Moore (changed by ARP to MIME encoding)
luasocket Copyright (c) Diego Nehab (with socket.lua changed by ARP to load x64/x86 as needed, and minetest compatibility)
tools.lua adapted from lua-websockets Copyright (c) 2012 Gerhard Lipp (with base64 inactivated and minetest compatibility)
base64.lua Copyright (c) 2014 Mark Rogaski and (C) 2012 Paul Moore (changed by ARP to MIME encoding and minetest compatibility)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
# raspberryjammod-minetest
Raspberry Jam Mod for Minetest
# Pycraft mod for Minetest
<img src="https://alessandronorfo.files.wordpress.com/2017/09/pycraft_minetest.png" alt="pycraft_minetest icon" height="360">
Implements most of Raspberry PI Minecraft API in Minetest.
This is a fork of the https://github.com/arpruss/raspberryjammod-minetest created to support Pycraft in Minetest. Thanks to Arpruss for his amazing work :)
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,
because of the following essential features:
- loading tcp/ip socket dynamic library
- executing and terminating python interpreter with /py command.
\ No newline at end of file
Alessandro Norfo (ale.norfo@gmail.com) & Giuseppe Menegoz (gmenegoz@gmail.com)
# Getting started
## WINDOWS
Download this installer: [pycraft_minetest.exe](https://github.com/sprintingkiwi/craft-with-python/releases/download/0.1/pycraft_minetest.exe)
## LINUX
* Install Minetest from your distribution's repository
* Install Lua (preferably 5.1)
* Install Luarocks for your version of Lua
* In a terminal execute this command as superuser: luarocks install luasocket
* Follow this tutorial on how to install a mod in Minetest: http://dev.minetest.net/Installing_Mods. We suggest to clone this repository inside the "mods" folder of Minetest.
* Create a world (it's better to enable creative mode)
* Click on "configure" and enable "pycraft_mod"
* Play the game
## MAC OSX
Work in progress...
win32move doesn't work
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
In socket/core.dll is a win32 Microsoft Visual C build from luasockets as well as a win64
build. Replace with something that fits your operating system if you need to.
In socket/core.dll is a win32 Microsoft Visual C build from luasockets as well as a win64
build. Replace with something that fits your operating system if you need to.
NeuroPy
=======
NeuroPy library written in python to connect, interact and get data from __neurosky's MindWave__ EEG headset.
This library is based on the minwave mindset communication protocol published by [Neurosky](http:://neurosky.com) and is tested
with Neurosky Mindwave EEG headset.
##Installation##
1. Download the source distribution (zip file) from [dist directory](https://github.com/lihas/NeuroPy/tree/master/dist)
2. unzip and navigate to the folder containing _setup.py_ and other files
3. run the following command:
`python setup.py install`
##Usage##
1. Importing the module: `from NeuroPy import NeuroPy`
2. Initialising: `object1=NeuroPy("COM6",57600)` _#windows_ <br /> `object1=NeuroPy("/dev/rfcomm0",57600)` _#linux_
Note: Add a True argument to emit the magic hex sequence for a MindFlex toy set up to run at 57600 baud
using the hack described here: http://www.instructables.com/id/Mindflex-EEG-with-raw-data-over-Bluetooth/
3. After initialising , if required the callbacks must be set
then using the start method the library will start fetching data from mindwave
i.e. `object1.start()`
similarly stop method can be called to stop fetching the data
i.e. `object1.stop()`
###The data from the device can be obtained using either of the following methods or bot of them together:###
* Obtaining value: `variable1=object1.attention` _\#to get value of attention_
>__\#other variables:__ attention,meditation,rawValue,delta,theta,lowAlpha,highAlpha,lowBeta,highBeta,lowGamma,midGamma, poorSignal and blinkStrength
* Setting callback:a call back can be associated with all the above variables so that a function is called when the variable is updated. Syntax: `setCallBack("variable",callback_function)` <br />
__for eg.__ to set a callback for attention data the syntax will be `setCallBack("attention",callback_function)`
>__\#other variables:__ attention,meditation,rawValue,delta,theta,lowAlpha,highAlpha,lowBeta,highBeta,lowGamma,midGamma, poorSignal and blinkStrength
##Sample Program##
from NeuroPy import NeuroPy
object1=NeuroPy("COM6") #If port not given 57600 is automatically assumed
#object1=NeuroPy("/dev/rfcomm0") for linux
def attention_callback(attention_value):
"this function will be called everytime NeuroPy has a new value for attention"
print "Value of attention is",attention_value
#do other stuff (fire a rocket), based on the obtained value of attention_value
#do some more stuff
return None
#set call back:
object1.setCallBack("attention",attention_callback)
#call start method
object1.start()
while True:
if(object1.meditation>70): #another way of accessing data provided by headset (1st being call backs)
object1.stop() #if meditation level reaches above 70, stop fetching data from the headset
Copyright (c) sahil singh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/
or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NeuroPy
=======
NeuroPy library written in python to connect, interact and get data from __neurosky's MindWave__ EEG headset.
This library is based on the minwave mindset communication protocol published by [Neurosky](http:://neurosky.com) and is tested
with Neurosky Mindwave EEG headset.
##Installation##
1. Download the source distribution (zip file) from [dist directory](https://github.com/lihas/NeuroPy/tree/master/dist)
2. unzip and navigate to the folder containing _setup.py_ and other files
3. run the following command:
`python setup.py install`
##Usage##
1. Importing the module: `from NeuroPy import NeuroPy`
2. Initialising: `object1=NeuroPy("COM6",57600)` _#windows_ <br /> `object1=NeuroPy("/dev/rfcomm0",57600)` _#linux_
Note: Add a True argument to emit the magic hex sequence for a MindFlex toy set up to run at 57600 baud
using the hack described here: http://www.instructables.com/id/Mindflex-EEG-with-raw-data-over-Bluetooth/
3. After initialising , if required the callbacks must be set
then using the start method the library will start fetching data from mindwave
i.e. `object1.start()`
similarly stop method can be called to stop fetching the data
i.e. `object1.stop()`
###The data from the device can be obtained using either of the following methods or bot of them together:###
* Obtaining value: `variable1=object1.attention` _\#to get value of attention_
>__\#other variables:__ attention,meditation,rawValue,delta,theta,lowAlpha,highAlpha,lowBeta,highBeta,lowGamma,midGamma, poorSignal and blinkStrength
* Setting callback:a call back can be associated with all the above variables so that a function is called when the variable is updated. Syntax: `setCallBack("variable",callback_function)` <br />
__for eg.__ to set a callback for attention data the syntax will be `setCallBack("attention",callback_function)`
>__\#other variables:__ attention,meditation,rawValue,delta,theta,lowAlpha,highAlpha,lowBeta,highBeta,lowGamma,midGamma, poorSignal and blinkStrength
##Sample Program##
from NeuroPy import NeuroPy
object1=NeuroPy("COM6") #If port not given 57600 is automatically assumed
#object1=NeuroPy("/dev/rfcomm0") for linux
def attention_callback(attention_value):
"this function will be called everytime NeuroPy has a new value for attention"
print "Value of attention is",attention_value
#do other stuff (fire a rocket), based on the obtained value of attention_value
#do some more stuff
return None
#set call back:
object1.setCallBack("attention",attention_callback)
#call start method
object1.start()
while True:
if(object1.meditation>70): #another way of accessing data provided by headset (1st being call backs)
object1.stop() #if meditation level reaches above 70, stop fetching data from the headset
Copyright (c) sahil singh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/
or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from time import time
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
t = time()
for i in range(1000):
mc.getBlock(0,0,0)
print "getBlock : {}ms".format(1000.*(time()-t)/1000.)
t = time()
for i in range(10000):
mc.setBlock(0,0,0,1)
mc.getBlock(0,0,0)
print "setBlock same : {}ms".format(1000.*(time()-t)/10000.)
t = time()
for i in range(10000):
mc.setBlock(0,0,0,i&1)
mc.getBlock(0,0,0)
print "setBlock different : {}ms".format(1000.*(time()-t)/10000.)
from time import time
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
t = time()
for i in range(1000):
mc.getBlock(0,0,0)
print "getBlock : {}ms".format(1000.*(time()-t)/1000.)
t = time()
for i in range(10000):
mc.setBlock(0,0,0,1)
mc.getBlock(0,0,0)
print "setBlock same : {}ms".format(1000.*(time()-t)/10000.)
t = time()
for i in range(10000):
mc.setBlock(0,0,0,i&1)
mc.getBlock(0,0,0)
print "setBlock different : {}ms".format(1000.*(time()-t)/10000.)
from mc import *
import pygame.camera
from time import sleep
from sys import argv
COLORS = ( (35,0, 222,222,222),
(35,1, 219,125,63),
(35,2, 180,81,189),
(35,3, 107,138,201),
(35,4, 177,166,39),
(35,5, 66,174,57),
(35,6, 208,132,153),
(35,7, 64,64,64),
(35,8, 155,161,161),
(35,9, 47,111,137),
(35,10, 127,62,182),
(35,11, 46,57,142),
(35,12, 79,50,31),
(35,13, 53,71,27),
(35,14, 151,52,49),
(35,15, 26,22,22),
(159,0,210,178,161),
(159,1,162,84,38),
(159,2,150,88,109),
(159,3,113,109,138),
(159,4,186,133,35),
(159,5,104,118,53),
(159,6,162,78,79),
(159,7,58,42,36),
(159,8,135,107,98),
(159,9,87,91,91),
(159,10,118,70,86),
(159,11,74,60,91),
(159,12,77,51,36),
(159,13,76,83,42),
(159,14,143,61,47),
(159,15,37,23,16),
(155,0,232,228,220),
(152,0,164,26,9),
(41,0,250,239,80),
(173,0,19,19,19) )
def colorDist(a,b):
return (a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])
def getBestColor(rgb):
bestColor = COLORS[0]
bestDist = 255*255*3
for c in COLORS:
d = colorDist(c[2:],rgb)
if d < bestDist:
bestDist = d
bestColor = c
return bestColor
mc = Minecraft()
pos = mc.player.getTilePos()
dither = True
width = 80
if len(argv) >= 2:
width = int(argv[1])
height = width * 3 // 4
pygame.camera.init()
camlist = pygame.camera.list_cameras()
if camlist:
cam = pygame.camera.Camera(camlist[0],(640,480))
current = [[(-1,-1) for y in range(height)] for x in range(width)]
while True:
image = pygame.transform.scale(cam.get_image(), (width,height))
if not dither:
for x in range(width):
for y in range(height):
block = getBestColor(image.get_at((x,y)))[0:2]
if current[x][y] != block:
mc.setBlock(pos.x+x,pos.y+height-1-y,pos.z,block)
current[x][y] = block
else:
pixels = [[list(image.get_at((x,y))[0:3]) for y in range(height)] for x in range(width)]
for x in range(width):
for y in range(height):
color = getBestColor(pixels[x][y])
block = color[0:2]
if current[x][y] != block:
mc.setBlock(pos.x+x,pos.y+height-1-y,pos.z,block)
current[x][y] = block
for i in range(3):
err = pixels[x][y][i] - color[2+i]
if x + 1 < width:
pixels[x+1][y][i] += err * 7 // 16
if y + 1 < height:
if 0 < x:
pixels[x-1][y+1][i] += err * 3 // 16
pixels[x][y+1][i] += err * 5 // 16
if x + 1 < width:
pixels[x+1][y+1][i] += err // 16
else:
mc.postToChat('Camera not found')
from mc import *
import pygame.camera
from time import sleep
from sys import argv
COLORS = ( (35,0, 222,222,222),
(35,1, 219,125,63),
(35,2, 180,81,189),
(35,3, 107,138,201),
(35,4, 177,166,39),
(35,5, 66,174,57),
(35,6, 208,132,153),
(35,7, 64,64,64),
(35,8, 155,161,161),
(35,9, 47,111,137),
(35,10, 127,62,182),
(35,11, 46,57,142),
(35,12, 79,50,31),
(35,13, 53,71,27),
(35,14, 151,52,49),
(35,15, 26,22,22),
(159,0,210,178,161),
(159,1,162,84,38),
(159,2,150,88,109),
(159,3,113,109,138),
(159,4,186,133,35),
(159,5,104,118,53),
(159,6,162,78,79),
(159,7,58,42,36),
(159,8,135,107,98),
(159,9,87,91,91),
(159,10,118,70,86),
(159,11,74,60,91),
(159,12,77,51,36),
(159,13,76,83,42),
(159,14,143,61,47),
(159,15,37,23,16),
(155,0,232,228,220),
(152,0,164,26,9),
(41,0,250,239,80),
(173,0,19,19,19) )
def colorDist(a,b):
return (a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])
def getBestColor(rgb):
bestColor = COLORS[0]
bestDist = 255*255*3
for c in COLORS:
d = colorDist(c[2:],rgb)
if d < bestDist:
bestDist = d
bestColor = c
return bestColor
mc = Minecraft()
pos = mc.player.getTilePos()
dither = True
width = 80
if len(argv) >= 2:
width = int(argv[1])
height = width * 3 // 4
pygame.camera.init()
camlist = pygame.camera.list_cameras()
if camlist:
cam = pygame.camera.Camera(camlist[0],(640,480))
current = [[(-1,-1) for y in range(height)] for x in range(width)]
while True:
image = pygame.transform.scale(cam.get_image(), (width,height))
if not dither:
for x in range(width):
for y in range(height):
block = getBestColor(image.get_at((x,y)))[0:2]
if current[x][y] != block:
mc.setBlock(pos.x+x,pos.y+height-1-y,pos.z,block)
current[x][y] = block
else:
pixels = [[list(image.get_at((x,y))[0:3]) for y in range(height)] for x in range(width)]
for x in range(width):
for y in range(height):
color = getBestColor(pixels[x][y])
block = color[0:2]
if current[x][y] != block:
mc.setBlock(pos.x+x,pos.y+height-1-y,pos.z,block)
current[x][y] = block
for i in range(3):
err = pixels[x][y][i] - color[2+i]
if x + 1 < width:
pixels[x+1][y][i] += err * 7 // 16
if y + 1 < height:
if 0 < x:
pixels[x-1][y+1][i] += err * 3 // 16
pixels[x][y+1][i] += err * 5 // 16
if x + 1 < width:
pixels[x+1][y+1][i] += err // 16
else:
mc.postToChat('Camera not found')
......@@ -18,6 +18,12 @@ def getHeightBelow(x,y,z):
return min(mc.getHeight(x,z),y)
def rectangularPrism(x1,y1,z1, x2,y2,z2, distribution):
x1 = int(round(x1))
y1 = int(round(y1))
z1 = int(round(z1))
x2 = int(round(x2))
y2 = int(round(y2))
z2 = int(round(z2))
for x in range(min(x1,x2),max(x1,x2)+1):
for y in range(min(y1,y2),max(y1,y2)+1):
for z in range(min(z1,z2),max(z1,z2)+1):
......
This diff is collapsed.
#
# WARNING: If you're running RJM on a server, do NOT include this script server-side for security reasons.
#
#
# Code under the MIT license by Alexander Pruss
#
......@@ -26,6 +30,8 @@ def inputLine(prompt):
return 'quit()'
elif c.message == ' ':
return ''
elif "__" in c.message:
sys.exit();
else:
return c.message
time.sleep(0.2)
......
#!/usr/bin/env python
#
from math import sin, cos, radians
import danielbates_minecraft_basic as mc
#
# By Daniel Bates, with minor adaptations by Alexander Pruss
#
from mc import *
#import pygame.image # comment this out if not using images - it's slow to import. If you uncomment, uncomment the image reference below.
import random
import server
......@@ -283,7 +286,7 @@ def officeblock(wallmaterial):
goody = (point.y%5 == 1) or (point.y%5 == 2)
goodz = (point.z%5 == 1) or (point.z%5 == 2)
if (goodx and goody) or (goodz and goody):
return mc.GLASS
return GLASS
else:
return wallmaterial
return f
......@@ -313,13 +316,13 @@ def tomaterial(r,g,b):
# Just a quick hack for now - could of course add more colours
# and a way of finding the nearest supported colour.
if (r,g,b) == (255,255,255): # white
return mc.AIR
return AIR
elif (r,g,b) == (0,0,0): # black
return mc.OBSIDIAN
return OBSIDIAN
elif (r,g,b) == (188,17,66): # pink
return mc.REDSTONE_ORE
return REDSTONE_ORE
elif (r,g,b) == (117,169,40): # green
return mc.MELON
return MELON
else:
return None
......@@ -374,61 +377,62 @@ by multiplying them together.
fillfunc = solid(material)
for point in shape:
point2 = transform * point
mc.setblock(int(point2.x), int(point2.y), int(point2.z), fillfunc(point))
mc.setBlock(int(point2.x), int(point2.y), int(point2.z), fillfunc(point))
def clear(shape, transform=identity()):
"""Remove any non-air blocks in the given shape."""
fillshape(shape,transform,mc.AIR)
fillshape(shape,transform,AIR)
def main():
global mc
"""Function used to build my demo world. Extra clearing may be required for
hilly worlds."""
mc.connect(server.address)
mc = Minecraft()
# Create a large empty space with a neat, grassy floor. Takes a long time!
clear(cuboid(100,10,120))
fillshape(floor(100,120), shift(0,-1,0), material=mc.GRASS)
fillshape(floor(100,120), shift(0,-1,0), material=GRASS)
# Introduce basic shapes/transformations/fill functions.
fillshape(arrow, material=mc.STONE)
fillshape(arrow, shift(6,0,0), mc.STONE)
fillshape(arrow, shift(12,0,0)*rotationx(90), mc.STONE)
fillshape(arrow, shift(18,0,0)*rotationx(45), mc.STONE)
fillshape(arrow, shift(24,0,0), fillfunc=chequers(mc.WOOD, mc.STONE))
fillshape(arrow, material=STONE)
fillshape(arrow, shift(6,0,0), STONE)
fillshape(arrow, shift(12,0,0)*rotationx(90), STONE)
fillshape(arrow, shift(18,0,0)*rotationx(45), STONE)
fillshape(arrow, shift(24,0,0), fillfunc=chequers(WOOD, STONE))
# Introduce generator functions.
fillshape(cuboid(4,4,4), shift(30,0,0), mc.STONE)
fillshape(cuboid(3,8,2), shift(36,0,0), mc.STONE)
fillshape(cuboid(4,4,4), shift(30,0,0), STONE)
fillshape(cuboid(3,8,2), shift(36,0,0), STONE)
# Show other simple shapes.
fillshape(sphere(5), shift(45,5,0), mc.STONE)
fillshape(pyramid(5), shift(50,0,0), mc.STONE)
fillshape(cylinder(5,4), shift(65,0,0), mc.STONE)
fillshape(cone(5,5), shift(75,0,0), mc.STONE)
fillshape(sphere(5), shift(45,5,0), STONE)
fillshape(pyramid(5), shift(50,0,0), STONE)
fillshape(cylinder(5,4), shift(65,0,0), STONE)
fillshape(cone(5,5), shift(75,0,0), STONE)
# Show some fill functions.
fillshape(cuboid(4,4,4), shift(80,0,5), fillfunc=chequers(mc.GOLD, mc.IRON))
fillshape(pyramid(5), shift(80,0,10), fillfunc=randomfill([mc.SAND, mc.SANDSTONE]))
fillshape(hollowcuboid(4,6,4), shift(80,0,22), mc.WOOD_PLANK)
fillshape(building(2,6,2), shift(80,0,30), fillfunc=officeblock(mc.COBBLESTONE))
fillshape(cuboid(4,4,4), shift(80,0,5), fillfunc=chequers(GOLD_BLOCK, IRON_BLOCK))
fillshape(pyramid(5), shift(80,0,10), fillfunc=randomfill([SAND, SANDSTONE]))
fillshape(hollowcuboid(4,6,4), shift(80,0,22), WOOD)