ID:2113008
 
Code:
CrystalB
var/obj/items/equippable/CrystalB/cha=0
name="Dark Moon Blood Crystal"
icon='CrystalB.dmi'
proc
Use()
if(usr.henge)return
Click()Use()
verb
Drop()
loc=locate(usr.x,usr.y,usr.z)
Pick_Up()
set src in oview(1)
loc=usr
usr<<"You picked up a [src]."

FeedChakra()
prejutsu()
if(swim||dead||stun||resting||caught||seals||busy)return
handseals(50,5,50)
if(!sealpass)return
view(8)<< output("<font color=cyan><b>[usr]: Grow STRONGER!","output2")
for(var/obj/items/equippable/CrystalB in orange(4, src))
CrystalB.cha+=1000
if(CrystalB.cha==1000)
overlays+='blacklightningaura.dmi'
return


Problem description: The first snippet is a new obj in required.dm file, that I am using as a catalyst for a new jutsu...

I defined a cha(kra) var to it, as to be able to put a chakra in it from players.

The second snippet is a test verb, that will turn into said jutsu, and uses tries to add 1000 chakra (for test purposes).

I get a var undefined, and it's probably super simple, but I have had this problem before, and I couldn't fix it then either. Simply overlooking stuff is a problematic habit of mine, until I give in...

The variable in question is the CrystalB.cha.

1. var/obj/items/equippable/CrystalB/cha=0 is bad. Just use var cha = 0.
It's bound to the /obj/items/equippable/CrystalB type simply because of where it is in the code.

2. for(var/obj/items/equippable/CrystalB in orange(4, src)) defines a variable called "CrystalB" with the type /obj/items/equippable. It's not declared as an /obj/items/equippable/CrystalB, so you can't use it to access variables of /obj/items/equippable/CrystalB.

3. The above two problems hint at a fundamental misunderstanding on how variables are declared. Try the DM Guide?

4. Using usr even in procs you call from Click() should be avoided. Use this pattern instead:
proc/Use(mob/User)
if(User.henge) return // use the User parameter, not usr

Click()
Use(usr) // pass usr as the first argument to Use(mob/User)
Oh no that's just a clear oversight on typing over a code, from a notepad.

I actually tried various ways, but always take my latest attempt, and post that. Var cha=0 was the first one I tried, but thanks for pointing this out :)

It's clear I am a programming virgin, haha, but I appreciate every little mistake you point out.

I wouldn't want it any other way though, this is how I learn way better, than reading a dm guide. I ain't a learner like that unfortunately.