Compare commits

..

2 Commits

Author SHA1 Message Date
loosewheel
6f8a194042 Add files via upload 2022-02-16 01:49:12 +10:00
loosewheel
84ddc82c95 Add files via upload 2022-02-16 01:46:56 +10:00
5 changed files with 29 additions and 23 deletions

View File

@@ -140,9 +140,10 @@ local function camera_scan (pos, resolution, distance)
tpos = vector.round ({ x = horz + pos.x, y = pos.y - vert, z = (dist * dir.z) + pos.z }) tpos = vector.round ({ x = horz + pos.x, y = pos.y - vert, z = (dist * dir.z) + pos.z })
end end
if last_pos and vector.equals (last_pos, tpos) then if last_pos and vector.equals (last_pos, tpos) then
image[y][x] = last_color if last_color then
image[y][x] = last_color
end
else else
local entity = get_entity (tpos) local entity = get_entity (tpos)
@@ -151,13 +152,11 @@ local function camera_scan (pos, resolution, distance)
last_color = string.format ("00%02X00", color) last_color = string.format ("00%02X00", color)
image[y][x] = last_color image[y][x] = last_color
last_pos = tpos
elseif entity == 2 then elseif entity == 2 then
local color = (((distance - dist) / distance) * 98) + 30 local color = (((distance - dist) / distance) * 98) + 30
last_color = string.format ("0000%02X", color) last_color = string.format ("0000%02X", color)
image[y][x] = last_color image[y][x] = last_color
last_pos = tpos
else else
local node = utils.get_far_node (tpos) local node = utils.get_far_node (tpos)
@@ -166,12 +165,13 @@ local function camera_scan (pos, resolution, distance)
last_color = string.format ("%02X%02X%02X", color, color, color) last_color = string.format ("%02X%02X%02X", color, color, color)
image[y][x] = last_color image[y][x] = last_color
last_pos = tpos
else else
last_pos = nil last_color = nil
end end
end end
end end
last_pos = tpos
end end
end end
end end
@@ -198,8 +198,6 @@ local function send_scan (pos)
channel, channel,
image) image)
end end
end end
end end
@@ -208,14 +206,14 @@ end
local function after_place_node (pos, placer, itemstack, pointed_thing) local function after_place_node (pos, placer, itemstack, pointed_thing)
local meta = minetest.get_meta (pos) local meta = minetest.get_meta (pos)
local spec = local spec =
"formspec_version[3]\n".. "formspec_version[3]"..
"size[8.5,5.5;true]\n".. "size[8.5,5.5;true]"..
"field[1.0,1.0;4.0,0.8;channel;Channel;${channel}]\n".. "field[1.0,1.0;4.0,0.8;channel;Channel;${channel}]"..
"button[5.5,1.0;2.0,0.8;setchannel;Set]\n".. "button[5.5,1.0;2.0,0.8;setchannel;Set]"..
"field[1.0,2.5;4.0,0.8;distance;Distance;${distance}]\n".. "field[1.0,2.5;4.0,0.8;distance;Distance;${distance}]"..
"button[5.5,2.5;2.0,0.8;setdistance;Set]\n".. "button[5.5,2.5;2.0,0.8;setdistance;Set]"..
"field[1.0,4.0;4.0,0.8;resolution;Resolution;${resolution}]\n".. "field[1.0,4.0;4.0,0.8;resolution;Resolution;${resolution}]"..
"button[5.5,4.0;2.0,0.8;setresolution;Set]\n" "button[5.5,4.0;2.0,0.8;setresolution;Set]"
meta:set_string ("formspec", spec) meta:set_string ("formspec", spec)
meta:set_string ("distance", "5") meta:set_string ("distance", "5")
@@ -271,7 +269,7 @@ local function on_receive_fields (pos, formname, fields, sender)
local meta = minetest.get_meta (pos) local meta = minetest.get_meta (pos)
if meta then if meta then
local resolution = math.max (tonumber (fields.resolution) or 1, 1) local resolution = math.min (math.max (tonumber (fields.resolution) or 1, 1), 128)
fields.resolution = tostring (resolution) fields.resolution = tostring (resolution)
meta:set_string ("resolution", tostring (resolution)) meta:set_string ("resolution", tostring (resolution))
@@ -375,10 +373,12 @@ local function digilines_support ()
send_scan (pos) send_scan (pos)
elseif m[1] == "distance" then elseif m[1] == "distance" then
meta:set_string ("distance", tostring (tonumber (m[2] or 5) or 5)) local distance = math.min (math.max (tonumber (m[2] or 5) or 5, 1), 16)
meta:set_string ("distance", tostring (distance))
elseif m[1] == "resolution" then elseif m[1] == "resolution" then
meta:set_string ("resolution", tostring (tonumber (m[2] or 16) or 16)) local resolution = math.min (math.max (tonumber (m[2] or 16) or 16, 1), 128)
meta:set_string ("resolution", tostring (resolution))
end end
end end

View File

@@ -96,9 +96,15 @@ v0.1.16
v0.1.17 v0.1.17
* Fixed unintended global variable in pistons.lua. * Fixed unintended global variable in pistons.lua.
v0.1.18 v0.1.18
* Added mesecons through wire. * Added mesecons through wire.
v0.1.19 v0.1.19
* Added camera. * Added camera.
v0.1.20
* Valid distance and resolution for camera set by digilines message.
* Imposed maximum resolution of 128 for cameras.

View File

@@ -13,8 +13,8 @@ Only the owner can dig or access the form of the locked version.
UI UI
Channel - digilines channel of camera. Channel - digilines channel of camera.
Distance - the viewing distance forward from the camera (1 t0 16). Distance - the viewing distance forward from the camera (1 to 16).
Resolution - the image resolution (for both width and height). Resolution - the image resolution (for both width and height, 1 to 128).
Digilines messages Digilines messages

View File

@@ -1,4 +1,4 @@
local version = "0.1.19" local version = "0.1.20"
local mod_storage = minetest.get_mod_storage () local mod_storage = minetest.get_mod_storage ()

View File

@@ -13,7 +13,7 @@ CC BY-SA 3.0
Version Version
======= =======
0.1.19 0.1.20
Minetest Version Minetest Version