Skip to content

Commit b65f0cc

Browse files
Allow jumping to unexplored areas (#115)
* descriptive errors * combine failure messages + emerge undefined areas * prepare to shorten obstruction message in the right branch * partially shut luackeck up * Create settingtypes.txt * Update jump.lua * whoops * move settings * cache config * Update init.lua Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> * Update settingtypes.txt * shut luacheck up Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com> --------- Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com>
1 parent bb66479 commit b65f0cc

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jumpdrive = {
1313

1414
-- base technic power requirement
1515
powerrequirement = tonumber(minetest.settings:get("jumpdrive.power_requirement")) or 2500,
16+
17+
-- allow emerging area on "uncharted" error
18+
emerge_uncharted = core.settings:get_bool("jumpdrive.allow_emerge", false),
1619
},
1720

1821
-- blacklisted nodes

is_area_empty.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jumpdrive.is_area_empty = function(pos1, pos2)
3030
local id = data[index]
3131

3232
if id == c_ignore then
33-
return false, "Uncharted"
33+
return false, "uncharted"
3434
end
3535

3636
if not buildable_to_nodes[id] then
3737
-- not buildable_to
38-
return false, "Occupied"
38+
return false, "occupied"
3939
end
4040
end
4141
end

jump.lua

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
44

55
local targetPos = jumpdrive.get_meta_pos(pos)
66

7-
if jumpdrive.check_mapgen(pos) then
8-
return false, "Error: mapgen was active in this area, please try again later for your own safety!"
7+
local mapgen_distance = jumpdrive.check_mapgen(pos)
8+
if mapgen_distance then
9+
return false, "Error: mapgen was active "..math.floor(mapgen_distance)
10+
.. " / 200 nodes away, please try again later for your own safety!"
911
end
1012

1113
local meta = minetest.get_meta(pos)
@@ -50,7 +52,7 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
5052
meta:set_int("simulation_expiry", shape.expiry)
5153
end
5254

53-
local msg = nil
55+
local msg = ""
5456
local success = true
5557

5658
local blacklisted_pos_list = minetest.find_nodes_in_area(source_pos1, source_pos2, jumpdrive.blacklist)
@@ -60,12 +62,13 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
6062
end
6163

6264
if minetest.find_node_near(targetPos, radius, "vacuum:vacuum", true) then
63-
msg = "Warning: Jump-target is in vacuum!"
65+
msg = msg .. "\nWarning: Jump-target is in vacuum!"
6466
end
6567

66-
if minetest.find_node_near(targetPos, radius, "ignore", true) then
67-
return false, "Warning: Jump-target is in uncharted area"
68-
end
68+
-- -- found to be useless/indescriptive and is superseded by "Jump-target is uncharted"
69+
-- if minetest.find_node_near(targetPos, radius, "ignore", true) then
70+
-- return false, "Warning: Jump-target is in uncharted area"
71+
-- end
6972

7073
if jumpdrive.is_area_protected(source_pos1, source_pos2, playername) then
7174
return false, "Jump-source is protected!"
@@ -78,7 +81,15 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
7881
local is_empty, empty_msg = jumpdrive.is_area_empty(target_pos1, target_pos2)
7982

8083
if not is_empty then
81-
msg = "Jump-target is obstructed (" .. empty_msg .. ")"
84+
if jumpdrive.config.emerge_uncharted and empty_msg == "uncharted" then
85+
local callback = function(_, _, calls_remaining, _)
86+
if calls_remaining == 0 then
87+
core.chat_send_player(playername, "Charting complete!")
88+
end
89+
end
90+
core.emerge_area(target_pos1, target_pos2, callback)
91+
end
92+
msg = msg .. "\nJump-target is " .. empty_msg
8293
success = false
8394
end
8495

@@ -87,7 +98,7 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
8798

8899
if not preflight_result.success then
89100
-- check failed in customization
90-
msg = "Preflight check failed!"
101+
msg = msg .. "\nPreflight check failed!"
91102
if preflight_result.message then
92103
msg = preflight_result.message
93104
end
@@ -99,7 +110,7 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
99110

100111
if powerstorage < power_req then
101112
-- not enough power
102-
msg = "Not enough power: required=" .. math.floor(power_req) .. ", actual: " .. powerstorage .. " EU"
113+
msg = msg .. "\nNot enough power: required=" .. math.floor(power_req) .. ", actual: " .. powerstorage .. " EU"
103114
success = false
104115
end
105116

mapgen.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ minetest.register_globalstep(function(dtime)
5454
end)
5555

5656

57-
-- true = mapgen recently active in that area
57+
-- any number = mapgen recently active in that area
5858
jumpdrive.check_mapgen = function(pos)
5959
for _, event in ipairs(events) do
60-
if vector.distance(pos, event.minp) < 200 then
61-
return true
60+
local mapgen_distance = vector.distance(pos, event.minp)
61+
if mapgen_distance < 200 then
62+
return mapgen_distance
6263
end
6364
end
6465

settingtypes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Allow jumpdrives to generate ungenerated areas
2+
jumpdrive.allow_emerge (Chart uncharted jump targets) bool false

0 commit comments

Comments
 (0)