unify codestyle [2]
This commit is contained in:
parent
9e074af07f
commit
49044ac15e
|
@ -46,6 +46,28 @@ Your commit names should be relatively descriptive, e.g. when saying "Fix #issue
|
|||
|
||||
Contributors will be credited in `CREDITS.md`.
|
||||
|
||||
## Code Style
|
||||
|
||||
Each mod must provide `mod.conf`.
|
||||
Each mod which add API functions should store functions inside a global table named like the mod.
|
||||
Object oriented API shoud be avoided e.g.:`function mobs.register_mod(self)`
|
||||
Functions should be defined in this way:
|
||||
```
|
||||
function mcl_xyz.stuff(param) end
|
||||
```
|
||||
Insteed of this way:
|
||||
```
|
||||
mcl_xyz.stuff = function(param) end
|
||||
```
|
||||
Indentation must be unified, more likely with tabs.
|
||||
|
||||
Time sensitive mods should make a local copy of most used API functions to improve performances.
|
||||
```
|
||||
local vector = vector
|
||||
local get_node = minetest.get_node
|
||||
```
|
||||
|
||||
|
||||
## Features > 1.12
|
||||
|
||||
If you want to make a feature that was added in a Minecraft version later than 1.12, you should fork MineClone5 (mineclone5 branch in the repository) and add your changes to this.
|
||||
|
|
|
@ -13,7 +13,7 @@ minetest.log("info", "[mcl_moon] Moon phase offset of this world: "..phase_offse
|
|||
mcl_moon = {}
|
||||
mcl_moon.MOON_PHASES = MOON_PHASES
|
||||
|
||||
mcl_moon.get_moon_phase = function()
|
||||
function mcl_moon.get_moon_phase()
|
||||
local after_midday = 0
|
||||
-- Moon phase changes after midday
|
||||
local tod = minetest.get_timeofday()
|
||||
|
@ -23,7 +23,7 @@ mcl_moon.get_moon_phase = function()
|
|||
return (minetest.get_day_count() + phase_offset + after_midday) % MOON_PHASES
|
||||
end
|
||||
|
||||
local get_moon_texture = function()
|
||||
local function get_moon_texture()
|
||||
local phase = mcl_moon.get_moon_phase()
|
||||
local x = phase % MOON_PHASES_HALF
|
||||
local y
|
||||
|
|
|
@ -20,7 +20,7 @@ mcl_weather.rain = {
|
|||
init_done = false,
|
||||
}
|
||||
|
||||
mcl_weather.rain.sound_handler = function(player)
|
||||
function mcl_weather.rain.sound_handler(player)
|
||||
return minetest.sound_play("weather_rain", {
|
||||
to_player = player:get_player_name(),
|
||||
loop = true,
|
||||
|
@ -28,7 +28,7 @@ mcl_weather.rain.sound_handler = function(player)
|
|||
end
|
||||
|
||||
-- set skybox based on time (uses skycolor api)
|
||||
mcl_weather.rain.set_sky_box = function()
|
||||
function mcl_weather.rain.set_sky_box()
|
||||
if mcl_weather.state == "rain" then
|
||||
mcl_weather.skycolor.add_layer(
|
||||
"weather-pack-rain-sky",
|
||||
|
@ -46,8 +46,7 @@ end
|
|||
|
||||
-- creating manually parctiles instead of particles spawner because of easier to control
|
||||
-- spawn position.
|
||||
mcl_weather.rain.add_rain_particles = function(player)
|
||||
|
||||
function mcl_weather.rain.add_rain_particles(player)
|
||||
mcl_weather.rain.last_rp_count = 0
|
||||
for i=mcl_weather.rain.particles_count, 1,-1 do
|
||||
local random_pos_x, random_pos_y, random_pos_z = mcl_weather.get_random_pos_by_player_look_dir(player)
|
||||
|
@ -70,7 +69,7 @@ mcl_weather.rain.add_rain_particles = function(player)
|
|||
end
|
||||
|
||||
-- Simple random texture getter
|
||||
mcl_weather.rain.get_texture = function()
|
||||
function mcl_weather.rain.get_texture()
|
||||
local texture_name
|
||||
local random_number = math.random()
|
||||
if random_number > 0.33 then
|
||||
|
@ -85,7 +84,7 @@ end
|
|||
|
||||
-- register player for rain weather.
|
||||
-- basically needs for origin sky reference and rain sound controls.
|
||||
mcl_weather.rain.add_player = function(player)
|
||||
function mcl_weather.rain.add_player(player)
|
||||
if mcl_weather.players[player:get_player_name()] == nil then
|
||||
local player_meta = {}
|
||||
player_meta.origin_sky = {player:get_sky()}
|
||||
|
@ -95,7 +94,7 @@ end
|
|||
|
||||
-- remove player from player list effected by rain.
|
||||
-- be sure to remove sound before removing player otherwise soundhandler reference will be lost.
|
||||
mcl_weather.rain.remove_player = function(player)
|
||||
function mcl_weather.rain.remove_player(player)
|
||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||
if player_meta ~= nil and player_meta.origin_sky ~= nil then
|
||||
player:set_clouds({color="#FFF0F0E5"})
|
||||
|
@ -119,7 +118,7 @@ end)
|
|||
-- adds and removes rain sound depending how much rain particles around player currently exist.
|
||||
-- have few seconds delay before each check to avoid on/off sound too often
|
||||
-- when player stay on 'edge' where sound should play and stop depending from random raindrop appearance.
|
||||
mcl_weather.rain.update_sound = function(player)
|
||||
function mcl_weather.rain.update_sound(player)
|
||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||
if player_meta ~= nil then
|
||||
if player_meta.sound_updated ~= nil and player_meta.sound_updated + 5 > minetest.get_gametime() then
|
||||
|
@ -140,7 +139,7 @@ mcl_weather.rain.update_sound = function(player)
|
|||
end
|
||||
|
||||
-- rain sound removed from player.
|
||||
mcl_weather.rain.remove_sound = function(player)
|
||||
function mcl_weather.rain.remove_sound(player)
|
||||
local player_meta = mcl_weather.players[player:get_player_name()]
|
||||
if player_meta ~= nil and player_meta.sound_handler ~= nil then
|
||||
minetest.sound_fade(player_meta.sound_handler, -0.5, 0.0)
|
||||
|
@ -150,7 +149,7 @@ mcl_weather.rain.remove_sound = function(player)
|
|||
end
|
||||
|
||||
-- callback function for removing rain
|
||||
mcl_weather.rain.clear = function()
|
||||
function mcl_weather.rain.clear()
|
||||
mcl_weather.rain.raining = false
|
||||
mcl_weather.rain.sky_last_update = -1
|
||||
mcl_weather.rain.init_done = false
|
||||
|
@ -166,11 +165,10 @@ minetest.register_globalstep(function(dtime)
|
|||
if mcl_weather.state ~= "rain" then
|
||||
return false
|
||||
end
|
||||
|
||||
mcl_weather.rain.make_weather()
|
||||
end)
|
||||
|
||||
mcl_weather.rain.make_weather = function()
|
||||
function mcl_weather.rain.make_weather()
|
||||
if mcl_weather.rain.init_done == false then
|
||||
mcl_weather.rain.raining = true
|
||||
mcl_weather.rain.set_sky_box()
|
||||
|
@ -190,7 +188,7 @@ mcl_weather.rain.make_weather = function()
|
|||
end
|
||||
|
||||
-- Switch the number of raindrops: "thunder" for many raindrops, otherwise for normal raindrops
|
||||
mcl_weather.rain.set_particles_mode = function(mode)
|
||||
function mcl_weather.rain.set_particles_mode(mode)
|
||||
if mode == "thunder" then
|
||||
mcl_weather.rain.particles_count = PARTICLES_COUNT_THUNDER
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user