vany / gh4lua Goto Github PK
View Code? Open in Web Editor NEWgithub client for minecraft lua
License: Apache License 2.0
github client for minecraft lua
License: Apache License 2.0
Хватит ломать черепах, они не в чем не виноваты! Прерывание программы происходит при зажатии Ctrl + T
turtle.inspect()
В своих программах ты часто сравниваешь блоки перед черепахой с предметом в слоте, или ищешь сундук при помощь perephiral. При этом есть классный метод у черепахи turtle.inspect(), turtle.inspectUp(), turtle.inspectDown(). В первую очередь, он позволяет узнать ид блока, но некоторые блоки поддерживают состояния (data.state) и тэги (data.tags), всё зависит от мода.
-- DOCS
-- Returns the ID string and metadata of the block in front of the Turtle
-- result values:
-- boolean success
-- table data / string errorMessage
turtle.inspect()
-- Returns the ID string and metadata of the block above the Turtle
-- result values:
-- boolean success
-- table data / string errorMessage
turtle.inspectUp()
-- Returns the ID string and metadata of the block below the Turtle
-- result values:
-- boolean success
-- table data / string errorMessage
turtle.inspectDown()
-- USAGE EXAMPLE
function block_has_id(id)
local success, data = turtle.inspect()
return success and data.name == id
end
-- true when the block in front is starmetal ore
function block_is_starmetal_ore()
return block_has_id("astralsorcery:starmetal_ore")
end
-- find for a chest around the turtle
function find_chest()
local success, data
for i = 1, 4 do
success, data = turtle.inspect()
if success and ends_with("chest") then return true end
end
error("chest not found")
end
-- check if string ends with ending
function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
-- DOCS
-- Returns the ID string, count and damage values of currently selected slot or, if specified, slotNum slot
-- result values:
-- table data
turtle.getItemDetail([number slotNum])
-- USAGE EXAMPLE
function item_has_id(slot, id)
local item = turtle.getItemDetail(slot)
-- item is nil when slot is empty
return item and item.name == id
end
-- true when an item is found in inventory
function select_slot_with_item(id)
for slot = 1, 16 do
if item_has_id(slot, id) then
turtle.select(slot)
return true
end
end
return false
end
-- starmetal loop
function starmetal()
local success, data
while true do
success, data = turtle.inspect()
if success then
if data.name == "astralsorcery:starmetal_ore" then
turtle.select(1)
turtle.dig()
else
-- waiting for starmetal
sleep(1)
end
else
if select_slot_with_item("minecraft:iron_ore") then
turtle.place()
else
print("no iron ore found in inventory")
sleep(5)
end
end
end
end
-- DOCS
-- Returns the ID string, count and damage values of currently selected slot or, if specified, slotNum slot
-- result values:
-- string serializedData
textutils.serialize(any data)
-- Returns the data reassembled from string serializedData. Used mainly together with textutils.serialize()
-- result values:
-- any unserializedData
textutils.unserialize(string serializedData)
-- USAGE EXAMPLE
--[[
-- example
local v = ...
v:SendStat({
name = os.getComputerLabel() or tostring(os.getComputerID()),
value = "working",
color = colors.green
})
]]
function v:SendStat(data)
data.color = data.color or colors.white
self.modem.transmit(self.channel, self.channel, textutils.serialize(data))
end
-- server example
function listen()
while true do
local _, _, channel, _, msg, _ = os.pullEvent("modem_message")
if msg then
local data = textutils.unserialize(msg)
print(data.name)
print(data.value)
print(data.color)
end
end
end
зы. Надеюсь эта информация была написана не зря и она поможет тебе в разработке :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.