Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mesecons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Illuna-Minetest
mesecons
Commits
63a18f1a
Commit
63a18f1a
authored
12 years ago
by
Jeija
Browse files
Options
Downloads
Patches
Plain Diff
Don't push objects into walls and fix bug in previous commit
parent
57e15475
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mesecons_mvps/init.lua
+12
-9
12 additions, 9 deletions
mesecons_mvps/init.lua
with
12 additions
and
9 deletions
mesecons_mvps/init.lua
+
12
−
9
View file @
63a18f1a
...
...
@@ -44,7 +44,7 @@ function mesecon:mvps_get_stack(pos, dir, maximum)
local
nn
=
minetest
.
env
:
get_node_or_nil
(
np
)
if
not
nn
or
#
nodes
>
maximum
then
-- don't push at all, something is in the way (unloaded map or too many nodes)
return
return
nil
end
if
nn
.
name
==
"air"
...
...
@@ -62,6 +62,7 @@ end
function
mesecon
:
mvps_push
(
pos
,
dir
,
maximum
)
-- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed
local
nodes
=
mesecon
:
mvps_get_stack
(
pos
,
dir
,
maximum
)
if
not
nodes
then
return
end
-- determine if one of the nodes blocks the push
for
id
,
n
in
ipairs
(
nodes
)
do
if
mesecon
:
is_mvps_stopper
(
n
.
node
,
dir
,
nodes
,
id
)
then
...
...
@@ -139,6 +140,8 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
end
function
mesecon
:
mvps_move_objects
(
pos
,
dir
,
nodestack
)
local
objects_to_move
=
{}
-- Move object at tip of stack
local
pushpos
=
mesecon
:
addPosRule
(
pos
,
-- get pos at tip of stack
{
x
=
dir
.
x
*
(
#
nodestack
),
...
...
@@ -148,29 +151,29 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
local
objects
=
minetest
.
env
:
get_objects_inside_radius
(
pushpos
,
1
)
for
_
,
obj
in
ipairs
(
objects
)
do
local
entity
=
obj
:
get_luaentity
()
if
not
entity
or
not
mesecon
:
is_mvps_unmov
(
entity
.
name
)
then
obj
:
setpos
(
mesecon
:
addPosRule
(
obj
:
getpos
(),
dir
))
end
table.insert
(
objects_to_move
,
obj
)
end
-- Move objects lying/standing on the stack (before it was pushed - oldstack)
local
objects_above
=
{}
if
tonumber
(
minetest
.
setting_get
(
"movement_gravity"
))
>
0
and
dir
.
y
==
0
then
-- If gravity positive and dir horizontal, push players standing on the stack
for
_
,
n
in
ipairs
(
nodestack
)
do
local
p_above
=
mesecon
:
addPosRule
(
n
.
pos
,
{
x
=
0
,
y
=
1
,
z
=
0
})
local
objects
=
minetest
.
env
:
get_objects_inside_radius
(
p_above
,
1
)
for
_
,
obj
in
ipairs
(
objects
)
do
table.insert
(
objects_
ab
ove
,
obj
)
table.insert
(
objects_
to_m
ove
,
obj
)
end
end
end
for
_
,
obj
in
ipairs
(
objects_
ab
ove
)
do
for
_
,
obj
in
ipairs
(
objects_
to_m
ove
)
do
local
entity
=
obj
:
get_luaentity
()
if
not
entity
or
not
mesecon
:
is_mvps_unmov
(
entity
.
name
)
then
obj
:
setpos
(
mesecon
:
addPosRule
(
obj
:
getpos
(),
dir
))
local
np
=
mesecon
:
addPosRule
(
obj
:
getpos
(),
dir
)
local
nn
=
minetest
.
env
:
get_node
(
np
)
if
not
minetest
.
registered_nodes
[
nn
.
name
].
walkable
then
obj
:
setpos
(
np
)
end
end
end
end
...
...
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