Jump to content

{Character perks} mining gems


Recommended Posts

Hello,

I've been looking for a code to make a character's perk where they are able to have a very small chance of dropping gems from any types of boulders.

if any one can help me with this code, it'll be very appreciated :) !!

Link to comment
Share on other sites

This is pretty simple~

Head to your modmain.lua and in there add this:

    AddPrefabPostInit("BolderNameHere", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.lootdropper:AddChanceLoot("redgem", 1.00)
        end
    end)

Simply place the prefab name of the bolder that you want to add your additional drops to, the name of your character, and here is how the lootdroper line works:

You can copy-paste it as many times as you want (to add more additional drops). You can of course change the "redgem" to any other gem that you wish to drop, and the number at the end "1.00" shows the drop chance percentage. 1.00 = 100% drop change, 0.50 = 50% drop change, 0.25 = 25% drop chance, and so on...
 

Example:
    AddPrefabPostInit("rock1", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.lootdropper:AddChanceLoot("redgem", 1.00)
            inst.components.lootdropper:AddChanceLoot("buegem", 0.30)
            inst.components.lootdropper:AddChanceLoot("greengem", 0.10)

        end
    end)

You will need however, to do this for all the boulders that you wish to add additional drops too.

I hope that helps.
Good luck!

Link to comment
Share on other sites

12 hours ago, BraveChicken said:

This is pretty simple~

Head to your modmain.lua and in there add this:

    AddPrefabPostInit("BolderNameHere", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.lootdropper:AddChanceLoot("redgem", 1.00)
        end
    end)

Simply place the prefab name of the bolder that you want to add your additional drops to, the name of your character, and here is how the lootdroper line works:

You can copy-paste it as many times as you want (to add more additional drops). You can of course change the "redgem" to any other gem that you wish to drop, and the number at the end "1.00" shows the drop chance percentage. 1.00 = 100% drop change, 0.50 = 50% drop change, 0.25 = 25% drop chance, and so on...
 

Example:
    AddPrefabPostInit("rock1", function(inst)
        if GetPlayer().prefab == "YourCharacterHere" then
            inst.components.lootdropper:AddChanceLoot("redgem", 1.00)
            inst.components.lootdropper:AddChanceLoot("buegem", 0.30)
            inst.components.lootdropper:AddChanceLoot("greengem", 0.10)

        end
    end)

You will need however, to do this for all the boulders that you wish to add additional drops too.

I hope that helps.
Good luck!

Hi @BraveChicken, thanks for your help, however iv'e inserted the code and I got an error, is there something I have done wrong?
I have added these to the modmain.lua file as followed.

404 error.png

Link to comment
Share on other sites

3 hours ago, Bunnyash said:

iv'e inserted the code and I got an error, is there something I have done wrong?

Oh right! I forgot!
Try adding this line somewhere at the very top of your modmain.lua

    GetPlayer = GLOBAL.GetPlayer

And let me know if that helped.
This line is needed so your mod would know what to do with the "GetPlayer()".
I'm kinda used to having most of the basic lines already added to my modmain.lua so I forgot to mention it.
Sorry about that. ^-^;

Link to comment
Share on other sites

2 hours ago, BraveChicken said:

Oh right! I forgot!
Try adding this line somewhere at the very top of your modmain.lua

    GetPlayer = GLOBAL.GetPlayer

And let me know if that helped.
This line is needed so your mod would know what to do with the "GetPlayer()".
I'm kinda used to having most of the basic lines already added to my modmain.lua so I forgot to mention it.
Sorry about that. ^-^;

Hi @BraveChicken! It's fine, I really appreciate the help :)
I've put the code at the very top on the modmain.lua and I still get an error.

404 error.png

Link to comment
Share on other sites

26 minutes ago, Bunnyash said:

I've put the code at the very top on the modmain.lua and I still get an error.

Hmmm, that's weird. I've tested it and it seems to work fine for me.  o.o
May I ask: Is the mod which you're attempting to make a DST mod or is it for DS/RoG/SW?
As the DST mods have differences in the way that they need to be scripted.
(I don't really know how to script for the DST mods, but if that's what you need then you can try asking for help in this forum section here. DST mods and tools I'm sure You'll find plenty of helpful people there :) )

Link to comment
Share on other sites

7 minutes ago, BraveChicken said:

Hmmm, that's weird. I've tested it and it seems to work fine for me.  o.o
May I ask: Is the mod which you're attempting to make a DST mod or is it for DS/RoG/SW?
As the DST mods have differences in the way that they need to be scripted.
(I don't really know how to script for the DST mods, but if that's what you need then you can try asking for help in this forum section here. DST mods and tools I'm sure You'll find plenty of helpful people there :) )

DST is what I'm using, yes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...