]> git.lizzy.rs Git - crafter_client.git/blobdiff - aether.lua
Update README.md
[crafter_client.git] / aether.lua
index 8bdd8c3ee23828cac1959183ae816e1157703738..bac87674047bb31350f2c39b507595fe4aa9dfb3 100644 (file)
@@ -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
@@ -39,14 +42,14 @@ minetest.register_globalstep(function(dtime)
                        
                elseif opacity < 255 then
                        --make the hud fade in
-                       opacity = opacity + 1.5
+                       opacity = opacity + (dtime*100)
                        
-                       minetest.localplayer:hud_change(hud_bg_id, "text", "aether_portal_gui.png^[opacity:"..opacity)                  
+                       minetest.localplayer:hud_change(hud_bg_id, "text", "aether_portal_gui.png^[opacity:"..opacity)
                end
        elseif hud_bg_id then
                --play heavenly sounds
                
-               if init_sound then
+               if init_sound and node and node.name == "aether:portal" then
                        minetest.sound_fade(init_sound, -0.4, 0)
                        init_sound = nil
                        teleport_sound = minetest.sound_play("aether_teleport_complete",{gain=1})
@@ -56,9 +59,14 @@ minetest.register_globalstep(function(dtime)
                
                --player left portal before teleporting
                if aether_cool_off_timer == 0 then
-                       opacity = opacity  - 1.5                        
+                       opacity = opacity  - (dtime*100)                        
                        minetest.localplayer:hud_change(hud_bg_id, "text", "aether_portal_gui.png^[opacity:"..opacity)
                        
+                       if init_sound then
+                               minetest.sound_fade(init_sound, -0.4, 0)
+                               init_sound = nil
+                       end
+                       
                        if opacity <= 0 then
                                minetest.localplayer:hud_remove(hud_bg_id)
                                hud_bg_id = nil
@@ -67,7 +75,7 @@ minetest.register_globalstep(function(dtime)
                --teleport complete animation
                elseif aether_cool_off_timer > 0 then
                
-                       opacity = opacity  - 1.5                        
+                       opacity = opacity  - (dtime*100)                        
                        minetest.localplayer:hud_change(hud_bg_id, "text", "aether_portal_gui.png^[opacity:"..opacity)
                        
                        if opacity <= 0 then
@@ -86,7 +94,7 @@ minetest.register_globalstep(function(dtime)
        
        --initialize teleport command to server
        if hud_bg_id and aether_cool_off_timer == 0 then
-               if opacity == 255 then
+               if opacity >= 255 then
                        aether:send_all("teleport me")
                        --can't use any portal for 7 seconds
                        aether_cool_off_timer = 7  --if you read this, you'll notice the nether cool off timer is 6 and this is 7 ;)