for(var/obj/Items/Potions/WeakHP/b)
if(!b in usr)
var/obj/B=new/obj/Items/Potions/WeakHP
B.loc= usr
B.addAmount(1)
usr<<"test1"
return
else if(b in usr)
b.addAmount(2)
b.suffix="[b.amount]"
usr<<"test2"
return
Problem description:
Code:
for(var/obj/Items/Potions/WeakHP/b) Problem description: |
!b in usr // wrong What your code does (after applying the above fix): do this for every WeakHP potion in the world: if this potion isn't in usr create a new WeakHP potion move new potion to usr call new potion's addAmount(1) stop the proc now else, if this potion is in usr (this "if" is redundant) call this potion's addAmount(2) set this potion's suffix stop the proc now What you probably want: give usr 2 new WeakHP potions In DM, var obj/Items/Potions/WeakHP/potion = locate() in usr In more general DM, mob It looks like you have some misconceptions about the "for()" control structure; what it means, what it does, what it's generally used for. DM Guide, Chapter 6.17.1: for list loop DM Reference: for list |
Ive got misconceptions about all of this XD. Its why i program to learn. Appreciate the advice, I'll try and incorporate and play with this until it sits right. Thank you.
|
Examples (both are the same thing):