Jump to content

Recommended Posts

he gave up on it? you explained it pretty well from what i saw. i dont really understand tables very much, as i have yet to use one, but from what i read you gave him an exact answer with these right?

if not GetPlayer().components.inventory.starting_inventory then --make a table if there isn't one    GetPlayer().components.inventory.starting_inventory == {}endtable.insert(GetPlayer().components.inventory.starting_inventory,"flint") --add one flint

 

he gave up on it? you explained it pretty well from what i saw. i dont really understand tables very much, as i have yet to use one, but from what i read you gave him an exact answer with these right?

if not GetPlayer().components.inventory.starting_inventory then --make a table if there isn't one    GetPlayer().components.inventory.starting_inventory == {}endtable.insert(GetPlayer().components.inventory.starting_inventory,"flint") --add one flint

That was my last idea, literally adding things to the existing starting inventory. I don't know whether this code runs before the starting inventory is given though.

 

If you put this into modmain, make sure to use GLOBAL.GetPlayer() or declare local GetPlayer = GLOBAL.GetPlayer above!

While i was thinking about this, to me, it doesnt really matter whether it is spawned into a world when it is loaded, or if its in the inventory. you said it was character specific and im not sure where this is really handled. ill look into it and see what i can find. but it would be more aesthetic if it did spawn when the world is. i even took a bit of time to look at how creatures spawned, but i couldnt figure it out other than worldgen stuff. the code you have presented is usually what you write and what would require a bit more look, right?

 

edit: i looked into the consolecommands.lua and was thinking about how the c_give command worked. couldnt i use something simular to this to give the item on spawn. have it like check for spawn character or something? or just modify part of the DebugSpawn command?

Edited by WitchDoctEr16

While i was thinking about this, to me, it doesnt really matter whether it is spawned into a world when it is loaded, or if its in the inventory. you said it was character specific and im not sure where this is really handled. ill look into it and see what i can find. but it would be more aesthetic if it did spawn when the world is. i even took a bit of time to look at how creatures spawned, but i couldnt figure it out other than worldgen stuff. the code you have presented is usually what you write and what would require a bit more look, right?

 

edit: i looked into the consolecommands.lua and was thinking about how the c_give command worked. couldnt i use something simular to this to give the item on spawn. have it like check for spawn character or something? or just modify part of the DebugSpawn command?

 

You can give something to the player using the inventory component (I think it was something like GetPlayer().components.inventory:Give(SpawnPrefab(LOOT))) using SpawnPrefab(). You need to set position too, or else it's in the middle of the world.

 

Other than that, I have no clue what your goal or idea is, so that's really up to you. Sorry.

hmm. ive tried each of these and i get the game to load, but i cant seem to get it to work in any form. honestly, all i am doing is wanting an item to only be available to the player at spawn. so if it were to spawn like the adventure mode spawns a winter hat during one of the adventure chapters would be enough for this to satisfy it. if it spawns in the inventory, or on the ground, thats fine. but making a table didnt work for me, nor did trying to use the inventory component or the player spawn handle thing. sadly, ill probably just upload it without this if i dont find a solution :D thanks for the help though, i at least understand tables a bit more, but still needs work on. your information and help was great :D

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