Hey OTLand, so I have this small script snippet here:
What I am attempting to do is something like this:
But I would like to be able to recall that..
So, in essence, I'm trying to make the function "GetItemInfo()" be able to call both the item name of a given value in the table, as well as the price, so that if GetItemInfo(x) where x=1 the output would be something like..
All in all, I'm attempting to index particular values from this table, so I'm able to recall the item's name OR the item's price by telling GetItemInfo(x) to search for the values of "Item" and "Price" within the table "Mining" at value "x".
I haven't used Lua in a long ass time, and have been learning Pascal, so this is confusing me.
Thanks,
-Aelu
Lua:
Mining =
{
--Foraged Minerals
[1] = {Item = "Quartz", Price = 25},
[2] = {Item = "Earth Crystal", Price = 50},
[3] = {Item = "Frozen Tear", Price = 75},
[4] = {Item = "Fire Quartz", Price = 100},
--Gems
[5] = {Item = "Emerald", Price = 250},
[6] = {Item = "Aquamarine", Price = 180},
[7] = {Item = "Ruby", Price = 250},
[8] = {Item = "Amethyst", Price = 100},
[9] = {Item = "Topaz", Price = 80},
[10] = {Item = "Jade", Price = 200},
[11] = {Item = "Diamond", Price = 750},
[12] = {Item = "Prismatic Shard", Price = 2000}
}
What I am attempting to do is something like this:
Lua:
function GetItemInfo(i, p)
local i = Mining[x].Item
local p = Mining[x].Price
print(i, p)
end
But I would like to be able to recall that..
Code:
x = The index value of the given table above (Mining)
i = "Item" in the index "x"
p = "Price" in the index "x
So, in essence, I'm trying to make the function "GetItemInfo()" be able to call both the item name of a given value in the table, as well as the price, so that if GetItemInfo(x) where x=1 the output would be something like..
Code:
Quartz 15
All in all, I'm attempting to index particular values from this table, so I'm able to recall the item's name OR the item's price by telling GetItemInfo(x) to search for the values of "Item" and "Price" within the table "Mining" at value "x".
Lua:
function GetItemInfo(i, p)
--Some code--
print(i) --Prints "Quartz"
or
print(p) --Prints "15"
I haven't used Lua in a long ass time, and have been learning Pascal, so this is confusing me.
Thanks,
-Aelu