Initial commit

master
Extex101 2019-08-07 20:00:43 -07:00 committed by GitHub
commit 1eabf5d916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 179 additions and 0 deletions

59
LICENSE.TXT Normal file
View File

@ -0,0 +1,59 @@
License of source code
----------------------
The MIT License (MIT)
Copyright (C) 2019 Extex
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
For more details:
https://opensource.org/licenses/MIT
Licenses of media (texture)
--------------------------------------
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Copyright (C) 2019 Extex
You are free to:
Share — copy and redistribute the material in any medium or format.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and
indicate if changes were made. You may do so in any reasonable manner, but not in any way
that suggests the licensor endorses you or your use.
ShareAlike — If you remix, transform, or build upon the material, you must distribute
your contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public
domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary
for your intended use. For example, other rights such as publicity, privacy, or moral
rights may limit how you use the material.
For more details:
http://creativecommons.org/licenses/by-sa/3.0/

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# Light Tool
This is a mod that adds a Torch/Flashlight to ![Minetest](https://www.minetest.net/) (![Github Repo](https://github.com/Minetest/minetest))
# Animated gif
Here's how it works
![GIF](https://github.com/Extex101/light_tool/blob/master/in%20use%20(animated).gif)
The beam is obstructed by blocks and go through glass and other nodes (with sunlight_propagates = true)
Minetest forumn topic ![here]()

41
api.lua Normal file
View File

@ -0,0 +1,41 @@
-- You can use light_tool.add_tool(<ItemStack>, range) to define your own torches
-- and you can use light_tool.light_beam(pos, dir, range) to define your own light beam
light_tool = {}
light_tool.tools = {}
light_tool.range = {}
light_tool.light_beam = function(pos, dir, range)
for i = 0, range do
local new_pos = {
x = pos.x + (dir.x * i),
y = pos.y + (dir.y * i),
z = pos.z + (dir.z * i),
}
local node = minetest.get_node(new_pos)
if minetest.get_node(new_pos).name == "air" or minetest.get_node(new_pos).name == "light_tool:light" then
minetest.set_node(new_pos, {name = "light_tool:light"})
elseif minetest.registered_nodes[node.name].sunlight_propagates == false then
break
end
end
end
light_tool.add_tool = function(toolname, range)
table.insert(light_tool.tools, toolname)
table.insert(light_tool.range, range)
end
light_tool.check = function(table, value)
for i,v in ipairs(table) do
if v == value then
return true
end
end
end
light_tool.check_index = function(table, value)
for i,v in ipairs(table) do
if v == value then
return i
end
end
end

1
author.txt Normal file
View File

@ -0,0 +1 @@
Extex

1
depends.txt Normal file
View File

@ -0,0 +1 @@
default?

3
description.txt Normal file
View File

@ -0,0 +1,3 @@
When holding a Light Tool it adds an aimed beam of light that is obstructed by blocks and shine through glass
Great for night travel and mining situations
Light Tool also adds an api to make your own light tools and create beams of light for own mods

BIN
in use (animated).gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 MiB

60
init.lua Normal file
View File

@ -0,0 +1,60 @@
local path = minetest.get_modpath("light_tool")
dofile(path.."/api.lua")
minetest.register_tool("light_tool:light_tool", {
description = "Light Tool",
inventory_image = "light_tool_light_tool.png",
})
light_tool.add_tool("light_tool:light_tool", 20)
minetest.register_node("light_tool:light", {
drawtype = "glasslike",
tiles = {"blank.png"},
paramtype = "light",
walkable = false,
is_ground_content = true,
light_propagates = true,
sunlight_propagates = true,
light_source = 8,
pointable = false,
buildable_to = true,
on_construct = function(pos)
minetest.after(0.1, function()
minetest.set_node(pos, {name = "air"})
end)
end,
})
minetest.register_lbm({
name = "light_tool:remove_light",
nodenames = {"light_tool:light"},
run_at_every_load = true,
action = function(pos, node)
minetest.set_node(pos, {name = "air"})
end,
})
if minetest.get_modpath("default") then
minetest.register_craft({
output = "light_tool:light_tool",
recipe = {
{"","default:mese_crystal_fragment","default:mese_crystal"},
{"default:mese_crystal_fragment","default:steel_ingot","default:mese_crystal_fragment"},
{"default:steel_ingot", "default:mese_crystal_fragment",""},
},
})
end
minetest.register_globalstep(function()
for _, user in ipairs(minetest.get_connected_players()) do
local stack = ItemStack(user:get_wielded_item())
local wielded = stack:get_definition()
if light_tool.check(light_tool.tools, wielded.name) then
local index = light_tool.check_index(light_tool.tools, wielded.name)
local dir = user:get_look_dir()
local pos = user:get_pos()
light_tool.light_beam({x = pos.x, y = pos.y+1, z = pos.z}, dir, light_tool.range[index])
end
end
end)

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B