Ok so, what I'd like to do in my game is have ores/trees around the map that can be found. When mined/chopped, you get some XP and 1 of said ore/log added to your inventory, which is on the server in a datastore. You can use these ores on your weapon to customize the look of it. I'm struggling with adding the inventory. I know how data stores work. My problem is actually implementing the Objects. So if I wanted to randomize the chance of an ore spawning, I'd grab a table with all the ore names, so x = ["Ruby_Ore", "Sapphire_Ore", etc], how would I tell all the scripts that might need to use the ores system, that "Ruby_Ore" means Ruby? Sorry if my question is confusing because this is my first time asking for help with something, and I don't have many ideas on how I'd approach this problem. Thanks for any help.
You can use global tables. Example: Set the global
local Ores = {Ruby = "Ruby_Ore",Sapphire = "Sapphire_Ore"} -- etc _G.Ores = Ores
From other script
-- example for i,v in pairs(_G.Ores) do -- i for index -- v for value -- in this case i would be Ruby Or Sapphire, the names -- and v would be Ruby_Ore or Sapphire_Ore wich are the values set to them print(""..i.." equals to "..v.."!") end
Happy scripting!