How would I print this module out?
Example: print(TheCatagory.." "..ItemName.." "..Order.." "..Desc)
Module:
return {
Plants = {{
ItemName = "Tall Plant",
Order = 2,
Desc = "Is that a tree or a plant!?"
}, {
ItemName = "Ivy",
Order = 1,
Desc = "What vigorous vining stems..."
}},
Walls = {{
ItemName = "Tall Wall",
Order = 3,
Desc = "Wall"
}, {
ItemName = "Short Wall",
Order = 4,
Desc = "Wall"
}},
Garden = {{
ItemName = "test1",
Order = 5,
Desc = "test2"
Hidden = true
}}
}
You would just link the request to the Module script function thing with a variable and then get the values out from the table.
A couple of ways to access the tables:
Table["TheCategory"]["ItemName"]
Table["TheCategory"]["Order"]
Table["TheCategory"]["Desc"]
or:
Table.TheCategory.ItemName
Table.TheCategory.Order
Table.TheCategory.Desc
etc.
… if this is what you meant.
I kinda meant like, it prints the Catagroy, the ItemName, Order, Desc.
Example: Plants Tall Plant 2 Is that a tree or a plant!?
When I try to print it I get,

local path = require(game.ReplicatedStorage.Module)
local Plants = path.Plants
print(Plants.ItemName, Plants.Order, Plants.Desc)
I would personally re-structure your table, as you don’t have any identifiers for the types of plants. I would change it to something like this:
return {
Plants = {
["Tall Plant"] = {
Order = 2,
Desc = "Is that a tree or a plant!?"
},
["Ivy"] = {
Order = 1,
Desc = "What vigorous vining stems..."
}
}
}
etc. This allows you to identify the plant data based off of its’ name.
The reason the previous print wasn’t working is because the Plants
table didn’t have any specific identifiers for each of the plant’s data.
1 Like
Here’s a fix for that script. This is a tables problem, not a modules problem. Plants.ItemName doesn’t exist in the table.
local path = require(game.ReplicatedStorage.Module)
local Plants = path.Plants
print(Plants[1].ItemName, Plants[1].Order, Plants[1].Desc)
1 Like
Thanks, but this only prints one section of data inside of Plants
. How would I print everything inside of Plants
.
Output: Tall Plant 2 Is that a tree or a plant!?
Expected output: Tall Plant 2 Is that a tree or a plant!?
, Ivy 1 What vigorous vining stems...
With your initial table, you would do something like this:
print("Plants:")
for _,plantData in pairs(Table.Plants) do
print(plantData.ItemName, plantData.Order, plantData.Desc)
end
5 Likes