Jump to content

Recommended Posts

Local variables, local table, anything local, really, be it inside a function or not. I might need to learn first how to make modmain read a different file within the mod and apply it to the game where necessary, but this is really bugging me and is a block of wall right in my face. I really need to know ways of editing information placed within local variables or local tables which are located in the original game, so that I can change the game with my mods the way I want it to be, otherwise I'm extremely limited. I've handled the most basic of things and learn some bit about taking global variables/tables and editing them as necessary from just the modmain, so I think I'm ready to move on a little bit. So, is there anyone who can help me get past this wall that is blocking me from, say, editing the loot tables of certain things (e.g. rock boulders, mini glaciers) or changing segment time and total amount of day segments, as all of those are assigned to local variables. Even if it means I have to take the original file, make a copy of it in my mod and edit it respectively, it's something I really need to be able to change.

They are called "local" for a reason. It's like "private" in Java, you're not meant to be able to edit them at all. You can, however, apply the custom version in the same manner as the original code does, and usually access the place the value in question is stored. e.g.:

Loot tables are either set as "shared loot tables" using a global function or set in the lootdropper component of the individual entity. As such, you can either set a new shared table, edit the existing shared table via LootTables as found in lootdropper.lua (probably), set a new individual one via inst.components.lootdropper:SetLoot({}) or edit the individual one via inst.components.lootdropper.loot

Okay, this just confused me... so, I'm trying to achieve two things here and with what you've described, I can't put my finger on how to do this:

* Change ice loot amount for mini glaciers (so, change icecount variable, which is inside a local table called STAGES inside rock_ice.lua)

* Change rock loot amount, same as with mini glaciers, but for them to also loot rocks like glaciers; via stages (if you mine away one stage, you get some loot, but the rock still stays there and has just moved down a stage, unless you've mines down the last stage). The file where the rock (nitre boulder, gold boulder, flint-less boulder, moon rock boulder as well as petrified trees) loot and related data is located is rocks.lua

 

lootdropped.lua doesn't seem to have anything that would affect any of this from my understanding. I would also want to change marble related mineables (i.e. marble statues, marble pillars, marble trees, maxwell's statue and possibly others) and stalagmite loots, but if I get more info on the above two, I'm sure I can do it for the other two.

Edited by EuedeAdodooedoe

Lootshared tables that the prefab uses is usually found on the prefab file itself. You might try doing AddPrefabPostInits into your modmain.lua to "replace" the loot table or the table that determines the amount of loot.

You could also use it to add functions to the Rock prefab to make it work like mini glaciers. 

But here is an example of what to try to do to edit loot drops for miniglacier:

	AddPrefabPostInit("rock_ice", function(inst)
	local STAGES = {
    {
        name = "empty",
        animation = "melted",
        showrock = false,
        work = -1,
    },
    {
        name = "short",
        animation = "low",
        showrock = true,
        work = TUNING.ICE_MINE,
        icecount = 2, --make this whatever you want.
    },
    {
        name = "medium",
        animation = "med",
        showrock = true,
        work = TUNING.ICE_MINE*0.67,
        icecount = 2,
    },
    {
        name = "tall",
        animation = "full",
        showrock = true,
        work = TUNING.ICE_MINE*0.67,
        icecount = 3, 
    },
}
	end
)
	
Edited by DarkKingBoo
8 hours ago, DarkKingBoo said:

Lootshared tables that the prefab uses is usually found on the prefab file itself. You might try doing AddPrefabPostInits into your modmain.lua to "replace" the loot table or the table that determines the amount of loot.

You could also use it to add functions to the Rock prefab to make it work like mini glaciers. 

But here is an example of what to try to do to edit loot drops for miniglacier:


	AddPrefabPostInit("rock_ice", function(inst)
	local STAGES = {
    {
        name = "empty",
        animation = "melted",
        showrock = false,
        work = -1,
    },
    {
        name = "short",
        animation = "low",
        showrock = true,
        work = TUNING.ICE_MINE,
        icecount = 2, --make this whatever you want.
    },
    {
        name = "medium",
        animation = "med",
        showrock = true,
        work = TUNING.ICE_MINE*0.67,
        icecount = 2,
    },
    {
        name = "tall",
        animation = "full",
        showrock = true,
        work = TUNING.ICE_MINE*0.67,
        icecount = 3, 
    },
}
	end
)
	

Did that, changed it in code (changed icecount to 30 for all of the ones that has icecount), but the mod didn't change any loot tables.

Also, weirdly enough, in TUNING, changing ICE_MINE from 3 to 10, instead of making it so that the ice gets mined 10, 10, 10 (total of 30 hits to fully mine), it's 7, 7, 10... what? Just a thing I noticed from some previous code I had placed in, which seems very strange.

Edited by EuedeAdodooedoe

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...