diff --git a/init.lua b/init.lua index 9b42c2b..be5542a 100644 --- a/init.lua +++ b/init.lua @@ -22,10 +22,10 @@ -- Parameters +local DEBUG = false local NETHER_DEPTH = -5000 local TCAVE = 0.6 local BLEND = 128 -local DEBUG = false -- 3D noise @@ -284,11 +284,25 @@ local function get_timerPos_from_p1_and_p2(p1, p2) end -- orientation is the rotation degrees passed to place_schematic: 0, 90, 180, or 270 -local function get_param2_from_orientation(param2, orientation) - return orientation / 90 +-- color is a value from 0 to 7 corresponding to the pixels in portal_palette.png +local function get_param2_from_color_and_orientation(color, orientation) + assert(orientation, "no orientation passed") + + -- wormhole nodes have a paramtype2 of colorfacedir, which means the + -- high 3 bits are palette, followed by 3 direction bits and 2 rotation bits. + -- We set the palette bits and rotation + return (orientation / 90) + color * 32 end local function get_orientation_from_param2(param2) + -- Strip off the top 6 bits, unfortunately MT lua has no bitwise '&' + -- (high 3 bits are palette, followed by 3 direction bits then 2 rotation bits) + if param2 >= 128 then param2 = param2 - 128 end + if param2 >= 64 then param2 = param2 - 64 end + if param2 >= 32 then param2 = param2 - 32 end + if param2 >= 16 then param2 = param2 - 16 end + if param2 >= 8 then param2 = param2 - 8 end + return param2 * 90 end @@ -336,7 +350,7 @@ local function set_portal_metadata(portal_definition, anchorPos, orientation, de -- they define the bounding volume for the portal. local p1, p2 = portal_definition.shape:get_p1_and_p2_from_anchorPos(anchorPos, orientation) local p1_string, p2_string = minetest.pos_to_string(p1), minetest.pos_to_string(p2) - local param2 = get_param2_from_orientation(0, orientation) + local param2 = get_param2_from_color_and_orientation(portal_definition.wormhole_node_color, orientation) local update_aborted-- using closures to allow the updateFunc to return extra information - by setting this variable @@ -863,7 +877,7 @@ function run_wormhole(pos, time_elapsed) minsize = 0.5, maxsize = 1.5, collisiondetection = false, - texture = "nether_particle.png", + texture = "nether_particle.png^[colorize:#808:alpha", glow = 5 }) end @@ -975,7 +989,9 @@ minetest.register_node("nether:portal", { }, drawtype = "nodebox", paramtype = "light", - paramtype2 = "facedir", + paramtype2 = "colorfacedir", + palette = "portal_palette.png", + post_effect_color = {a = 180, r = 128, g = 0, b = 128}, sunlight_propagates = true, use_texture_alpha = true, walkable = false, @@ -985,7 +1001,6 @@ minetest.register_node("nether:portal", { is_ground_content = false, drop = "", light_source = 5, - post_effect_color = {a = 180, r = 128, g = 0, b = 128}, alpha = 192, node_box = { type = "fixed", diff --git a/textures/nether_particle.png b/textures/nether_particle.png index 56a5b78..6171305 100644 Binary files a/textures/nether_particle.png and b/textures/nether_particle.png differ diff --git a/textures/nether_portal.png b/textures/nether_portal.png index 824d652..583a099 100644 Binary files a/textures/nether_portal.png and b/textures/nether_portal.png differ diff --git a/textures/portal_palette.png b/textures/portal_palette.png new file mode 100644 index 0000000..8cc6f30 Binary files /dev/null and b/textures/portal_palette.png differ