Jump to content

Recommended Posts

This is all I was able to find for the miner's hat:

 

 if name == "miner" then
        table.insert(assets, Asset("ANIM", "anim/hat_miner_off.zip"))
    end
__________________________________________________________________________________________
 
local function miner_turnon(inst)
        local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
        if inst.components.fueled:IsEmpty() then
            if owner then
                onequip(inst, owner, "hat_miner_off")
            end
        else
            if owner then
                onequip(inst, owner)
            end
 
            inst.components.fueled:StartConsuming()
            inst.SoundEmitter:PlaySound("dontstarve/common/minerhatAddFuel")
            inst.Light:Enable(true)
        end
    end
 
    local function miner_turnoff(inst, ranout)
        if inst.components.equippable and inst.components.equippable:IsEquipped() then
            local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
            if owner then
                onequip(inst, owner, "hat_miner_off")
            end
        end
        inst.components.fueled:StopConsuming()
        inst.SoundEmitter:PlaySound("dontstarve/common/minerhatOut")
 
        inst.Light:Enable(false)
    end
 
    local function miner_equip(inst, owner)
        miner_turnon(inst)
    end
    local function miner_unequip(inst, owner)
        onunequip(inst, owner)
        miner_turnoff(inst)
    end
    local function miner_perish(inst)
        local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
        if owner then
            owner:PushEvent("torchranout", {torch = inst})
        end
        miner_turnoff(inst)
    end
    local function miner_drop(inst)
        miner_turnoff(inst)
    end
    local function miner_takefuel(inst)
        if inst.components.equippable and inst.components.equippable:IsEquipped() then
            miner_turnon(inst)
        end
    end
 
    local function miner()
        local inst = simple()
 
        inst.entity:AddSoundEmitter()        
 
        local light = inst.entity:AddLight()
        light:SetFalloff(0.4)
        light:SetIntensity(.7)
        light:SetRadius(2.5)
        light:SetColour(180/255, 195/255, 150/255)
        light:Enable(false)
 
        inst.components.inventoryitem:SetOnDroppedFn( miner_drop )
        inst.components.equippable:SetOnEquip( miner_equip )
        inst.components.equippable:SetOnUnequip( miner_unequip )
 
        inst:AddComponent("fueled")
        inst.components.fueled.fueltype = "CAVE"
        inst.components.fueled:InitializeFuelLevel(TUNING.MINERHAT_LIGHTTIME)
        inst.components.fueled:SetDepletedFn(miner_perish)
        inst.components.fueled.ontakefuelfn = miner_takefuel
        inst.components.fueled.accepting = true
        return inst
    end

__________________________________________________________________________________________

 

elseif name == "miner" then
        fn = miner
__________________________________________________________________________________________
 
MakeHat("miner"),
__________________________________________________________________________________________
 
I think the parts in red are the important parts about how the light of the hat works. Since I don't code, I can't really be sure... but yeah.

Ok, I wrote a big long post and then the forum logged me out for some reason, which it's been doing lately and I'd LOVE to know why the forum has been acting so weird. But anyway.. I'm not up for writing my whole post again, so I'm sorry if this seems a bit short.

 

Yea, the miner hat is just an omnidirectional light like seronis said. The cone I'm seeing is probably just part of the hat's animation and not an actual light. So here's another idea. Do you have the Screecher mod on Mac? I assume you do. The flashlight in that mod is NOT omnidirectional. Go look at the flashlight_particles.lua file and you may learn something about the light effect you're going for.

 

With the "dusk" thing, dusk will still be there in the game for things you need to do during dusk. You could just give your camera 2 settings(day/night) for now and add in the "dusk" setting later when you get other things figured out.

 

As to the file indexing, I didn't mean just that you could see the files, but that if you index their contents... well let's say you find a function call for DoThisThing or DoThatOtherThing, and you want to find the file where that function is defined and see what it does exactly. If you've indexed the contents and not just the filenames, the search will help you find which file you need to look at. But you'll have to find out how Mac indexes files.

 

I think this mod is very doable, but it'll take some work. If you're up for it, I think it really is an amazing idea.

Edited by zeropoint101

If you want the effect to happen in a cone, you should make 4-6 circles of increasing radius appear one in front of the other.  That should pretty much fake a cone.

 

Honest question here, not trying to be argumentative. But why would that work better than to just work off of the flashlight_particles.lua I described above? With your suggestion, wouldn't you have to create an object for each light source and also connect it perfectly to the characters' movement? That seems like it would be really difficult to impossible...

That's what flashlight.lua does.  It creates 5 instances of flashlight_particles.lua and arranges them in front of the player.  I do, however, see the error in this.  In the Screecher mod, the player always faces forwards so there is no need to worry about the character changing directions.  I don't know how to accomplish this with a player that turns...  It would be very difficult, but I'm sure it would be possible somehow.

That's what flashlight.lua does.  It creates 5 instances of flashlight_particles.lua and arranges them in front of the player.  I do, however, see the error in this.  In the Screecher mod, the player always faces forwards so there is no need to worry about the character changing directions.  I don't know how to accomplish this with a player that turns...  It would be very difficult, but I'm sure it would be possible somehow.

 

Oh. That's bad.

Is it possible to turn effects?

That's what flashlight.lua does.  It creates 5 instances of flashlight_particles.lua and arranges them in front of the player.  I do, however, see the error in this.  In the Screecher mod, the player always faces forwards so there is no need to worry about the character changing directions.  I don't know how to accomplish this with a player that turns...  It would be very difficult, but I'm sure it would be possible somehow.

 

Very interesting. Well, glad I asked. I tried figuring out what was going on in the flashlight particles lua, but had no idea. I'm still stuck on some simpler stuff.

Oh. That's bad.

Is it possible to turn effects?

 

Hopefully someone else will come back with a better answer, but the particles file is just another prefab. The player does turn, but the camera turns with him. I would just try something similar to the particles file, and see how it looks with the camera setup in the normal Don't Starve position. Then tinker with it from there.

I'm not sure what you guys are talking about, flashlight_particles is totally unused; all the lines that use it are commented out. The screecher flashlight creates multiple flashlight_lightpiece prefabs (very simple prefabs with just a Light) and adds them all to the flashlight's 'lightbeam' component. The lightbeam component updates every frame and does the following: it gets the player's position and facing direction and then positions its flashlight_lightpiece prefabs accordingly.

You could pretty much use the lightbeam component directly as is (but you'd probably want to remove the transition-related stuff that deals with searching containers and whatnot). Check out mods/screecher/scripts/components/lightbeam.lua.

Edited by squeek

I'm not sure what you guys are talking about, flashlight_particles is totally unused; all the lines that use it are commented out. The screecher flashlight creates multiple flashlight_lightpiece prefabs (very simple prefabs with just a Light) and adds them all to the flashlight's 'lightbeam' component. The lightbeam component updates every frame and does the following: it gets the player's position and facing direction and then positions its flashlight_lightpiece prefabs accordingly.

You could pretty much use the lightbeam component directly as is (but you'd probably want to remove the transition-related stuff that deals with searching containers and whatnot). Check out mods/screecher/scripts/components/lightbeam.lua.

 

My bad. I'm trying to comment on something way above my skill level. I guess I should have said there's probably something to do with the flashlight he could use, but I don't know any more than that.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...