我的世界電腦mod教程gps的簡單使用與代碼操作
小編為大家?guī)砹恕段业氖澜纭冯娔Xmod教程gps的簡單使用與代碼操作,這個(gè)就是傳說中的那個(gè)只要會編程就可以幫你完成很多任務(wù)的mod,只要玩家能做到的事情,電腦mod它很多都能做到,這里小編就教大家如何編寫與使用GPS功能,有興趣的玩家都來看看吧。
電腦mod中的gps系統(tǒng)由服務(wù)器和用戶組成。
我們知道現(xiàn)實(shí)中g(shù)ps由衛(wèi)星來定位,一顆衛(wèi)星是定位不了的,至少要3顆衛(wèi)星才能定位。
同樣的,cc中需要4臺電腦作為定位服務(wù)器(o,x,y,z)才能定位。這4臺電腦必須裝上無線modern。
然后給上圖中指著的電腦輸入 gps host 0 0 0
然后分別給另外3個(gè)電腦輸入相應(yīng)的坐標(biāo)
如我輸入的是
gps host 3 0 0
gps host 0 3 0
gps host 0 0 3
然后給一臺帶無線的turtle寫下面的程序:
--程序名:gps
rednet.open("right")
print("rednet open")
print("Man I am so lost right now!")
local x, y, z = gps.locate(5)
if not x then --if gps.locate didn't work, it won't return anything. So check to see if it did.
print("Failed to get my location!")
else
print("I am at (" .. x .. ", " .. y .. ", " .. z .. ")") --This prints 'I am at (1, 2, 3)' or whatever your coordinates are
end
運(yùn)行程序gps
定位成功了,坐標(biāo)是(4,5,0)
如果你放了第5臺服務(wù)器,可以直接使用gps host命令,會自動從另外4臺服務(wù)器獲得坐標(biāo)。
查看所有0條評論>>