Commit 22d045fc authored by Petter Reinholdtsen's avatar Petter Reinholdtsen

New upstream version 0.12

parents
The MIT License (MIT)
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)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# raspberryjammod-minetest
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,
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
The MIT License (MIT)
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, 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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
if minetest.request_insecure_environment then
ie = minetest.request_insecure_environment()
else
ie = _G
end
--[[--------------------------------------------------------------------------
The MIT License (MIT)
Copyright (c) 2014 Mark Rogaski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
----------------------------------------------------------------------------
This software includes portions of base64.lua, available at:
https://gist.github.com/paulmoore/2563975
Copyright (C) 2012 by Paul Moore
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
--]]--------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Package Definition
----------------------------------------------------------------------------
local Base64 = {}
----------------------------------------------------------------------------
-- Imports
----------------------------------------------------------------------------
bit = ie.require("bit")
local band, bor, lshift, rshift = bit.band, bit.bor, bit.lshift, bit.rshift
----------------------------------------------------------------------------
-- Constants and tables
----------------------------------------------------------------------------
local ENCODE = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' --- ARP: changed to Mime version
}
local DECODE = {}
for i, c in ipairs(ENCODE) do
DECODE[c] = i - 1
end
----------------------------------------------------------------------------
-- Utility functions
----------------------------------------------------------------------------
--- Converts a 6-bit octet into the associated Base64 character.
--
-- @param octet A 6-bit integer.
-- @return The Base64 representation of the character
local function toChar(octet)
return assert(ENCODE[octet + 1], "No Base64 character for octet: " .. tostring(octet))
end
--- Converts a Base64 character into the associated octet.
--
-- @param char The single Base64 character.
-- @return The 6-bit integer representing the Base64 character.
local function toOctet(char)
return assert(DECODE[char], "Not a valid Base64 character: " .. tostring(char))
end
----------------------------------------------------------------------------
-- User functions
----------------------------------------------------------------------------
--- Encodes a string into a Base64 string.
-- The input can be any string of arbitrary bytes.
-- If the input is not a string, or the string is empty, an error will be thrown.
--
-- @param input The input string.
-- @return The Base64 representation of the input string.
function Base64.encode(sInput)
assert(type(sInput) == "string", "Invalid input, expected type string but got: " .. tostring(sInput) .. " as a: " .. type(sInput))
assert(#sInput > 0, "Invalid input, cannot encode an empty string.")
local b = { sInput:byte(1, #sInput) }
local tOutput = {}
for i = 1, #b, 3 do
local c = {}
c[1] = rshift(b[i], 2)
if b[i + 1] ~= nil then
c[2] = band(lshift(b[i], 4) + rshift(b[i + 1], 4), 0x3F)
if b[i + 2] ~= nil then
c[3] = band(lshift(b[i + 1], 2) + rshift(b[i + 2], 6), 0x3F)
c[4] = band(b[i + 2], 0x3F)
else
c[3] = band(lshift(b[i + 1], 2), 0x3F)
end
else
c[2] = band(lshift(b[i], 4), 0x3F)
end
for j = 1, 4 do
if c[j] ~= nil then
tOutput[#tOutput + 1] = toChar(c[j])
else
tOutput[#tOutput + 1] = '='
end
end
end
return table.concat(tOutput)
end
--- Decodes a Base64 string into an output string of arbitrary bytes.
-- If the input is not a string, or the string is empty, or the string is not well-formed Base64, an error will be thrown.
--
-- @param input The Base64 input to decode.
-- @return The decoded Base64 string, as a string of bytes.
function Base64.decode (sInput)
assert(type(sInput) == "string", "Invalid input, expected type string but got: " .. tostring(sInput) .. " as a: " .. type(sInput))
assert(#sInput > 0, "Invalid input, cannot decode an empty string.")
local tOutput = {}
for i = 1, #sInput, 4 do
local block, pad = string.gsub(string.sub(sInput, i, i + 3), '=', '')
local buffer, b = 0, 0
for j = 1, 4 - pad do
b = toOctet(string.sub(block, j, j))
b = lshift(b, (4 - j) * 6)
buffer = bor(buffer, b)
end
for j = 1, 3 - pad do
b = rshift(buffer, (3 - j) * 8) % 256
tOutput[#tOutput + 1] = string.char(b)
end
end
return table.concat(tOutput)
end
----------------------------------------------------------------------------
-- Package Registration
----------------------------------------------------------------------------
--Apollo.RegisterPackage(Base64, "Encoding:Base64-1.0", 1, {})
return Base64
\ No newline at end of file
This diff is collapsed.
default
wool
farming?
doors?
flowers?
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.
\ No newline at end of file
This diff is collapsed.
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.
mcpipy
======
Python scripts for controlling Minecraft Pi Edition on Raspberry Pi, as highlighted at mcpipy.com
This is a collection of python scripts that can be used to control Minecraft Pi Edition running on Raspberry Pi, or alternatively on a CraftBukkit server using the RaspberryJuice plugin.
Most (if not all) of the scripts are NOT of my own creation, but rather were created by others and collected to make it easy for others to enjoy them. The scripts are unmodified with a few exceptions:
1. A comment was added near the top of each file noting the author and original URL where it was posted.
2. The mcpi python libraries are assumed to be in the "mcpi" folder and require this as a prefix to import. As needed, scripts are updated to comply with this.
3. Minor formatting/bug fixing may be done to make the script run.
Thanks to everyone who has written with the scripts and I hope you enjoy it!
If you have questions or comments, email me at mcpipy at mcpipy.com or via twitter @mcpipy
# mcpipy.com retrieved from URL below, written by astrotutor
# http://www.minecraftforum.net/topic/1698103-camerasetpos-not-working-magic-trick/
import mcpi.minecraft as minecraft
import mcpi.block as block
import time as time
mc = minecraft.Minecraft.create()
# Find player position
playerPos = mc.player.getPos()
#Find block type below player
Block = mc.getBlock(playerPos.x, playerPos.y - 1, playerPos.z)
# Set camera to above player position
mc.camera.setFollow()
# Build 1st wall across in front to right
length = 0
height = 0
while length < 5:
mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 4)
while height < 3:
mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 4)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Build second wall on right towards
length = 0
height = 0
while length < 4:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 4)
while height < 3:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 4)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Build third wall on left towards
length = 0
height = 0
while length < 4:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2, 4)
while height < 3:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2 , 4)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Build last wall behind to right
length = 0
height = 0
while length < 3:
mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 4)
while height < 3:
mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 4)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Build the roof
length = 1
width = 0
while length < 4:
while width < 3:
mc.setBlock(playerPos.x + 2 - length, playerPos.y + 2, playerPos.z - 1 + width, 5)
time.sleep(0.2)
width += 1
length += 1
width = 0
# Create void below house
length = 1
width = 0
while length < 4:
while width < 3:
mc.setBlock(playerPos.x + 2 - length, playerPos.y - 2, playerPos.z - 1 + width, 0)
time.sleep(0.2)
width += 1
length += 1
width = 0
length = 1
width = 0
while length < 4:
while width < 3:
mc.setBlock(playerPos.x + 2 - length, playerPos.y - 3, playerPos.z - 1 + width, 0)
time.sleep(0.2)
width += 1
length += 1
width = 0
# Remove the floor
length = 1
width = 0
while length < 4:
while width < 3:
mc.setBlock(playerPos.x + 2 - length, playerPos.y - 1, playerPos.z - 1 + width, 0)
time.sleep(0.2)
width += 1
length += 1
width = 0
# Build the floor
length = 1
width = 0
while length < 4:
while width < 3:
mc.setBlock(playerPos.x + 2 - length, playerPos.y - 1, playerPos.z - 1 + width, Block)
time.sleep(0.2)
width += 1
length += 1
width = 0
# Remove the roof
length = 1
width = 0
while length < 4:
while width < 3:
mc.setBlock(playerPos.x + 2 - length, playerPos.y + 2, playerPos.z - 1 + width, 0)
time.sleep(0.2)
width += 1
length += 1
width = 0
# Remove 1st wall across in front to right
length = 0
height = 0
while length < 5:
mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 0)
while height < 3:
mc.setBlock(playerPos.x + 2, playerPos.y + height, playerPos.z - 2 + length, 0)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Remove second wall on right towards
length = 0
height = 0
while length < 4:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 0)
while height < 3:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z + 2, 0)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Remove third wall on left towards
length = 0
height = 0
while length < 4:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2, 0)
while height < 3:
mc.setBlock(playerPos.x + 1 - length, playerPos.y + height, playerPos.z - 2 , 0)
time.sleep(0.2)
height += 1
length += 1
height = 0
# Remove last wall behind to right
length = 0
height = 0
while length < 3:
mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 0)
while height < 3:
mc.setBlock(playerPos.x - 2, playerPos.y + height, playerPos.z - 1 + length, 0)
time.sleep(0.2)
height += 1
length += 1
height = 0
\ No newline at end of file
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.)
#www.stuffaboutcode.com
#Raspberry Pi, Minecraft Bombs - Turn any block into a bomb!
#import the minecraft.py module from the minecraft directory
import mcpi.minecraft as minecraft
#import minecraft block module
import mcpi.block as block
#import time, so delays can be used
import time
#import threading, so threads can be used
import threading
class ExplodingBlock(threading.Thread):
def __init__(self, pos, fuseInSecs, blastRadius):
#Setup object
threading.Thread.__init__(self)
self.pos = pos
self.fuseInSecs = fuseInSecs
self.blastRadius = blastRadius
def run(self):
#Open connect to minecraft