2
\$\begingroup\$

Im making an rpg game and right now I'm working on crafting. I've made a crafting slot class, and an arrayList of that class. I've got 10 of those slots in total, 9 placed in a 3x3 'order' and 1 below (like the minecraft inventory). I want to check if the 9 slots contain some items in a particular way, and if they do to put a item in the 10th slot. I can figure out how to craft stuff, but I don't know how to read all those 9 slots at the same time (btw Im using an enhanced for loop to update and render all of 'em). I figured I would check if the slots contain items in this order

4 4 4

0 3 0

0 3 0

(4 being stone and 3 being the stick item)

Each slot has its own item variable. So how can I access all of them at the same time? Or even if there is a simpler way to do this. Thank you

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Just check them 1 at a time in a loop. At some point that needs to happen anyway. \$\endgroup\$ Commented Oct 31, 2015 at 20:34

1 Answer 1

1
\$\begingroup\$

You don't need to access them all at once, use a for-loop going from 0 to 8 (1-9 in human counting) to check them against an array of your recipe.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.