ID:1891010
 
(See the best response by Zecronious.)
How can i get variable from another code-file/directory? Sorry fot noob question, but i don't get it. Cause it says undefined var when i try to use variable in another directory code.

Sry for noob again.
Best response
This is called scope. If I create a variable under 'mob' then anything inside the scope (everything within the definition of mob) can use it. But something outside the mob scope won't be able to use it. Such as turf which has it's own scope.

The same applies for verbs and procs. Anything defined within a proc or within a verb will be accessible by anything inside the definition of the verb or proc.

Here's an example. Anything under the heading of mob will have access to foo. Turf is not under the heading of mob, therefore it can't access foo. However if I create a new mob within turf then I can access the variable because that mob contains foo as the definition of mob states.
mob
var/foo = 10

turf
proc
test()
world << foo // won't work

var/mob/M = new/mob
world << M.foo // will work
Thanks a lot.

P.S But byond still telling bout undefined var.
Try posting the code you're having trouble with, and where the var is defined. That would shed some light on this.
As addition:
You can split your mob-definitions almost as much files as you like. For example, you can define different type of mobs in different files for structuring purposes. If you override for example a variable in one file which is also defined in another, then maybe the loading order (of all files) in your dme-file decides which overrides which. I guess, the last one loaded is the last one to override every previous ones.
Here:

/datum/huds/proc/player_hud(ui_style = 'icons/mob/screen_rogue.dmi')
var/code/modules/client/settings/Have_belt
if (Have_belt)
Blah,Blah
else
Blah,Blah

P.S: Using SS13 style.
In response to Likot
That's not how you get variables from other places. I showed in my original post how each mob contains foo. So in order to get a copy of foo then I must create a copy of mob and then ask it for foo.

I think you need to go back to basics. All of this is covered in the guide. Start from chapter 2 and go as far as is needed.

http://www.byond.com/docs/guide/
This is just a general misunderstanding of what is known in the programming world as "scope". Variables are restricted to the scope in which they're defined, whether it be within a function (a proc), within a game entity, or in the global context.