This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
kain184's profile picture

searching for keywords inside table data

Started by kain184, 29 January 2015 - 11:16 PM
kain184 #1
Posted 30 January 2015 - 12:16 AM
hello i am trying to find out if it is possible to seach keywords from table data. in my case i am using a table to store name variable data from open peripherals in such a format
name.rawname.display name why you ask is becouse of items like mushroom that give that data as
tile.mushroom.red_mushroom.Mushroom. i need all three factors to match for the checks i have to work becouse of the overlap between nbt similer items.
so i want to run a check in the table for the item and have it tell me which line it is on instead of having each name in a seperate key that way the line number can be used to call the item into the system. instead of having to use the table name for each item as such Ingredients[1] equiling vines it would call the table tell me 1 and that number would go into the pull item slot any ideas
Bomb Bloke #2
Posted 30 January 2015 - 12:24 AM
I get the impression this thread will explain what you want to know; if it doesn't, post the code you're using.
kain184 #3
Posted 30 January 2015 - 12:49 AM
that is basicly the same system im already using to get and store the information the way i want to do it is as such

table.insert(ingredients,1,item in slot name data for each slot item)
so it would be like so
ingredients={  1= name1,name2,name3,etc}
but i want to seach ingredients for say mushroom
ingredients={1=mushroom,etc}
but the names are like i said before
name.displayname.raw or in any order so that i can match it.
but i want to search instead of for the full name a keyword. such as brown to distinguish between red_mushroom and brown_mushroom
and that the table return will give me the line it is in in this example it should be 1 to tell me slot one is a brown mushroom so it will be put in  chest.pullItem(slot,)
Bomb Bloke #4
Posted 30 January 2015 - 03:37 AM
Are you familiar with how to search for given symbols, words and phrases within strings?
kain184 #5
Posted 30 January 2015 - 04:20 AM
no but that sounds like what i am looking for can you show me an example or point me in the right direction
Bomb Bloke #6
Posted 30 January 2015 - 05:13 AM
Check out the functions listed here, such as string.find().