Need help about creating a jetpack mod

Post Reply
User avatar
AFCM
Member
Posts: 21
Joined: Tue Jun 30, 2020 12:21
GitHub: AFCMS
IRC: AFCM
In-game: AFCM

Need help about creating a jetpack mod

by AFCM » Post

Hi everyone,
I am working about a jetpack mod depending of technic and 3d_armor
I want to :
-- activate fly mode on equip, but without need of a privilege ;
-- consume durability only in flight
-- unactivate when durability is null
-- doesn't break when durability is null

Charging already work.

Someone can help me ? I am a beginner.
Feel free to create pull request !
GitHub: https://github.com/AFCMS/technic_jetpack

LC Creations
Member
Posts: 157
Joined: Mon Feb 18, 2019 02:53

Re: Need help about creating a jetpack mod

by LC Creations » Post

I know you said to make a pull request but I thought I would just show you it here since it's not a lot.

As far as going up goes, the following code works... You would have to do more checks to only fly in specific conditions, I.E., when a player has the jetpack on and when it runs out of fuel. Here is a very basic base code of how to make a player fly with a jetpack-like behavior. You can play around with this code.

Code: Select all

--Untested code
minetest.register_globalstep(function(dtime) --Everything in this function happens for every step or frame of the game.
  local players = minetest.get_connected_players() --gets all players that are on the server
  for _, player in pairs(players) do --loops through each player on the server. 'player' is the current player the loop is at.
    local ctrl = player:get_player_control() --gets the control the player is pressing.
    if ctrl.jump then --if the player is pressing the jump control then do the following code
      local pos = player:get_pos() --get players position
      local speed = 2.5 --this is the players jetpack speed. 2.5 may be faster than you think but you can mess around with it.
      player:add_player_velocity({x=0,y=speed,z=0}) -- make the player go up.
    end
  end
end)

User avatar
AFCM
Member
Posts: 21
Joined: Tue Jun 30, 2020 12:21
GitHub: AFCMS
IRC: AFCM
In-game: AFCM

Re: Need help about creating a jetpack mod

by AFCM » Post

Thank for your help LC Creations !

Flying works, but I don't know how to do to be able to use the aux1 key to switch between fly mode and normal mode of the armor.
Anyone can help me ?

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests