Fixed inconsistent max values for Video and Control channels

Code cleanup
This commit is contained in:
LemADEC 2017-05-10 04:04:03 +02:00
parent 26e7f57b8d
commit 3d4bea2f29
4 changed files with 12 additions and 10 deletions
src/main
java/cr0s/warpdrive/api
resources/assets/warpdrive/lua.ComputerCraft/warpdriveRadar

View file

@ -2,7 +2,7 @@ package cr0s.warpdrive.api;
public interface IControlChannel {
int CONTROL_CHANNEL_MIN = 0;
int CONTROL_CHANNEL_MAX = 999999999;
int CONTROL_CHANNEL_MAX = 0xFFFFFFF; // 268435455
String CONTROL_CHANNEL_TAG = "controlChannel";
// get control channel, return -1 if invalid

View file

@ -2,7 +2,7 @@ package cr0s.warpdrive.api;
public interface IVideoChannel {
int VIDEO_CHANNEL_MIN = 0;
int VIDEO_CHANNEL_MAX = 999999999;
int VIDEO_CHANNEL_MAX = 0xFFFFFFF; // 268435455
String VIDEO_CHANNEL_TAG = "videoChannel";
// get video channel, return -1 if invalid

View file

@ -12,6 +12,7 @@ function error(message)
print()
end
local radar
sides = peripheral.getNames()
for key,side in pairs(sides) do
if peripheral.getType(side) == "warpdriveRadar" then
@ -52,7 +53,7 @@ print("Scanning... (" .. scanDuration .. " s)")
os.sleep(scanDuration)
local delay = 0
local count = nil
local count
repeat
count = radar.getResultsCount()
sleep(0.1)
@ -62,11 +63,11 @@ until (count ~= nil and count ~= -1) or delay > 10
if count ~= nil and count > 0 then
for i=0, count-1 do
success, type, name, x, y, z = radar.getResult(i)
if success then
print(type .. " " .. name .. " @ (" .. x .. " " .. y .. " " .. z .. ")")
else
print("Error " .. type)
end
if success then
print(type .. " " .. name .. " @ (" .. x .. " " .. y .. " " .. z .. ")")
else
print("Error " .. type)
end
end
else
print("Nothing was found =(")

View file

@ -6,6 +6,7 @@ if not term.isColor() then
exit()
end
local radar
sides = peripheral.getNames()
for key,side in pairs(sides) do
if peripheral.getType(side) == "warpdriveRadar" then
@ -68,8 +69,8 @@ function scanAndDraw()
local energy, energyMax = radar.energy()
local energyRequired = radar.getEnergyRequired(radius)
if (energy < energyRequired) then
hh = math.floor(h / 2)
hw = math.floor(w / 2)
local hh = math.floor(h / 2)
local hw = math.floor(w / 2)
paintutils.drawLine(hw - 5, hh - 1, hw + 5, hh - 1, colors.red)
paintutils.drawLine(hw - 5, hh, hw + 5, hh, colors.red)