How to activate player fly mode by a lua code?
How to activate player fly mode by a lua code?
I want when a player hits a specific block, put (and even force) him into a fly+noclip mode. Is this possible?
- texmex
- Member
- Posts: 1753
- Joined: Mon Jul 11, 2016 21:08
- GitHub: tacotexmex
- In-game: tacotexmex
Re: How to activate player fly mode by a lua code?
IIRC the player can be granted usage of the modes programmatically in such a case, but the player still has to manually activate the modes.
Re: How to activate player fly mode by a lua code?
You can set gravity individually for a player: player:set_physics_override({jump=0}). I am less sure for the noclip mode. Have you tried changing the player's collision box?
- texmex
- Member
- Posts: 1753
- Joined: Mon Jul 11, 2016 21:08
- GitHub: tacotexmex
- In-game: tacotexmex
Re: How to activate player fly mode by a lua code?
Player gravity isn't the same as fly mode though.
- Krock
- Developer
- Posts: 4650
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: How to activate player fly mode by a lua code?
A) The server does neither know about the player's free_move, noclip nor fast move settings. There's no way to control either of these using a Lua mod.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
Re: How to activate player fly mode by a lua code?
Although I've managed to simulate the derised using this code:Yvanhoe wrote:You can set gravity individually for a player: player:set_physics_override({jump=0}). I am less sure for the noclip mode. Have you tried changing the player's collision box?
Code: Select all
local players = {}
-- Create a block.
minetest.register_node(minetest.get_current_modname()..":ghost_block",
{
description = "A ghost block.",
tiles = {"default_dirt.png^[colorize:#FFFFFFFF"},
on_rightclick = function(pos, node, player, pointed_thing)
players[player:get_player_name()] = player
minetest.chat_send_all(player:get_player_name().." is a ghost.")
player:set_physics_override({gravity=0,jump=0})
player:set_properties({collisionbox={0,0,0,0,0,0}})
end
})
-- Scan the controls.
minetest.register_globalstep(function(seconds_since_last_global_step)
local controls
for player_name,player in pairs(players) do
controls = player:get_player_control()
if controls.jump then
player:set_physics_override({gravity=-1})
elseif controls.sneak then
player:set_physics_override({gravity=1})
else
player:set_physics_override({gravity=0})
end
end
end)
Since switching into a fly/noclip mode is not a server responsibility, would it be possible then with the client-side mods when an API for them will be finished?Krock wrote:There's no way to control either of these using a Lua mod.
Re: How to activate player fly mode by a lua code?
I have found out it is possible to do by attaching a player to an object. So I created a small mod library that provides an interface for it. Although it's working, I still believe that it would've been better to make it by manipulating fly+noclip modes since this mod just duplicates a feature that Minetest already has built-in by default.
https://github.com/aa6/minetest_mod_lib_astral_body
https://github.com/aa6/minetest_mod_lib_astral_body
Who is online
Users browsing this forum: No registered users and 4 guests