Spoiler
I have been working on an adventure peripheral for the past several days pretty much nonstop, and I am fairly happy with the result. It has many functions which could be useful to map makers, although so far SMP is not fully supported (I will attempt to work on that, but it's not a priority right now).
Changelog
V1.5 Changelog
- Modified the method of retrieving computer/turtle coordinates (No longer hit and miss)
- Added the peripheral.getDirection() function
V1.4 Changelog (Skipped a version because of bugs)
- Can now retrieve block metadata
- Can now create explosions (awww yeah)
- Fixed a bug with finding the computer location.
- Other minor bug fixes
V1.2 Changelog
Spoiler
- Added the option to set block metadata- Added three new functions: peripheral.say(), peripheral.createFireball(), and peripheral.playerLooking(). See the functions list for more info
Disclaimer
This peripheral was not created to be a legit tool (although you can use it that way if you want). It is aimed towards map makers and perhaps structure building
Functions List
peripheral.getBlock(int x, int y, int z) --Returns the id and metadata at the specified x,y,z location
peripheral.setBlock(int x, int y, int z, int id, [int metadata]) --Sets the block at the specified x,y,z location to the given id and (optionally) metadata
peripheral.findPeripheral() --Returns the x,y,z position of the peripheral block
peripheral.findComputer() --Returns the x,y,z position of the computer attached to the peripheral
peripheral.playerCoords(str username) -- Returns the x,y,z position of the specified player
peripheral.playerHealth(str username) --Returns the current amount of health the player has
peripheral.attackPlayer(str username, int damageValue) -- Damages the player by the specified amount
peripheral.setPlayerPos(str username, int x, int y, int z) --Sets the player's x,y,z position the given coordinates
peripheral.givePlayer(str username, int itemID, int amount) --Gives the player the specified amount of the itemID
peripheral.getPlayers(integer) --Returns a player from a table. Inputting peripheral.getPlayers(1) will get you the first connected player.
peripheral.say(str text) --Adds the given text value in the chat
peripheral.createFireball(int startX, int startY, int startZ, double velocityX, double velocityY, double velocityZ) --Adds a fireball to the world with the given values
peripheral.playerLooking(str username) --Returns the specified vecX, vecY, and vecZ as doubles
peripheral.createExplosion(int x,int y, int z, int damagevalue) --Creates explosion of specified magnitude at given coordinates
peripheral.getDirection() --Returns the direction the attached computer (or turtle) is facing
Crafting
DDD
DSD
DDD
Where D is a diamond block and S is smooth stone.
Screenshots
Here are some screenshots of the peripheral in action. Hopefully I will be able to record a video sometime in the near future.
http://www.4shared.c...ral_Images.html
Sample Programs
Spoiler
--Give the player specified items
local args = {...}
if args[2] == nil then
print("Requires 2 arguments")
else
local p = peripheral.wrap('left')
local username = p.getPlayers(1)
p.givePlayer(username, tonumber(args[1]), tonumber(args[2]))
end
--Move the player to the specified coordinates
local args = {...}
if args[3] == nil then
print('Requires 3 args.')
else
local p = peripheral.wrap('left')
local username = p.getPlayers(1)
local cX,cY,cZ = p.playerCoords(username)
cX = math.floor(cX)
cY = math.floor(cY)
cZ = math.floor(cZ)
local x = tonumber(args[1])
local y = tonumber(args[2])
local z = tonumber(args[3])
local nX = cX + x
local nY = cY + y
local nZ = cZ + z
print("Current player position: "..cX..", "..cY..", "..cZ)
print("New player position: "..nX..", "..nY..", "..nZ)
p.setPlayerPos(username, nX,nY,nZ)
end
--Print same basic info about the player
local p = peripheral.wrap('left')
local username = p.getPlayers(1)
pX, pY, pZ = p.playerCoords(username)
print("Player X: "..pX)
print("Player Y: "..pY)
print("Player Z: "..pZ)
print("Player health: "..p.playerHealth())
print("------------------------------------")
print("Getting the id of the block underneath the player")
pX = math.floor(pX)
pY = math.floor(pY)
pZ = math.floor(pZ)
print("ID is: "..p.getBlock(pX,pY-1,pZ))
--Set the block at the given coords relative to the Computer to the specified ID
local args = {...}
if args[4] == nil then
print("Requires 4 args")
else
local p = peripheral.wrap('left')
local cX, cY, cZ = p.findComputer()
p.setBlock(cX + tonumber(args[1]),cY + tonumber(args[2]),cZ + tonumber(args[3]),tonumber(args[4]))
end
Install
Just drop the zip file into your mods folder. No extra steps are necessary!
Notes
- I give anybody and everybody full rights to this peripheral, up to and including making small modifications to the code and releasing it as your own.
- This peripheral is still in development, meaning that it may still have bugs or could use improvements in some areas.
Download
Version 1.5 (Current - CC 1.47 MC 1.45)
Client
Source
Old versions
Spoiler
V1.4 (Outdated - CC 1.47 MC 1.45)Client
Source
V1.2 (Outdated - CC 1.47 MC 1.45)
Client: http://www.4shared.c...ipheralv12.html
Source: http://www.4shared.c...eralv12SRC.html
V1.1 (Outdated - CC 1.47 MC 1.45)
Client: http://www.4shared.c...pheral_v11.html
Source: http://www.4shared.c...al_v11_src.html
V1.0 (Outdated - CC 1.47 MC 1.45)
Client with diamond recipe: http://www.4shared.c...ralDRecipe.html
Client with cobble recipe http://www.4shared.c...peripheral.html
Source http://www.4shared.c...5oPrl/Code.html