[Mod] gravitysim

Gundul
Member
 
Posts: 177
Joined: Thu Aug 27, 2015 10:55
GitHub: berengma
IRC: Gundul

[Mod] gravitysim

by Gundul » Sun Jul 24, 2016 15:56

Description: This mod adds gravity simulation to your world. (not realistic though). It makes the gravity decrease the higher your avatar climbs.
And the higher you climb the higher you can jump.

Depends: nothing

License: nothing, free of everything, do what ever you want with it

No warranties, no garanties. If you run this on your server and your world says good bye do not blame me




I made this for my server, because player there building a space station and I thought it would be nice to have some
low gravity and moonlike jumping. Maybe some people find that also useful. Play around with the values so it suit the needs of your world.


Installation:

- create a new folder "gravitysim" in your mods directory.
- go in that folder and create a new text document "init.lua"
- copy below code to the document and save.
- start Minetest and activate gravitysim in your world


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
--gravitysim   made by Gundul no copyright nothing, do what you want with it
--
-- do not expect realism here. This is just for fun. So try out any values you like
-- and which suit your needs :)
--
-- have fun



local timer = 0
local checktime = 5 -- postion check intervall
local gravity = 1 -- standard on earth 9,81 m/s*s on sea level that is equal with 1 in Minetest game

minetest.register_globalstep(function(dtime)
   
   timer = timer + dtime;
   if timer >= checktime then
   
     -- check all player altitudes and set new gravity
   
    
    
   local players = minetest.get_connected_players();
      
      
      for _,player in pairs(players) do
         local pos = player:getpos(); -- feet position
         local y=pos.y;               -- we only need the y ccordinate
         
         
         
        if y ~= nil then
          local newgrav=1;
          local newjump=1;
         
         
               if y >= 0 then
         
              newgrav = gravity - (y/1500);    -- going up in the sky just try out some values to suit your needs
              newjump = 1 + y/125,             -- jumping calculation
              
              player:set_physics_override({gravity = newgrav,jump = newjump });
              
          else
            
            -- commented out because if cannot even jump one node high its pretty useless to jump at all :)
            
             -- newgrav = gravity - (y/32000);    -- going to the center of earth
             -- newjump = 1 + y/10000             -- jumping should get lower the deeper you are
              
              
             -- player:set_physics_override({gravity = newgrav,jump = newjump });
              
          end
         
         
         
         
                -- minetest.chat_send_all("I come and get your y position :) y-pos = ".. y .. " newgravity is : ".. newgrav) -- commend this out for ingame debug
        else
         
         
        --minetest.chat_send_all("something went wrong") -- commend this out for ingame debug
       
        end
      end
      
   
   
   timer =0
   
   end
end)
Last edited by Gundul on Sun Jul 24, 2016 18:20, edited 1 time in total.
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: [Mod] gravitysim

by DS-minetest » Sun Jul 24, 2016 16:33

nice
but isnt on earth the placefactor g=9,81m/s² and not m*s²
Do not call me -minetest.
Call me DS or DS-minetest.
I am German, so you don't have to pm me English if you are also German.
The background is a lie.
 

Gundul
Member
 
Posts: 177
Joined: Thu Aug 27, 2015 10:55
GitHub: berengma
IRC: Gundul

Re: [Mod] gravitysim

by Gundul » Sun Jul 24, 2016 18:20

DS-minetest wrote:nice
but isnt on earth the placefactor g=9,81m/s² and not m*s²


oh embarassing, I have to go back to school :D

thanks
 

User avatar
Sirmentio
Member
 
Posts: 18
Joined: Thu Apr 21, 2016 17:22
In-game: Sirmentio

Re: [Mod] gravitysim

by Sirmentio » Sun Jul 24, 2016 20:29

This sounds cool! I can't wait to try this myself!
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [Mod] gravitysim

by azekill_DIABLO » Mon Jul 25, 2016 09:44

+1 when we do a minetest parody of interstellar?
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

ABJ
Member
 
Posts: 2344
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ

Re: [Mod] gravitysim

by ABJ » Tue Aug 30, 2016 08:49

Accidental necropost, mod delete please.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron