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
748446b3
Commit
748446b3
authored
7 years ago
by
DS
Committed by
Vitaliy
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
MVPS: pull objects (#374)
parent
1b10610f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mesecons_movestones/init.lua
+7
-4
7 additions, 4 deletions
mesecons_movestones/init.lua
mesecons_mvps/init.lua
+4
-2
4 additions, 2 deletions
mesecons_mvps/init.lua
mesecons_pistons/init.lua
+6
-4
6 additions, 4 deletions
mesecons_pistons/init.lua
with
17 additions
and
10 deletions
mesecons_movestones/init.lua
+
7
−
4
View file @
748446b3
...
...
@@ -50,7 +50,6 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
minetest
.
get_node_timer
(
pos
):
start
(
timer_interval
)
return
end
mesecon
.
mvps_process_stack
(
stack
)
mesecon
.
mvps_move_objects
(
frontpos
,
direction
,
oldstack
)
-- ### Step 2: Move the movestone ###
...
...
@@ -61,9 +60,13 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
minetest
.
get_node_timer
(
frontpos
):
start
(
timer_interval
)
-- ### Step 3: If sticky, pull stack behind ###
if
is_sticky
then
local
backpos
=
vector
.
subtract
(
pos
,
direction
)
mesecon
.
mvps_pull_all
(
backpos
,
direction
,
max_pull
)
if
not
is_sticky
then
return
end
local
backpos
=
vector
.
subtract
(
pos
,
direction
)
success
,
stack
,
oldstack
=
mesecon
.
mvps_pull_all
(
backpos
,
direction
,
max_pull
)
if
success
then
mesecon
.
mvps_move_objects
(
backpos
,
vector
.
multiply
(
direction
,
-
1
),
oldstack
,
-
1
)
end
end
...
...
This diff is collapsed.
Click to expand it.
mesecons_mvps/init.lua
+
4
−
2
View file @
748446b3
...
...
@@ -205,7 +205,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
return
true
,
nodes
,
oldstack
end
function
mesecon
.
mvps_move_objects
(
pos
,
dir
,
nodestack
)
function
mesecon
.
mvps_move_objects
(
pos
,
dir
,
nodestack
,
movefactor
)
local
objects_to_move
=
{}
local
dir_k
local
dir_l
...
...
@@ -216,6 +216,8 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
break
end
end
movefactor
=
movefactor
or
1
dir
=
vector
.
multiply
(
dir
,
movefactor
)
for
id
,
obj
in
pairs
(
minetest
.
object_refs
)
do
local
obj_pos
=
obj
:
get_pos
()
local
cbox
=
obj
:
get_properties
().
collisionbox
...
...
@@ -229,7 +231,7 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
edge2
=
v
+
0
.
51
else
edge1
=
v
-
0
.
5
*
dir_l
edge2
=
v
+
(
#
nodestack
+
0
.
5
)
*
dir_l
edge2
=
v
+
(
#
nodestack
+
0
.
5
*
movefactor
)
*
dir_l
-- Make sure, edge1 is bigger than edge2:
if
edge1
>
edge2
then
edge1
,
edge2
=
edge2
,
edge1
...
...
This diff is collapsed.
Click to expand it.
mesecons_pistons/init.lua
+
6
−
4
View file @
748446b3
...
...
@@ -101,10 +101,12 @@ local function piston_off(pos, node)
if
not
pistonspec
.
sticky
then
return
end
local
dir
=
vector
.
multiply
(
minetest
.
facedir_to_dir
(
node
.
param2
),
-
1
)
local
pullpos
=
vector
.
add
(
pos
,
vector
.
multiply
(
dir
,
2
))
local
stack
=
mesecon
.
mvps_pull_single
(
pullpos
,
vector
.
multiply
(
dir
,
-
1
),
max_pull
)
mesecon
.
mvps_process_stack
(
pos
,
dir
,
stack
)
local
dir
=
minetest
.
facedir_to_dir
(
node
.
param2
)
local
pullpos
=
vector
.
add
(
pos
,
vector
.
multiply
(
dir
,
-
2
))
local
success
,
stack
,
oldstack
=
mesecon
.
mvps_pull_single
(
pullpos
,
dir
,
max_pull
)
if
success
then
mesecon
.
mvps_move_objects
(
pullpos
,
vector
.
multiply
(
dir
,
-
1
),
oldstack
,
-
1
)
end
end
local
orientations
=
{
...
...
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