Jump to content

Need help with code.


Recommended Posts

Hello, I'm making a personal mod that tweaks a bunch of stuff that I want to change.

I am in need of help from someone to tell me how I can change lets say... Warg's loot drop, how do I make that?

I also need help tweaking Wickerbottom's book durability so all her books have 10 uses.

Thank you.

Link to comment
Share on other sites

14 hours ago, mathem99 said:

Warg's loot drop, how do I make that?

AddSimPostInit(function()
	-- Access to the old loot table
	local old_warg_loot = GLOBAL.LootTables["warg"]
	-- Adding new loot
	table.insert(old_warg_loot, {"goldnugget", 1.00})
	-- Removing loot (the first table value)
	table.remove(old_warg_loot, 1)

	-- OR

	-- Replacing the table entirely
	local new_warg_loot = {
		{"monstermeat", 1.00},
		{"goldnugget", 1.00},
		{"houndstooth", 0.66},
	}
	GLOBAL.SetSharedLootTable("warg", new_warg_loot)
end)

 

14 hours ago, mathem99 said:

Wickerbottom's book durability so all her books have 10 uses

local function MakeTenUses(inst)
	if inst.components.finiteuses then
		inst.components.finiteuses:SetMaxUses(10)
		inst.components.finiteuses:SetUses(10)
	end
end

AddPrefabPostInit("book_tentacles", MakeTenUses)
AddPrefabPostInit("book_birds", MakeTenUses)
AddPrefabPostInit("book_brimstone", MakeTenUses)
AddPrefabPostInit("book_sleep", MakeTenUses)
AddPrefabPostInit("book_gardening", MakeTenUses)

 

Link to comment
Share on other sites

6 hours ago, DarkXero said:

AddSimPostInit(function()
	-- Access to the old loot table
	local old_warg_loot = GLOBAL.LootTables["warg"]
	-- Adding new loot
	table.insert(old_warg_loot, {"goldnugget", 1.00})
	-- Removing loot (the first table value)
	table.remove(old_warg_loot, 1)

	-- OR

	-- Replacing the table entirely
	local new_warg_loot = {
		{"monstermeat", 1.00},
		{"goldnugget", 1.00},
		{"houndstooth", 0.66},
	}
	GLOBAL.SetSharedLootTable("warg", new_warg_loot)
end)

 


local function MakeTenUses(inst)
	if inst.components.finiteuses then
		inst.components.finiteuses:SetMaxUses(10)
		inst.components.finiteuses:SetUses(10)
	end
end

AddPrefabPostInit("book_tentacles", MakeTenUses)
AddPrefabPostInit("book_birds", MakeTenUses)
AddPrefabPostInit("book_brimstone", MakeTenUses)
AddPrefabPostInit("book_sleep", MakeTenUses)
AddPrefabPostInit("book_gardening", MakeTenUses)

 

Much obliged.

Link to comment
Share on other sites

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
 Share

×
  • Create New...