Update motorbike mod to Git commit f918701...

...and patch to make ownable.

Commit: https://github.com/Extex101/motorbike/tree/f918701
This commit is contained in:
Jordan Irwin 2021-05-28 17:13:37 -07:00
parent 7121c63041
commit b4b068c346
7 changed files with 83 additions and 21 deletions

View File

@ -133,7 +133,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* [helicopter][] ([GPL][lic.gpl2.0] / [CC0][lic.cc0] / CC BY-NC) -- version: [d3985b0 Git][ver.helicopter] *2021-04-27* ([patched][patch.helicopter])
* [hot_air_balloons][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa3.0]) -- version: [39a3572 Git][ver.hot_air_balloons] *2020-11-17*
* [hovercraft][] ([LGPL / CC BY-SA / CC0][lic.hovercraft]) -- version: [4d50e68 Git][ver.hovercraft] *2017-05-14* ([patched][patch.hovercraft])
* [motorbike][] ([MIT][lic.motorbike]) -- version: [9527d56 Git][ver.motorbike] *2021-04-01* ([patched][patch.motorbike])
* [motorbike][] ([MIT][lic.motorbike]) -- version: [f918701 Git][ver.motorbike] *2021-05-22* ([patched][patch.motorbike])
* ui/
* [bookmarks_gui][] ([BSD 3-Clause][lic.bookmarks_gui]) -- version: [f7ae10a Git][ver.bookmarks_gui] *2017-08-29*
* [hbarmor][] ([MIT][lic.mit] / [CC BY-SA][lic.ccbysa3.0]) -- version: [1.0.0][ver.hbarmor] *2019-04-01*
@ -586,7 +586,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.moreblocks]: https://github.com/minetest-mods/moreblocks/tree/3b97ea5
[ver.moremesecons]: https://github.com/minetest-mods/MoreMesecons/tree/1dab017
[ver.moreores]: https://github.com/minetest-mods/moreores/tree/3fe0ba8
[ver.motorbike]: https://github.com/Extex101/motorbike/tree/9527d56
[ver.motorbike]: https://github.com/Extex101/motorbike/tree/f918701
[ver.mthudclock]: https://gitlab.com/Rochambeau/mthudclock/tree/d86e745
[ver.mydoors]: https://github.com/minetest-mods/mydoors/tree/eef3b5f
[ver.myfences]: https://github.com/DonBatman/myfences/tree/c6e529a
@ -661,7 +661,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[patch.minetest_game]: https://github.com/AntumMT/mtgame-minetest/tree/355a756
[patch.moreblocks]: https://github.com/AntumMT/mod-moreblocks/tree/6dda839
[patch.moreores]: https://github.com/AntumMT/mod-moreores/tree/ae59578
[patch.motorbike]: https://github.com/AntumMT/mod-motorbike/tree/3bb0c6a
[patch.motorbike]: https://github.com/AntumMT/mod-motorbike/tree/fda6a40
[patch.mysheetmetal]: https://github.com/AntumMT/mod-mysheetmetal/tree/2ffb3a2
[patch.nether]: https://github.com/AntumMT/mod-nether/tree/7a84ddd
[patch.pipeworks]: https://gitlab.com/AntumMT/mod-pipeworks/tree/48b082e

View File

@ -0,0 +1,4 @@
player_api
default
wool
signs?

View File

