Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
naturefreshmilk committed Jun 3, 2019
0 parents commit adcb18f
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 0 deletions.
38 changes: 38 additions & 0 deletions commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

local c_lavastone = minetest.get_content_id("lavastone:lavastone")
local c_air = minetest.get_content_id("air")

local range = {x=32,y=32,z=32}

minetest.register_chatcommand("lavastone_remove", {
description = "removes lavastone in the current area",
privs = { lavastone_remove = true },
func = function(name, param)
local player = minetest.get_player_by_name(name)
local pos = player:get_pos()

local pos1 = vector.subtract(pos, range)
local pos2 = vector.add(pos, range)

local manip = minetest.get_voxel_manip()
local e1, e2 = manip:read_from_map(pos1, pos2)
local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
local data = manip:get_data()

for z=pos1.z, pos2.z do
for y=pos1.y, pos2.y do
for x=pos1.x, pos2.x do

local index = area:index(x, y, z)
if data[index] == c_lavastone then
data[index] = c_air
end

end
end
end

manip:set_data(data)
manip:write_to_map()
end
})
11 changes: 11 additions & 0 deletions cooling.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

-- taken from https://github.com/minetest/minetest_game/blob/master/mods/default/functions.lua
default.cool_lava = function(pos, node)
if node.name == "default:lava_source" then
minetest.set_node(pos, {name = "default:obsidian"})
else -- Lava flowing
minetest.set_node(pos, {name = "lavastone:lavastone"})
end
minetest.sound_play("default_cool_lava",
{pos = pos, max_hear_distance = 16, gain = 0.25})
end
1 change: 1 addition & 0 deletions depends.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default
6 changes: 6 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
local MP = minetest.get_modpath("lavastone")

dofile(MP.."/lavastone.lua")
dofile(MP.."/cooling.lua")
dofile(MP.."/commands.lua")
dofile(MP.."/privs.lua")
10 changes: 10 additions & 0 deletions lavastone.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

-- taken from https://github.com/minetest/minetest_game/blob/master/mods/default/nodes.lua#L232

minetest.register_node("lavastone:lavastone", {
description = "Stone (Cooled lava)",
tiles = {"default_stone.png"},
groups = {cracky = 3, stone = 1},
drop = 'default:cobble',
sounds = default.node_sound_stone_defaults(),
})
4 changes: 4 additions & 0 deletions privs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

minetest.register_privilege("lavastone_remove", {
description = "Can remove lavastone in an area"
})
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Overrides the lava cooling with a generated lavastone that can be removed with /remove_lavastone

# License

Media: CC BY-SA 3.0
Code: GPL

0 comments on commit adcb18f

Please sign in to comment.