Download (34 KB)

How do I install this?

This is awful (probably).

The flashlight mod with brightness linearly decreasing with distance and ray casting. Textures: made by me. Sounds: also by me. Some of the code: by the illumination mod, but heavily changed. Some more of the code: by ApolloX (thank you once again).

Reviews

Review

Do you recommend this mod?

  • Great mod, and a code suggestion

    First off, I like that it reduces brightness the further away it goes (like real life!)

    Second, I'd like to see it gain the ability to toggle the flashlight on/off by right click too!

    -- Line 141 to line 165 Rewritten
    -- A: Make the function that swiches back and forth into a local function
    local function flashlight_toggle(stack)
            if stack:get_name() == "goodtorch:flashlight_off" then
                    minetest.sound_play("goodtorch_on")
                    stack:set_name("goodtorch:flashlight_on")
            else
                    minetest.sound_play("goodtorch_off")
                    stack:set_name("goodtorch:flashlight_off")
            end
            return stack
    end
    
    -- B: Update the register functions to use on_use (left click/punch) and on_secondary_use (right click/place)
    minetest.register_craftitem("goodtorch:flashlight_off", {
            description = "Flashlight (off)",
            inventory_image = "goodtorch_flashlight_off.png",
            on_use = flashlight_toggle,
            on_secondary_use = flashlight_toggle,
            groups = {
                    flash_light = 1,
            },
    })
    
    minetest.register_craftitem("goodtorch:flashlight_on", {
            description = "Flashlight (on)",
            inventory_image = "goodtorch_flashlight_on.png",
            on_use = flashlight_toggle,
            on_secondary_use = flashlight_toggle,
            groups = {
                    flash_light = 1,
            },
    })
    
    -- C: Profit! :)
    
    12 comments
  • altogether great mod!

    i have used tis mod countless times,adds a whole new layer to dark horror games, (very creepy), surprisingly smooth node transition, nice texture, and has the most satisfying on/off sound ever. i was thinking of using it in a game i have been working on, would that be alright? also i had no idea you made this mod, great job man. thumbs up from me!

    3 comments

Used By