mob/proc/OtherProc() src.CalledProc("1") //want to replace one using type???
mob/proc/CalledProc(r) switch(r) if("1") for(var/obj/type1/O in src) //SAME AS THE OTHER 2 if("2") for(var/obj/type2/O in src) //SAME AS THE OTHER 2 if("3") for(var/obj/type3/O in src) //SAME AS THE OTHER 2
Wondering how I can cut out the need for SWITCH() and jump straight into FOR()?
I'm guessing its either with type or text2path()? I tried the latter but didn't get it right :\
mob/proc/CalledProc(r) for(var/obj/Obj in src) if( !istype(Obj, text2path("/obj/type[r]") ) ) continue var/obj/type1/O = Obj // or type2 or type3 ? // common code here
The latter is the most proper and simplest way of doing it.
Edit: If you hate associative lists, you can also do it this way
<dm>
mob/proc/CalledProc(r)
var/whattype
switch(r)
if("1")
whattype=/obj/commontype/blah
if("2")
whattype=/obj/commontype/blahblah
if("3")
whattype=/obj/commontype/blahblahblah
else
whattype=/obj/commontype/ // all
for(var/obj/commontype/O in src)
if( !istype(O,whattype) )
continue
// common code here
Just had a better look at your code snippet...
At first glance it looks like you've assumed i can only call it with "1" etc...
I'm able to type anything I like here - its totally flexible! :)
/* t could equal whatever i want it to in this case: *obj/objtype *obj/objtype/subtype1 *obj/objtype/subtype2 *obj/objtype/subtype3 */ RefreshJustuWindow(t) for(var/obj/SkillCard/O) in usr if(findtext(O,t) //do stuff