Fix spike error.

This commit is contained in:
Duane Robertson 2016-05-29 06:20:20 -05:00
parent 558e778861
commit 16983356c8
3 changed files with 27 additions and 38 deletions

View file

@ -208,20 +208,15 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = fun_caves.hot_spikes, nodenames = fun_caves.hot_spikes,
interval = 30 * fun_caves.time_factor, interval = 30 * fun_caves.time_factor,
chance = 10, chance = 30,
action = function(pos, node) action = function(pos, node)
local spike_num local spike_num = fun_caves.hot_spike[node.name]
for i = 1, #hot_spikes do
if hot_spikes[i] == node.name then
spike_num = i
end
end
if not spike_num then if not spike_num then
return return
end end
if spike_num < #hot_spikes then if spike_num < #fun_caves.hot_spikes then
set_node(pos, {name=hot_spikes[spike_num+1]}) set_node(pos, {name=fun_caves.hot_spikes[spike_num+1]})
return return
end end

View file

@ -283,6 +283,11 @@ for i in ipairs(spike_size) do
}) })
end end
fun_caves.hot_spike = {}
for i = 1, #fun_caves.hot_spikes do
fun_caves.hot_spike[fun_caves.hot_spikes[i]] = i
end
-- stone with algae -- stone with algae
newnode = fun_caves.clone_node("default:stone") newnode = fun_caves.clone_node("default:stone")
newnode.description = "Cave Stone With Algae" newnode.description = "Cave Stone With Algae"

View file

@ -465,10 +465,8 @@ local function generate(p_minp, p_maxp, seed)
end end
if data[ivm] == node["air"] then if data[ivm] == node["air"] then
local sr = rand(1000)
-- hanging down -- hanging down
if node_above == node["default:stone"] and sr < 80 then if node_above == node["default:stone"] and rand(12) == 1 then
if stone_type == node["default:ice"] then if stone_type == node["default:ice"] then
data[ivm] = node["fun_caves:icicle_down"] data[ivm] = node["fun_caves:icicle_down"]
write = true write = true
@ -493,66 +491,58 @@ local function generate(p_minp, p_maxp, seed)
end end
-- fluids -- fluids
if y > minp.y and (node_below == node["default:stone"] or node_below == node["fun_caves:hot_cobble"]) and sr < 3 then if y > minp.y and (node_below == node["default:stone"] or node_below == node["fun_caves:hot_cobble"]) and rand(300) == 1 then
data[ivm] = node["default:lava_source"] data[ivm] = node["default:lava_source"]
write = true write = true
break break
elseif node_below == node["fun_caves:stone_with_moss"] and sr < 3 then elseif node_below == node["fun_caves:stone_with_moss"] and rand(300) == 1 then
data[ivm] = node["default:water_source"] data[ivm] = node["default:water_source"]
write = true write = true
break break
-- standing up -- standing up
elseif node_below == node["default:ice"] and sr < 80 then elseif node_below == node["default:ice"] and rand(12) == 1 then
data[ivm] = node["fun_caves:icicle_up"] data[ivm] = node["fun_caves:icicle_up"]
write = true write = true
break break
elseif node_below == node["fun_caves:stone_with_algae"] and sr < 80 then elseif node_below == node["fun_caves:stone_with_algae"] and rand(12) == 1 then
data[ivm] = node["fun_caves:stalagmite_slimy"] data[ivm] = node["fun_caves:stalagmite_slimy"]
write = true write = true
break break
elseif node_below == node["fun_caves:stone_with_moss"] and sr < 80 then elseif node_below == node["fun_caves:stone_with_moss"] and rand(12) == 1 then
data[ivm] = node["fun_caves:stalagmite_mossy"] data[ivm] = node["fun_caves:stalagmite_mossy"]
write = true write = true
break break
elseif node_below == node["fun_caves:stone_with_lichen"] and sr < 80 then elseif node_below == node["fun_caves:stone_with_lichen"] and rand(12) == 1 then
data[ivm] = node["fun_caves:stalagmite"] data[ivm] = node["fun_caves:stalagmite"]
write = true write = true
break break
elseif node_below == node["default:stone"] and sr < 80 then elseif node_below == node["default:stone"] and rand(12) == 1 then
data[ivm] = node["fun_caves:stalagmite"] data[ivm] = node["fun_caves:stalagmite"]
write = true write = true
break break
elseif node_below == node["fun_caves:hot_cobble"] and sr < 80 then elseif node_below == node["fun_caves:hot_cobble"] and rand(50) == 1 then
if sr <= 20 then data[ivm] = node[fun_caves.hot_spikes[rand(#fun_caves.hot_spikes)]]
data[ivm] = node["fun_caves:hot_spike"] elseif node_below == node["fun_caves:black_sand"] and rand(50) == 1 then
write = true
break
else
data[ivm] = node["fun_caves:hot_spike_"..ceil(sr / 20)]
write = true
break
end
elseif node_below == node["fun_caves:black_sand"] and sr < 20 then
data[ivm] = node["fun_caves:constant_flame"] data[ivm] = node["fun_caves:constant_flame"]
write = true write = true
break break
-- vegetation -- vegetation
elseif node_below == node["default:dirt"] and (stone_type == node["fun_caves:stone_with_lichen"] or stone_type == node["fun_caves:stone_with_algae"]) and biome_val >= -0.5 then elseif node_below == node["default:dirt"] and (stone_type == node["fun_caves:stone_with_lichen"] or stone_type == node["fun_caves:stone_with_algae"]) and biome_val >= -0.5 then
if sr < 110 then if rand(10) == 1 then
data[ivm] = node["flowers:mushroom_red"] data[ivm] = node["flowers:mushroom_red"]
write = true write = true
break break
elseif sr < 220 then elseif rand(10) == 1 then
data[ivm] = node["flowers:mushroom_brown"] data[ivm] = node["flowers:mushroom_brown"]
write = true write = true
break break
elseif node_above == node["air"] and sr < 330 then elseif node_above == node["air"] and rand(10) == 1 then
data[ivm] = node["fun_caves:giant_mushroom_stem"] data[ivm] = node["fun_caves:giant_mushroom_stem"]
write = true write = true
break break
elseif sr < 360 then elseif rand(30) == 1 then
local air_count = 0 local air_count = 0
local j local j
for i = 1, 12 do for i = 1, 12 do
@ -612,16 +602,15 @@ local function generate(p_minp, p_maxp, seed)
write = true write = true
break break
elseif y < water_level and node_below == node["default:sand"] and node_above == node["default:water_source"] and data[ivm] == node["default:water_source"] and coral_biomes[biome] and pn < -0.1 and rand(5) < 3 then elseif y < water_level and node_below == node["default:sand"] and node_above == node["default:water_source"] and data[ivm] == node["default:water_source"] and coral_biomes[biome] and pn < -0.1 and rand(5) < 3 then
local sr = rand(65) if rand(15) == 1 then
if sr < 4 then
data[ivm] = node["fun_caves:brain_coral"] data[ivm] = node["fun_caves:brain_coral"]
write = true write = true
break break
elseif sr < 6 then elseif rand(15) == 1 then
data[ivm] = node["fun_caves:dragon_eye"] data[ivm] = node["fun_caves:dragon_eye"]
write = true write = true
break break
elseif sr < 65 then else
data[ivm] = node["fun_caves:pillar_coral"] data[ivm] = node["fun_caves:pillar_coral"]
write = true write = true
break break