ID:149304
 
Can you create a new class of object that represents multiple other types of objects? For example, "/atom" represents "/turf", "/obj", "/area" and "/mob", while "/atom/movable" only represents "/obj" and "/mob". Is there a way to create a custom type that will represent whatever I want, such as "/room" which would represent "/obj/room", "/area/room" and "/turf/room"?

It seems like someone mentioned that this was possible, but I don't know what to look for and I don't know if it really is or not.
Foomer wrote:
Can you create a new class of object that represents multiple other types of objects? For example, "/atom" represents "/turf", "/obj", "/area" and "/mob", while "/atom/movable" only represents "/obj" and "/mob". Is there a way to create a custom type that will represent whatever I want, such as "/room" which would represent "/obj/room", "/area/room" and "/turf/room"?

It seems like someone mentioned that this was possible, but I don't know what to look for and I don't know if it really is or not.

Foomer,

You sort of have the concept of inheritance a little backwards.

"/atom" and "/atom/movable" represent all of those other types, because they are PARENTS of those types. In other words, the fully qualifying name for "/mob" is really "/atom/moveable/mob". "/mob" is just shorthand that we're allowed to use. You can read more about this here:

http://www.byondscape.com/scape.dmb/content/000026/ index.html#/atom

To answer your question, though, I'm 99.9% sure that we can't create custom higher level types that posess the same properties as lower level base types (unless we additionally write code which mimics their behavior). In the long run, it's just easier to inherit off of those lower level base types.

Regards,
Corporate Dog

In response to Corporate Dog
I'll show off my lack of expertise now. Does having an additional amount of unused variables create any "bad things" within the game? If mobs had all the same values as turfs and turfs had all the same values as mobs, would there be any problems with this?
In response to Foomer
Not really, if the variables are totally unused. You could load an atom chok-full with variables and as long as they are not in use there will be no heightened CPU or server lag. However, if all of those vars are being periodically calibrated, you're going to get lag spikes as every atom runs its calibration process. You can smoothe out those spiked by staggering the calibration processes.

-Lord of Water
In response to Foomer
Foomer wrote:
I'll show off my lack of expertise now. Does having an additional amount of unused variables create any "bad things" within the game? If mobs had all the same values as turfs and turfs had all the same values as mobs, would there be any problems with this?

Nope, there's no problem with that. As long as a var remains at its initial value, it takes up no additional memory.

Lummox JR
In response to Lummox JR
What if you use the variable for a bit but then don't need it anymore (for a while at least)? Can you set it to it's initial value and it's memory will be deallocated or once the initial value has changed will it take up memory no matter what value it may take on?

My guess would be the latter but you never know :p
In response to English
English wrote:
What if you use the variable for a bit but then don't need it anymore (for a while at least)? Can you set it to it's initial value and it's memory will be deallocated or once the initial value has changed will it take up memory no matter what value it may take on?

My guess would be the latter but you never know :p

I believe it should cease to take up memory at that point.

Lummox JR
In response to Lummox JR
If you make the variable equal to null, such as:
mob/var/MyLogin = 5

...lines of code using MyLogin...

MyLogin = null

You delete the memory reference and thus free up that memory for use. The problem is, however, that your OS ( such as Windows 9x ) may not realize that the memory is free and you won't get it back until the program ends ( like normal basically ).

But this is still a good programming practice because I believe BYOND will still know that the memory space is open and should put something there -- theoretically.

In response to ShadowWolf
ShadowWolf wrote:
If you make the variable equal to null, such as:
mob/var/MyLogin = 5

...lines of code using MyLogin...

MyLogin = null

You delete the memory reference and thus free up that memory for use. The problem is, however, that your OS ( such as Windows 9x ) may not realize that the memory is free and you won't get it back until the program ends ( like normal basically ).

This depends on how memory is allocated in BYOND, but you make a good point: When a small chunk is deallocated, there's no guarantee something else will use it.

Lummox JR