Recommended Posts

FurryEskimo    39

I've been working on editing the player's starting inventory and have been finding some unusual properties.

TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.CHARACTER_PREFAB_NAME = {
	"ITEM_PREFAB_NAME",
}
for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do
	start_inv[string.lower(k)] = v.FURRYESKIMO
	print("TESTING TABLE 2")
	print(start_inv[string.lower(k)])
end
local prefabs = FlattenTree(start_inv, true)
--Sets starting inventory.
inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default
print("start_inv 2: ", start_inv.default)  --Test code
[00:00:09]: TESTING TABLE 2	
[00:00:09]: table: 0F03FFD8	
[00:00:09]: TESTING TABLE 2	
[00:00:09]: nil	
[00:00:09]: TESTING TABLE 2	
[00:00:09]: nil	

[00:00:45]: start_inv 2: 	table: 0F03FFD8	

I've tested my own tables and can extract data, but the default code seems to reference a table ID that's generated each time the game runs, not the actual data in the table.  It also seems like the default inventory table can store more data but is compressed?

I have partially overcome this issue and can now store data in a table and then reference the seemingly random table ID.

local people = {  --Test code.
	{
		test = "nightmarefuel",
	},
}
	for k, v in pairs(people ) do  --Test code.
		print("NEW INVENTORY TEST")
		print(k, v)
	--	inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or (k, v)  --Error:  ')' expected near ','
		inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or people.test
	end

This appears to almost work, giving the player a different inventory on spawn than what was shown to them.  Trouble is, the player currently spawns with no items, even though I've listed an item in the table.  Does anyone know what I've missed?  I suspect it's at the very end, "people.test" is somehow wrong, but I don't how how to replace it with the "(k, v)" that references the table's random ID.

Edited by FurryEskimo

Share this post


Link to post
Share on other sites
IronHunter    569

Dude you are making this way more complicated than it has to be lols...
the start_inv table is just a table containing the subtables default, and maybe lavaarena/quaqmire all lowercase, these tables contain a simple ordered list of strings.
 

start_inv = {
  	default = {
      "nightmarefuel",
      "papyrus",
      "flint",
    },
}

This is the results you would get if you had

TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.YOUR_CHARACTER_NAME = {
	"nightmarefuel",
	"papyrus",
	"flint",
}
local start_inv = {}
for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do
    start_inv[string.lower(k)] = v.YOUR_CHARACTER_NAME
end

as you can see you need to make sure your start_inv has a subtable default because you are calling for that from:
 

    inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default

in the masterpostinit

 

if you want to break the template your people.test most likely needs to return a table rather than a string.

  • Like 2

Share this post


Link to post
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