From c654c9fd1197b91bab0c91432f5149223987eaad Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Sun, 7 Dec 2014 15:17:09 +0100 Subject: [PATCH] Remove weird constants in default --- game_api.txt | 7 ++++++- mods/default/init.lua | 15 +++++++++------ mods/default/nodes.lua | 18 +++++++++--------- mods/farming/API.txt | 2 +- mods/farming/init.lua | 4 ++-- mods/tnt/init.lua | 2 +- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/game_api.txt b/game_api.txt index 8123c010..6ce69f09 100644 --- a/game_api.txt +++ b/game_api.txt @@ -83,7 +83,7 @@ farming.register_plant(name, Plant definition) steps = 8, -- How many steps the plant has to grow, until it can be harvested ^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber) minlight = 13, -- Minimum light to grow - maxlight = LIGHT_MAX -- Maximum light to grow + maxlight = default.LIGHT_MAX -- Maximum light to grow } Stairs API @@ -148,6 +148,11 @@ default.node_sound_wood_defaults() default.node_sound_leaves_defaults() default.node_sound_glass_defaults() +Default constants +----------------- +default.LIGHT_MAX +^ The maximum light level (see [Node definition] light_source) + Player API ---------- The player API can register player models and update the player's appearence diff --git a/mods/default/init.lua b/mods/default/init.lua index 276af543..663a3ae1 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -1,16 +1,13 @@ -- Minetest 0.4 mod: default -- See README.txt for licensing and other information. --- The API documentation in here was moved into doc/lua_api.txt - -WATER_ALPHA = 160 -WATER_VISC = 1 -LAVA_VISC = 7 -LIGHT_MAX = 14 +-- The API documentation in here was moved into game_api.txt -- Definitions made by this mod that other mods can use too default = {} +default.LIGHT_MAX = 14 + -- GUI related stuff default.gui_bg = "bgcolor[#080808BB;true]" default.gui_bg_img = "background[5,5;1,1;gui_formbg.png;true]" @@ -46,3 +43,9 @@ dofile(minetest.get_modpath("default").."/mapgen.lua") dofile(minetest.get_modpath("default").."/player.lua") dofile(minetest.get_modpath("default").."/trees.lua") dofile(minetest.get_modpath("default").."/aliases.lua") + +-- Legacy: +WATER_ALPHA = minetest.registered_nodes["default:water_source"].alpha +WATER_VISC = minetest.registered_nodes["default:water_source"].liquid_viscosity +LAVA_VISC = minetest.registered_nodes["default:lava_source"].liquid_viscosity +LIGHT_MAX = default.LIGHT_MAX diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index 90b6dbd7..fcc34bbf 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -547,7 +547,7 @@ minetest.register_node("default:water_flowing", { animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=0.8} }, }, - alpha = WATER_ALPHA, + alpha = 160, paramtype = "light", paramtype2 = "flowingliquid", walkable = false, @@ -559,7 +559,7 @@ minetest.register_node("default:water_flowing", { liquidtype = "flowing", liquid_alternative_flowing = "default:water_flowing", liquid_alternative_source = "default:water_source", - liquid_viscosity = WATER_VISC, + liquid_viscosity = 1, post_effect_color = {a=64, r=100, g=100, b=200}, groups = {water=3, liquid=3, puts_out_fire=1, not_in_creative_inventory=1}, }) @@ -579,7 +579,7 @@ minetest.register_node("default:water_source", { backface_culling = false, } }, - alpha = WATER_ALPHA, + alpha = 160, paramtype = "light", walkable = false, pointable = false, @@ -590,7 +590,7 @@ minetest.register_node("default:water_source", { liquidtype = "source", liquid_alternative_flowing = "default:water_flowing", liquid_alternative_source = "default:water_source", - liquid_viscosity = WATER_VISC, + liquid_viscosity = 1, post_effect_color = {a=64, r=100, g=100, b=200}, groups = {water=3, liquid=3, puts_out_fire=1}, }) @@ -614,7 +614,7 @@ minetest.register_node("default:lava_flowing", { }, paramtype = "light", paramtype2 = "flowingliquid", - light_source = LIGHT_MAX - 1, + light_source = default.LIGHT_MAX - 1, walkable = false, pointable = false, diggable = false, @@ -624,7 +624,7 @@ minetest.register_node("default:lava_flowing", { liquidtype = "flowing", liquid_alternative_flowing = "default:lava_flowing", liquid_alternative_source = "default:lava_source", - liquid_viscosity = LAVA_VISC, + liquid_viscosity = 7, liquid_renewable = false, damage_per_second = 4*2, post_effect_color = {a=192, r=255, g=64, b=0}, @@ -647,7 +647,7 @@ minetest.register_node("default:lava_source", { } }, paramtype = "light", - light_source = LIGHT_MAX - 1, + light_source = default.LIGHT_MAX - 1, walkable = false, pointable = false, diggable = false, @@ -657,7 +657,7 @@ minetest.register_node("default:lava_source", { liquidtype = "source", liquid_alternative_flowing = "default:lava_flowing", liquid_alternative_source = "default:lava_source", - liquid_viscosity = LAVA_VISC, + liquid_viscosity = 7, liquid_renewable = false, damage_per_second = 4*2, post_effect_color = {a=192, r=255, g=64, b=0}, @@ -680,7 +680,7 @@ minetest.register_node("default:torch", { sunlight_propagates = true, is_ground_content = false, walkable = false, - light_source = LIGHT_MAX-1, + light_source = default.LIGHT_MAX - 1, selection_box = { type = "wallmounted", wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, diff --git a/mods/farming/API.txt b/mods/farming/API.txt index a2f3d9d6..9234bc44 100644 --- a/mods/farming/API.txt +++ b/mods/farming/API.txt @@ -23,5 +23,5 @@ Plant definition steps = 8, -- How many steps the plant has to grow, until it can be harvested ^ Always provide a plant texture for ech step, format: modname_plantname_i.png (i = stepnumber) minlight = 13, -- Minimum light to grow - maxlight = LIGHT_MAX -- Maximum light to grow + maxlight = default.LIGHT_MAX -- Maximum light to grow } \ No newline at end of file diff --git a/mods/farming/init.lua b/mods/farming/init.lua index 9245470f..d3157a07 100644 --- a/mods/farming/init.lua +++ b/mods/farming/init.lua @@ -13,7 +13,7 @@ farming.register_plant("farming:wheat", { inventory_image = "farming_wheat_seed.png", steps = 8, minlight = 13, - maxlight = LIGHT_MAX, + maxlight = default.LIGHT_MAX, fertility = {"grassland"} }) minetest.register_craftitem("farming:flour", { @@ -46,7 +46,7 @@ farming.register_plant("farming:cotton", { inventory_image = "farming_cotton_seed.png", steps = 8, minlight = 13, - maxlight = LIGHT_MAX, + maxlight = default.LIGHT_MAX, fertility = {"grassland", "desert"} }) diff --git a/mods/tnt/init.lua b/mods/tnt/init.lua index a2e5adaa..fda4ec39 100644 --- a/mods/tnt/init.lua +++ b/mods/tnt/init.lua @@ -255,7 +255,7 @@ minetest.register_node("tnt:tnt_burning", { minetest.register_node("tnt:boom", { drawtype = "plantlike", tiles = {"tnt_boom.png"}, - light_source = LIGHT_MAX, + light_source = default.LIGHT_MAX, walkable = false, drop = "", groups = {dig_immediate=3},