This solves my problem here, got some help on EUO. I was worried that no one would see it due to the limited activity in their script debug thread but luckily there are some that still read it. I am posting this here in case anyone else runs into the same problem and needs a fix! 
finditem afz c_ , %ResourceSecure
{
for #findindex 1 #findcnt
{
set %resource . #findcol #findid
}
}
%resource1150 = #findid of saltpeter
%resource1190 = #findid of charcoal
%resource1102 = #findid of potash
%resource1109 = #findid of blackpowder
The code you posted basically sets dynamic variables for you to use.
What happens if we call a variable that isn't set in EasyUO? I haven't tried hehe

I'm guessing the code i posted should work then as well?
set %saltpeter SPT (whatever the objecttype is)
set %saltpeterColor 1150
finditem %saltpeter C_ , #BACKPACKID
if #FINDCNT > 0
{
for #FINDINDEX 1 #FINDCNT
{
if #FINDCOL = %saltpeterColor
{
; do specific something with this type
}
else
{
; drag to container
}
}
}
Let's analyze your code a bit (anyone can correct me if i'm wrong, i'm beginner at this

)
sub CheckColor
finditem AFZ C_ , %ResourceSecure
You mentioned that you were looking for a way to distinguish between items that share the same objecttype right?
So with this you might find saltpeter & charcoal & others right?
-> If that is the case, i think you need to iterate, loop through, the result of finditem. Charcoal, saltpeter, ... will all have a different index.
-> for #findindex 1 #findcnt
sub CheckColor
finditem AFZ C_ , %ResourceSecure
wait 10
[
if #findcol = 1150
set %resoucrce 1
if #findcol = 1190
set %resource 2
if #findcol = 1102
set %resource 3
if #findcol = 1109
set %resource 4
]
gosub CheckSaltpeter
;===================================================================
sub CheckSaltpeter
finditem %resource1 C_ , #backpackid
if #findstack <= 20
{
wait 10
gosub moveit #backpackid %ResourceSecure %resource1 200
wait 10
if #result = 0
{
display Out of saltpeter in secure, halting...
halt
}
}
pause
return
- The sub CheckColor doesn't have a return at the end
- What are the square brackets? Same as {}?
- set %resoucrce 1 has a typo
- set %resource 1
=> this basically sets a local variable named 'resource' to a string 1 (or is it an integer? no idea)
but in your sub CheckSaltpeter you are using 'finditem %resource1' which you have never set, you have set %resource to the value of 1