@ -19,7 +19,11 @@ local settings = {
-- Ability to punch the motorbike to kick the rider
kick = true,
-- Enable custom plates, requires "signs" mod
custom_plates = true
custom_plates = true,
-- Bike is be placed directly in inventory when punched
punch_inv = true,
-- "owner" attribute is set when bike is placed
ownable = minetest.settings:get_bool("mount_ownable", true),
}
for setting, default in pairs(settings) do
local value = minetest.settings:get("motorbike." .. setting)
@ -27,7 +31,6 @@ for setting, default in pairs(settings) do
biker[setting] = value
end
biker.path = minetest.get_modpath"motorbike"
dofile(biker.path .. "/settings.lua")
dofile(biker.path .. "/functions.lua")
local bikelist = {
"black",
@ -64,14 +67,18 @@ for _, colour in pairs(bikelist) do
},
drop = "motorbike:" .. colour,
on_activate = function(self, staticdata)
if staticdata and biker.signs then
self.platenumber = staticdata
if staticdata then
local sdata = minetest.deserialize(staticdata)
self.owner = sdata.owner
if biker.signs then
self.platenumber = sdata.platenumber
local pos = self.object:get_pos()
self.plate = minetest.add_entity(pos, "motorbike:licenseplate")
if self.plate then
self.plate:set_attach(self.object, "", { x = -0.2, y = -1.9, z = -12.12 }, { x = 0, y = 0, z = 0 })
end
end
end
self.timer1 = 0
self.timer2 = 0
self.object:set_armor_groups{ immortal = 1 }
@ -79,6 +86,11 @@ for _, colour in pairs(bikelist) do
end,
on_rightclick = function(self, clicker)
if not self.driver then
local pname = clicker:get_player_name()
if settings.ownable and self.owner and self.owner ~= pname then
minetest.chat_send_player(pname, "You cannot ride " .. self.owner .. "'s motorbike")
return
end
biker.attach(self, clicker, false)
minetest.sound_play("motorbike_start", {
max_hear_distance = 24,
@ -96,8 +108,13 @@ for _, colour in pairs(bikelist) do
return
end
if not self.driver then
local pname = puncher:get_player_name()
if settings.ownable and self.owner and self.owner ~= pname then
minetest.chat_send_player(pname, "You cannot take " .. self.owner .. "'s motorbike")
return
end
if biker.breakable then
if not biker.punch_inv then
if not settings.punch_inv then
local pos = self.object:get_pos()
local item = minetest.add_item(pos, self.drop)
if item then
@ -108,7 +125,7 @@ for _, colour in pairs(bikelist) do
local stack = ItemStack(self.drop)
local pinv = puncher:get_inventory()
if not pinv:room_for_item("main", stack) then
core.chat_send_player(puncher:get_player_name(), "You do not have room in your inventory")
core.chat_send_player(pname, "You do not have room in your inventory")
return
end
pinv:add_item("main", stack)
@ -123,7 +140,13 @@ for _, colour in pairs(bikelist) do
end
end,
on_step = biker.drive,
get_staticdata = function(self) if biker.signs then return self.platenumber end end
get_staticdata = function(self)
local sdata = {
owner = self.owner,
platenumber = self.platenumber,
}
return minetest.serialize(sdata)
end
})
minetest.register_craftitem("motorbike:" .. colour, {
description = colour:gsub("^%l", string.upper):gsub("_", " ") .. " bike",
@ -131,7 +154,9 @@ for _, colour in pairs(bikelist) do
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then return end
local pos = { x = pointed_thing.above.x, y = pointed_thing.above.y + 1, z = pointed_thing.above.z }
local bike = minetest.add_entity(pos, "motorbike:bike_" .. colour, biker.get_plate(placer:get_player_name()))
local pname = placer:get_player_name()
local sdata = {owner=pname, platenumber=biker.get_plate(pname)}
local bike = minetest.add_entity(pos, "motorbike:bike_" .. colour, minetest.serialize(sdata))
bike:set_yaw(placer:get_look_horizontal())
itemstack:take_item()
return itemstack

View File

@ -1,4 +1,4 @@
name = motorbike
description = Adds various coloured motorbikes to Minetest Game
depends = player_api, default, wool
depends = default, player_api, wool
optional_depends = signs

View File

@ -1,3 +0,0 @@
-- If enabled, bike is be placed in inventory when punched.
biker.punch_inv = core.settings:get_bool("motorbike.punch_inv", false)

View File

@ -1,3 +1,36 @@
# Turning speed of bike, 1 is instant.
motorbike.turn_power (Turning speed) float 0.07
# Top speed the bike can go.
motorbike.max_speed (Top speed) float 17
# Top speed in reverse.
motorbike.max_reverse (Top speed reverse) float 5
# Acceleration.
motorbike.acceleration (Acceleration) float 1.5
# Braking power.
motorbike.braking (Braking power) float 5
# Step height.
motorbike.stepheight (Step height) float 1.3
# Whether the bike is breakable.
motorbike.breakable (Breakable) bool true
# Same as max_speed but on nodes like dirt, sand, gravel ect.
motorbike.crumbly_spd (Top speed crumbly) float 11
# Ability to punch the motorbike to kick the rider.
motorbike.kick (Punch kicks rider) bool true
# Enable custom plates, requires "signs" mod.
motorbike.custom_plates (Custom plates) bool true
# If enabled, bike is placed in inventory when punched.
motorbike.punch_inv (Punch places in inventory) bool false
motorbike.punch_inv (Punch places in inventory) bool true
# Mounted entities can only be used by owners.
mount_ownable (Ownable mounts) bool true

View File

@ -44,6 +44,9 @@ enable_mob_nametags (Enable mob nametags) bool false
# player is looking.
mount_turn_player_look (Turn with look direction) bool false
# Mounted entities can only be used by owners.
mount_ownable (Ownable mounts) bool true
# ---------------------------------------------------------------------------------