ID:2242883
 
(See the best response by Byakuya_uchiha32.)
Code:
obj/bar/healthOverlay
icon='Healthbar.dmi';icon_state="overlay"
pixel_y=38;layer=100;pixel_x=-1


obj/bar/health
icon='healthBar.dmi';icon_state="health"
pixel_y=38;layer=99;pixel_x=-1


mob/proc/healthCheck()
var/obj/bar/healthOverlay/o=new()
var/obj/bar/health/h=new()
var matrix/m=new()
src.overlays-=src.healthBar
src.overlays-=h;src.overlays-=o
src.overlays+=o
m.Scale(src.hp/src.maxhp,1)
h.transform=m
h.pixel_x+=(((src.hp/src.maxhp)-1)*10) * (((h.bound_width/2)-1)/9.5)
src.healthBar=h
src.overlays+=h

Barcode.dm:16:error: src.healthBar: undefined var
Barcode.dm:19:error: src.hp: undefined var
Barcode.dm:19:error: src.maxhp: undefined var
Barcode.dm:21:error: src.hp: undefined var
Barcode.dm:21:error: src.maxhp: undefined var
Barcode.dm:22:error: src.healthBar: undefined var

Problem description:
I was watching a tutorial https://www.youtube.com/watch?v=cm_yYWNLaOM&t=129s and i appear to have done something wrong and have tried many things to fix it but it just wont work, I wish to know if there is anything wrong here or if i should just try to find another way of making a healthbar.
Not to state the obvious but have you defined those variables already in the project?
for example

mob/var
hp=0
healthBar
maxhp=10
In response to Byakuya_uchiha32
mob/var
hp=200
maxhp=200
healthBar


sure did, i probably messed something up here somewhere o.o
are those variables located in a different .dm file from your healthbar code?
In response to Byakuya_uchiha32
Indeed they are.
Best response
try moving those specific variables to the same .dm file
In response to Byakuya_uchiha32
...thank you LOL i knew i was gonna feel stupid after this xD
lol im glad it worked out. I don't know why thats happening because in theory it should work no matter where the variables are located unless you have that .dm file unchecked or not included while compiling.
In response to Byakuya_uchiha32
yeah xD
Whut? NO! It doesn't matter what file things are in!

Please share the snippet where you declare all your variable for your mob, it should look something like:
mob
var
hp
maxhp


Also, I'd advise not writing:
A line of DM; another line; and another

as it makes your code much less legible, which means less maintainable, and more bug-prone. This isn't real estate, you're not paying per line, use whatever space you need ;)
im pretty sure he wasn't including the dm file the variables were located while compiling. its the only viable explanation
It'd be better to tick include on that DM, and keep the code structured sensibly than to teach him to bunch stuff together unnecessarily though.

It's important that we keep in mind that solving the problems here is not our only goal: we also need to help people become better programmers.
In response to Ease
Well i got it to work more organized :D, Only issue now is i gotta figure out how to get my turfs working again O.o