Yes you CAN Search Tables (under 50 cells)

JGary321JGary321 Member Posts: 1,246
edited September 2012 in Working with GS (Mac)
Searchable Tables:

IMPORTANT Note 1: The "tutorial" is based around Darren's "Collision without actors template", so I give full credit to him for the idea I am about to share.

IMPORTANT Note 2: This is NOT a beginners tutorial.

You CAN search tables. This is not a perfect system. It will NOT work for WORD games where you need to search hundreds of cells. But if you need to search a small number of cells, lets say around 50, this will work wonderfully.

Step 1: Create 3 self.attributes

image

The ones to pay attention to here are... Inventory_Row, Inventory_Col, & Search. The others don't affect the searchable tables.

Inventory_Row is what Row in the table you want the search to start at. In my case it is Row 15. Inventory_Col is what Column you want it to start at. In my case Column 1.

Step 2: Create 1 game.attribute

image

You'll see why in a minute.

Step 3: The Rules

image

When pressed make self.search = true. Should be simple enough.

image

In this part of the rule... If self.search = true then EVERY 0 Seconds (Run to Completion) change

image

to

image

Note: game.table_checker can be text or integer. For me I wanted to search numbers only therefore it is an integer.

Hopefully everyone is with me so far...

If game.table_checker = 0 (in my case 0 means the inventory slot is empty, but this is the value that you are searching for) then (insert rule here. Whatever action you want performed.)

Otherwise:

image

if self.Inventory_Col < 11 (11 is one more column than what I have in my table, so in my example i have 10 columns) then change self.Inventory_Col to self.Inventory_Col + 1. (this make it search the next column)

Otherwise:

Change self.Inventory_Row to self.Inventory_Row + 1 (this means that if self.Inventory_Col is MORE than 10 that it will change the row to the next row)
Change self.Inventory_Col to 1 (resets the Col back to 1)

So to sum it up what's happening here is Every 0 secs it changes our game.attribute to whats in Row 15 Col 1. It then checks if game.attribute is what we need. If not it goes to the next column & does it again. When it gets done checking column 10 & tries to go to column 11 it goes to Row 16 & Column 1 & starts anew.

Conclusion
Again this will NOT work for a game with a lot of Rows/Columns it needs to search, so most word games are out of the question. But in an RPG for instance it works great. Most RPG's have limited inventory slots. This is not a perfect system by any means, but it is what I am using for my inventory system in the RPG I am currently making. To get it to be a proper inventory system you need to do a bit more work, but this will hopefully spur the creativity & get you thinking.

At this time I am not going to go completely in depth with a full fledge inventory system tutorial, because there are a lot of other factors involved in doing an inventory system. If I do decide to create an inventory tutorial I will do it as a video tutorial most likely, because it would be way to much to type out & do screenshots for.

Anyways I hope this helps someone get the ball rolling with whatever they need.

JG

Comments

Sign In or Register to comment.