Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

123abc1920/minetest-compass

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compass - Mod for minetest

This mod adds compasses and special blocks. The compasses are attached to the block and point at it. Blocks and compasses have names.

Content

  1. Blocks and Items
  2. Using
  3. API

Blocks and Items

  1. Point Block

    Home Block
    Craft

  2. Compass

    Compass

Using

  1. Right click at point block and set name of block.
    Set name
  2. Left click at point block with compass.
  3. Left click with compass in hand and its arrow will point at attached block.

API

The name and the coordinates of blocks are stored in mod_storage, key is "compasses".

Function changeCompass (line 161) starts when left click with compass in hand. If there is point block near, then compass gets attached to it.

Else function compassImg (line 106) starts. It controls the arrow.

In the drawing the red point is the point block, green is player. Blue line is direction of view. Yellow line built with two points - block point and player coordinates.

Blue and yellow lines are 2D vectors (x-z coordinates). Black is angle A between vectors. It calculates with formula:

ab=|a||b|cosA

Then use cross product of vectors to determine where block is located regarding player`s line of view. If it is on the right then add 180 to angle A.

The arrow of compass deviates by an angle A.

Diagram

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.