Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minetest_game
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zadrog Pzvotrügen
minetest_game
Commits
efb81d18
Commit
efb81d18
authored
8 years ago
by
Dániel Juhász
Committed by
paramat
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Correct rotation of attached nodes, and rotate colored nodes
parent
297192dd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mods/screwdriver/init.lua
+40
-6
40 additions, 6 deletions
mods/screwdriver/init.lua
with
40 additions
and
6 deletions
mods/screwdriver/init.lua
+
40
−
6
View file @
efb81d18
...
...
@@ -11,6 +11,19 @@ screwdriver.rotate_simple = function(pos, node, user, mode, new_param2)
end
end
-- For attached wallmounted nodes: returns true if rotation is valid
-- simplified version of minetest:builtin/game/falling.lua#L148.
local
function
check_attached_node
(
pos
,
rotation
)
local
d
=
minetest
.
wallmounted_to_dir
(
rotation
)
local
p2
=
vector
.
add
(
pos
,
d
)
local
n
=
minetest
.
get_node
(
p2
).
name
local
def2
=
minetest
.
registered_nodes
[
n
]
if
def2
and
not
def2
.
walkable
then
return
false
end
return
true
end
screwdriver
.
rotate
=
{}
local
facedir_tbl
=
{
...
...
@@ -32,18 +45,39 @@ local facedir_tbl = {
},
}
screwdriver
.
rotate
.
facedir
=
function
(
node
,
mode
)
return
facedir_tbl
[
mode
][
node
.
param2
]
screwdriver
.
rotate
.
facedir
=
function
(
pos
,
node
,
mode
)
local
rotation
=
node
.
param2
%
32
-- get first 5 bits
local
other
=
node
.
param2
-
rotation
rotation
=
facedir_tbl
[
mode
][
rotation
]
or
0
return
rotation
+
other
end
screwdriver
.
rotate
.
colorfacedir
=
screwdriver
.
rotate
.
facedir
local
wallmounted_tbl
=
{
[
screwdriver
.
ROTATE_FACE
]
=
{[
2
]
=
5
,
[
3
]
=
4
,
[
4
]
=
2
,
[
5
]
=
3
,
[
1
]
=
0
,
[
0
]
=
1
},
[
screwdriver
.
ROTATE_AXIS
]
=
{[
2
]
=
5
,
[
3
]
=
4
,
[
4
]
=
2
,
[
5
]
=
1
,
[
1
]
=
0
,
[
0
]
=
3
}
}
screwdriver
.
rotate
.
wallmounted
=
function
(
node
,
mode
)
return
wallmounted_tbl
[
mode
][
node
.
param2
]
screwdriver
.
rotate
.
wallmounted
=
function
(
pos
,
node
,
mode
)
local
rotation
=
node
.
param2
%
8
-- get first 3 bits
local
other
=
node
.
param2
-
rotation
rotation
=
wallmounted_tbl
[
mode
][
rotation
]
or
0
if
minetest
.
get_item_group
(
node
.
name
,
"attached_node"
)
~=
0
then
-- find an acceptable orientation
for
i
=
1
,
5
do
if
not
check_attached_node
(
pos
,
rotation
)
then
rotation
=
wallmounted_tbl
[
mode
][
rotation
]
or
0
else
break
end
end
end
return
rotation
+
other
end
screwdriver
.
rotate
.
colorwallmounted
=
screwdriver
.
rotate
.
wallmounted
-- Handles rotation
screwdriver
.
handler
=
function
(
itemstack
,
user
,
pointed_thing
,
mode
,
uses
)
if
pointed_thing
.
type
~=
"node"
then
...
...
@@ -66,7 +100,7 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
end
local
should_rotate
=
true
local
new_param2
=
fn
(
node
,
mode
)
local
new_param2
=
fn
(
pos
,
node
,
mode
)
-- Node provides a handler, so let the handler decide instead if the node can be rotated
if
ndef
and
ndef
.
on_rotate
then
...
...
@@ -80,7 +114,7 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
should_rotate
=
false
end
else
if
not
ndef
or
not
ndef
.
paramtype2
==
"facedir"
or
if
not
ndef
or
ndef
.
on_rotate
==
false
or
(
ndef
.
drawtype
==
"nodebox"
and
(
ndef
.
node_box
and
ndef
.
node_box
.
type
~=
"fixed"
))
or
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment