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
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
minetest_game
Commits
59dbeebc
Unverified
Commit
59dbeebc
authored
6 years ago
by
Paramat
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Boats: Add cruise mode (boat autoforward)
Document controls in README.txt. Optimise 'get yaw' and 'set yaw' code.
parent
876a9ca5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mods/boats/README.txt
+16
-0
16 additions, 0 deletions
mods/boats/README.txt
mods/boats/init.lua
+21
-8
21 additions, 8 deletions
mods/boats/init.lua
with
37 additions
and
8 deletions
mods/boats/README.txt
+
16
−
0
View file @
59dbeebc
...
...
@@ -13,3 +13,19 @@ Textures: Zeg9 (CC BY-SA 3.0)
Model: thetoon and Zeg9 (CC BY-SA 3.0),
modified by PavelS(SokolovPavel) (CC BY-SA 3.0),
modified by sofar (CC BY-SA 3.0)
Controls
--------
Right mouse button = Enter or exit boat when pointing at boat.
Forward = Speed up.
Slow down when moving backwards.
Forward + backward = Enable cruise mode: Boat will accelerate to maximum forward
speed and remain at that speed without needing to hold the
forward key.
Backward = Slow down.
Speed up when moving backwards.
Disable cruise mode.
Left = Turn to the left.
Turn to the right when moving backwards.
Right = Turn to the right.
Turn to the left when moving backwards.
This diff is collapsed.
Click to expand it.
mods/boats/init.lua
+
21
−
8
View file @
59dbeebc
...
...
@@ -44,7 +44,8 @@ local boat = {
driver
=
nil
,
v
=
0
,
last_v
=
0
,
removed
=
false
removed
=
false
,
auto
=
false
}
...
...
@@ -55,6 +56,7 @@ function boat.on_rightclick(self, clicker)
local
name
=
clicker
:
get_player_name
()
if
self
.
driver
and
clicker
==
self
.
driver
then
self
.
driver
=
nil
self
.
auto
=
false
clicker
:
set_detach
()
player_api
.
player_attached
[
name
]
=
false
player_api
.
set_animation
(
clicker
,
"stand"
,
30
)
...
...
@@ -130,24 +132,35 @@ end
function
boat
.
on_step
(
self
,
dtime
)
self
.
v
=
get_v
(
self
.
object
:
get_velocity
())
*
get_sign
(
self
.
v
)
if
self
.
driver
then
local
driver_name
=
self
.
driver
:
get_player_name
()
local
ctrl
=
self
.
driver
:
get_player_control
()
local
yaw
=
self
.
object
:
get_yaw
()
if
ctrl
.
up
then
self
.
v
=
self
.
v
+
0
.
1
if
ctrl
.
up
and
ctrl
.
down
then
if
not
self
.
auto
then
self
.
auto
=
true
minetest
.
chat_send_player
(
driver_name
,
"[boats] Cruise on"
)
end
elseif
ctrl
.
down
then
self
.
v
=
self
.
v
-
0
.
1
if
self
.
auto
then
self
.
auto
=
false
minetest
.
chat_send_player
(
driver_name
,
"[boats] Cruise off"
)
end
elseif
ctrl
.
up
or
self
.
auto
then
self
.
v
=
self
.
v
+
0
.
1
end
if
ctrl
.
left
then
if
self
.
v
<
0
then
self
.
object
:
set_yaw
(
yaw
-
(
1
+
dtime
)
*
0
.
03
)
self
.
object
:
set_yaw
(
self
.
object
:
get_
yaw
()
-
(
1
+
dtime
)
*
0
.
03
)
else
self
.
object
:
set_yaw
(
yaw
+
(
1
+
dtime
)
*
0
.
03
)
self
.
object
:
set_yaw
(
self
.
object
:
get_
yaw
()
+
(
1
+
dtime
)
*
0
.
03
)
end
elseif
ctrl
.
right
then
if
self
.
v
<
0
then
self
.
object
:
set_yaw
(
yaw
+
(
1
+
dtime
)
*
0
.
03
)
self
.
object
:
set_yaw
(
self
.
object
:
get_
yaw
()
+
(
1
+
dtime
)
*
0
.
03
)
else
self
.
object
:
set_yaw
(
yaw
-
(
1
+
dtime
)
*
0
.
03
)
self
.
object
:
set_yaw
(
self
.
object
:
get_
yaw
()
-
(
1
+
dtime
)
*
0
.
03
)
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