From ef702f099b13d3a86f18ad15d68642639b991656 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Thu, 11 Jun 2020 10:49:23 -0400 Subject: [PATCH] Improve fps --- aether.lua | 3 +++ environment_effects.lua | 2 ++ fire_handling.lua | 3 +++ init.lua | 35 +++++++++++++++-------------------- music_handling.lua | 2 ++ nether.lua | 3 +++ player_input.lua | 2 ++ version_send.lua | 2 ++ waila.lua | 2 +- weather_handling.lua | 6 ++++++ 10 files changed, 39 insertions(+), 21 deletions(-) diff --git a/aether.lua b/aether.lua index 88d4d98..bac8767 100644 --- a/aether.lua +++ b/aether.lua @@ -1,3 +1,6 @@ +local minetest,name = minetest,minetest.localplayer:get_name() +local aether = minetest.mod_channel_join(name..":aether_teleporters") + --nether teleporters are animation based --the animation must finish before the teleport is initialized local hud_bg_id = nil --aether portal bg diff --git a/environment_effects.lua b/environment_effects.lua index 8b2b6e2..a71a3e4 100644 --- a/environment_effects.lua +++ b/environment_effects.lua @@ -1,3 +1,5 @@ +local minetest,math = minetest,math + local old_node local in_water = false local old_in_water = false diff --git a/fire_handling.lua b/fire_handling.lua index c47e0e2..a4658de 100644 --- a/fire_handling.lua +++ b/fire_handling.lua @@ -1,3 +1,6 @@ +local minetest,name = minetest,minetest.localplayer:get_name() +local fire_handling_channel = minetest.mod_channel_join(name..":fire_state") + local on_fire = 0 local fire_id = nil local fire_animation_timer = 0 diff --git a/init.lua b/init.lua index c9b9da0..5d645fb 100644 --- a/init.lua +++ b/init.lua @@ -8,27 +8,8 @@ if not minetest.get_node_def("client_version_checker:this_is_the_signature_of_cr return end ---declare globals -weather_intake = nil -weather = nil -weather_type = nil -player_movement_state = nil -nether = nil -aether = nil -name = nil -version_channel = nil -fire_handling_channel = nil - function initialize_all() --declare globals for now - weather_intake = minetest.mod_channel_join("weather_intake") - weather = minetest.mod_channel_join("weather_nodes") - weather_type = minetest.mod_channel_join("weather_type") - player_movement_state = minetest.mod_channel_join(name..":player_movement_state") - nether = minetest.mod_channel_join(name..":nether_teleporters") - aether = minetest.mod_channel_join(name..":aether_teleporters") - version_channel = minetest.mod_channel_join(name..":client_version_channel") - fire_handling_channel = minetest.mod_channel_join(name..":fire_state") --next we load everything seperately because it's easier to work on individual files than have everything jammed into one file --not into seperate mods because that is unnecessary and cumbersome @@ -49,7 +30,6 @@ end local function recursive_startup_attempt() local ready_to_go = minetest.localplayer if ready_to_go and minetest.get_node_or_nil(minetest.localplayer:get_pos()) then - name = minetest.localplayer:get_name() --good to begin initialize_all() else @@ -62,3 +42,18 @@ end --begin initial attempt recursive_startup_attempt() + +--leave mod channels on shutdown +--[[ +minetest.register_on_shutdown(function() + weather_intake = nil + weather = nil + weather_type = nil + player_movement_state = nil + nether = nil + aether = nil + name = nil + version_channel = nil + fire_handling_channel = nil +end) +]]-- \ No newline at end of file diff --git a/music_handling.lua b/music_handling.lua index a8291cc..7915d14 100644 --- a/music_handling.lua +++ b/music_handling.lua @@ -1,3 +1,5 @@ +local minetest,math = minetest,math + song_playing = nil local song_tick = 0 song_index = nil diff --git a/nether.lua b/nether.lua index 9d06fdd..4810345 100644 --- a/nether.lua +++ b/nether.lua @@ -1,3 +1,6 @@ +local minetest,math,name = minetest,math,minetest.localplayer:get_name() +local nether = minetest.mod_channel_join(name..":nether_teleporters") + --nether teleporters are animation based --the animation must finish before the teleport is initialized local hud_bg_id = nil --aether portal bg diff --git a/player_input.lua b/player_input.lua index 4d8b1e4..d3e9e63 100644 --- a/player_input.lua +++ b/player_input.lua @@ -1,3 +1,5 @@ +local minetest,name = minetest,minetest.localplayer:get_name() +local player_movement_state = minetest.mod_channel_join(name..":player_movement_state") --double tap running --set up our initial values diff --git a/version_send.lua b/version_send.lua index b2e3844..2d28693 100644 --- a/version_send.lua +++ b/version_send.lua @@ -1,3 +1,5 @@ +local minetest,name = minetest,minetest.localplayer:get_name() +local version_channel = minetest.mod_channel_join(name..":client_version_channel") minetest.after(2,function() -- this needs a few seconds for the mod channel to open up version_channel:send_all("0.05008") end) \ No newline at end of file diff --git a/waila.lua b/waila.lua index 6059484..bd8056d 100644 --- a/waila.lua +++ b/waila.lua @@ -1,6 +1,6 @@ +local minetest,vector = minetest,vector local hud_item_name = "" - local hud_bg = minetest.localplayer:hud_add({ hud_elem_type = "image", -- see HUD element types, default "text" position = {x=0.5, y=0}, diff --git a/weather_handling.lua b/weather_handling.lua index f4ad3e2..4fcebac 100644 --- a/weather_handling.lua +++ b/weather_handling.lua @@ -1,3 +1,9 @@ +local minetest,name,vector,math = minetest,minetest.localplayer:get_name(),vector,math + +local weather_intake = minetest.mod_channel_join("weather_intake") +local weather = minetest.mod_channel_join("weather_nodes") +local weather_type = minetest.mod_channel_join("weather_type") + local all_nodes = {} local do_effects = false local snow = false -- 2.44.0