Compare commits
10 Commits
f06f24628b
...
0f616845de
Author | SHA1 | Date | |
---|---|---|---|
|
0f616845de | ||
|
a62d81f3fc | ||
|
2186b6e970 | ||
|
5ddd166197 | ||
|
f265515947 | ||
|
906c72b95f | ||
|
97704cf0fa | ||
|
9cf4f59a34 | ||
|
217b7fd147 | ||
|
1660684bc2 |
36
README.md
@ -1,5 +1,5 @@
|
|||||||
Realcompass
|
Real Compass
|
||||||
===========
|
============
|
||||||
|
|
||||||
**compass** *(n)* A mechanical or electronic instrument used for navigation or orienteering,
|
**compass** *(n)* A mechanical or electronic instrument used for navigation or orienteering,
|
||||||
which points to the physical or magnetic north pole.
|
which points to the physical or magnetic north pole.
|
||||||
@ -11,27 +11,45 @@ David_G (kestral246@gmail.com)
|
|||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
It's only feature is to act like a real compass and always point to the north.
|
This mod tries to address what the "real" essence of being a compass is all about.
|
||||||
|
|
||||||
|
No options, no gui's, just an animated needle that points toward the north.
|
||||||
|
|
||||||
|
I'm now using compass textures derived from the wonderful ones created by tacotexmex for ccompass.
|
||||||
|
I changed the colors and crafting recipe so that it can hopefully be used in parallel with ccompass,
|
||||||
|
since they both provide different features.
|
||||||
|
|
||||||
|
I have returned to using 16 pointing directions. *(I started with tacotexmex's 16-direction update for ccompass, but I changed the colors and slightly shortened most of the compass needles.)*
|
||||||
|
|
||||||
|
**New:** I have updated this mod to work with the craftguide mod. *(Thanks to feedback from FreeGamers.)*
|
||||||
|
|
||||||
|
|
||||||
|
![Realcompass Screenshot](screenshot.png "Realcompass")
|
||||||
|
|
||||||
|
|
||||||
Crafting guide
|
Crafting guide
|
||||||
--------------
|
--------------
|
||||||
|
**New:** Reduced cost of recipe by replacing mese\_fragment with glass.
|
||||||
|
|
||||||
```
|
```
|
||||||
, steel_ingot ,
|
, steel_ingot ,
|
||||||
steel_ingot, mese_crystal_fragment, steel_ingot
|
copper_ingot, glass , copper_ingot
|
||||||
, steel_ingot ,
|
, copper_ingot,
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
- **textures:** original compass textures: CC BY-SA by Echo (45deg versions added by kestral246 also CC BY-SA)
|
- **new textures:** derived from ccompass, textures CC BY-SA by tacotexmex (changes by kestral246 also CC BY-SA)
|
||||||
- **code:** My changes to original code are CC0-1.0
|
- **code:** My changes to original code are CC0-1.0
|
||||||
- **original compassgps license:** Original code by Echo, PilzAdam, and TeTpaAka is WTFPL. Kilarin (Donald Hines) changes are CC0 (No rights reserved)
|
- **original compassgps license:** Original code by Echo, PilzAdam, and TeTpaAka is WTFPL. Kilarin (Donald Hines) changes are CC0 (No rights reserved)
|
||||||
|
|
||||||
|
|
||||||
Thanks
|
Thanks
|
||||||
------
|
------
|
||||||
- [compassgps](https://github.com/Kilarin/compassgps) / Kilarin (Donald Hines),
|
This mod is basically compassgps with 90% of its code ripped out, so I can't take much credit.
|
||||||
et. al.
|
That belongs to Echo, PilzAdams, TeTpaAka, and Kilarin. I was just standing on their shoulders.
|
||||||
|
|
||||||
|
- [compassgps](https://github.com/Kilarin/compassgps) / Kilarin (Donald Hines),
|
||||||
|
et. al.
|
||||||
|
- [ccompass](https://github.com/minetest-mods/ccompass) / code: bell07, textures: tacotexmex
|
||||||
|
@ -1 +1 @@
|
|||||||
default
|
default?
|
||||||
|
171
init.lua
@ -1,107 +1,100 @@
|
|||||||
-- realcompass 1.0
|
-- realcompass 1.23
|
||||||
-- This fork written by David_G (kestral246@gmail.com)
|
-- This fork written by David_G (kestral246@gmail.com)
|
||||||
-- My changes are CC0 (No rights reserved)
|
|
||||||
-- textures: original compass textures: CC BY-SA by Echo (I added 45deg versions)
|
|
||||||
-- Changes:
|
|
||||||
-- only points north
|
|
||||||
-- 16 directions instead of 12
|
|
||||||
|
|
||||||
-- based on compassgps 2.7 and compass 0.5
|
|
||||||
--
|
--
|
||||||
--Original code by Echo, PilzAdam, and TeTpaAka is WTFPL.
|
-- 2020-02-20
|
||||||
--Original code by Kilarin (Donald Hines) is CC0 (No rights reserved).
|
|
||||||
--fixed bug that caused compass to jump around in inventory
|
|
||||||
|
|
||||||
local activewidth=8 --until I can find some way to get it from minetest
|
local activewidth=8 --until I can find some way to get it from minetest
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
local players = minetest.get_connected_players()
|
local players = minetest.get_connected_players()
|
||||||
for i,player in ipairs(players) do
|
for i,player in ipairs(players) do
|
||||||
|
|
||||||
local gotacompass=false
|
local gotacompass=false
|
||||||
local wielded=false
|
local wielded=false
|
||||||
local activeinv=nil
|
local activeinv=nil
|
||||||
local stackidx=0
|
local stackidx=0
|
||||||
--first check to see if the user has a compass, because if they don't
|
--first check to see if the user has a compass, because if they don't
|
||||||
--there is no reason to waste time calculating bookmarks or spawnpoints.
|
--there is no reason to waste time calculating bookmarks or spawnpoints.
|
||||||
local wielded_item = player:get_wielded_item():get_name()
|
local wielded_item = player:get_wielded_item():get_name()
|
||||||
if string.sub(wielded_item, 0, 12) == "realcompass:" then
|
if string.sub(wielded_item, 0, 12) == "realcompass:" then
|
||||||
--if the player is wielding a compass, change the wielded image
|
--if the player is wielding a compass, change the wielded image
|
||||||
wielded=true
|
wielded=true
|
||||||
stackidx=player:get_wield_index()
|
stackidx=player:get_wield_index()
|
||||||
gotacompass=true
|
gotacompass=true
|
||||||
else
|
else
|
||||||
--check to see if compass is in active inventory
|
--check to see if compass is in active inventory
|
||||||
if player:get_inventory() then
|
if player:get_inventory() then
|
||||||
--is there a way to only check the activewidth items instead of entire list?
|
--is there a way to only check the activewidth items instead of entire list?
|
||||||
--problem being that arrays are not sorted in lua
|
--problem being that arrays are not sorted in lua
|
||||||
for i,stack in ipairs(player:get_inventory():get_list("main")) do
|
for i,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||||
if i<=activewidth and string.sub(stack:get_name(), 0, 12) == "realcompass:" then
|
if i<=activewidth and string.sub(stack:get_name(), 0, 12) == "realcompass:" then
|
||||||
activeinv=stack --store the stack so we can update it later with new image
|
activeinv=stack --store the stack so we can update it later with new image
|
||||||
stackidx=i --store the index so we can add image at correct location
|
stackidx=i --store the index so we can add image at correct location
|
||||||
gotacompass=true
|
gotacompass=true
|
||||||
break
|
break
|
||||||
end --if i<=activewidth
|
end --if i<=activewidth
|
||||||
end --for loop
|
end --for loop
|
||||||
end -- get_inventory
|
end -- get_inventory
|
||||||
end --if wielded else
|
end --if wielded else
|
||||||
|
|
||||||
--dont mess with the rest of this if they don't have a compass
|
--dont mess with the rest of this if they don't have a compass
|
||||||
--update to remove legacy get_look_yaw function
|
--update to remove legacy get_look_yaw function
|
||||||
if gotacompass then
|
if gotacompass then
|
||||||
local dir = player:get_look_horizontal()
|
local dir = player:get_look_horizontal()
|
||||||
local angle_relative = math.deg(dir)
|
local angle_relative = math.deg(dir)
|
||||||
local compass_image = math.floor((angle_relative/22.5) + 0.5)%16
|
local compass_image = math.floor((angle_relative/22.5) + 0.5)%16
|
||||||
|
|
||||||
--update compass image to point at target
|
--update compass image to point at target
|
||||||
if wielded then
|
if wielded then
|
||||||
player:set_wielded_item("realcompass:"..compass_image)
|
player:set_wielded_item("realcompass:"..compass_image)
|
||||||
elseif activeinv then
|
elseif activeinv then
|
||||||
player:get_inventory():set_stack("main",stackidx,"realcompass:"..compass_image)
|
player:get_inventory():set_stack("main",stackidx,"realcompass:"..compass_image)
|
||||||
end --if wielded elsif activin
|
end --if wielded elsif activin
|
||||||
end --if gotacompass
|
end --if gotacompass
|
||||||
end --for i,player in ipairs(players)
|
end --for i,player in ipairs(players)
|
||||||
end) -- register_globalstep
|
end) -- register_globalstep
|
||||||
|
|
||||||
local images = {
|
local images = {
|
||||||
"realcompass_0.png",
|
"realcompass_0.png",
|
||||||
"realcompass_1.png",
|
"realcompass_1.png",
|
||||||
"realcompass_2.png",
|
"realcompass_2.png",
|
||||||
"realcompass_3.png",
|
"realcompass_3.png",
|
||||||
"realcompass_4.png",
|
"realcompass_4.png",
|
||||||
"realcompass_5.png",
|
"realcompass_5.png",
|
||||||
"realcompass_6.png",
|
"realcompass_6.png",
|
||||||
"realcompass_7.png",
|
"realcompass_7.png",
|
||||||
"realcompass_8.png",
|
"realcompass_8.png",
|
||||||
"realcompass_9.png",
|
"realcompass_9.png",
|
||||||
"realcompass_10.png",
|
"realcompass_10.png",
|
||||||
"realcompass_11.png",
|
"realcompass_11.png",
|
||||||
"realcompass_12.png",
|
"realcompass_12.png",
|
||||||
"realcompass_13.png",
|
"realcompass_13.png",
|
||||||
"realcompass_14.png",
|
"realcompass_14.png",
|
||||||
"realcompass_15.png",
|
"realcompass_15.png",
|
||||||
}
|
}
|
||||||
|
|
||||||
local i
|
local i
|
||||||
for i,img in ipairs(images) do
|
for i,img in ipairs(images) do
|
||||||
local inv = 1
|
local inv = 1
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
inv = 0
|
inv = 0
|
||||||
end
|
end
|
||||||
minetest.register_tool("realcompass:"..(i-1), {
|
minetest.register_tool("realcompass:"..(i-1), {
|
||||||
description = "Real Compass",
|
description = "Real Compass",
|
||||||
inventory_image = img,
|
inventory_image = img,
|
||||||
wield_image = img,
|
wield_image = img,
|
||||||
groups = {not_in_creative_inventory=inv}
|
groups = {not_in_creative_inventory=inv}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_craft({
|
-- crafting recipe only works if default mod present.
|
||||||
output = 'realcompass:1',
|
if minetest.get_modpath("default") ~= nil then
|
||||||
recipe = {
|
minetest.register_craft({
|
||||||
{'', 'default:steel_ingot', ''},
|
output = 'realcompass:0',
|
||||||
{'default:steel_ingot', 'default:mese_crystal_fragment', 'default:steel_ingot'},
|
recipe = {
|
||||||
{'', 'default:steel_ingot', ''}
|
{'', 'default:steel_ingot', ''},
|
||||||
}
|
{'default:copper_ingot', 'default:glass', 'default:copper_ingot'},
|
||||||
})
|
{'', 'default:copper_ingot', ''}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
3
mod.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = realcompass
|
||||||
|
description = A simple compass that only points north.
|
||||||
|
optional_depends = default
|
BIN
screenshot.png
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 523 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 495 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 487 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 490 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 487 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 528 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 484 B After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 2.5 KiB |