ID:2922142
 
Applies to:DM Language
Status: Open

Issue hasn't been assigned a status value.
Title.

* It will be static within the same typepath (or subtypes in a condition)
* If a subtype doesn't define a new variable to that typestatic, it will be considered to be the same static from its parent.
* If a subtype defines a new variable to that typestatic, this will be a new group of static that's only available to its type.

I wrote a syntax below


/mob
// this is shared by every /mob
var/static/some_var = "hello"
// this works like static, but static per type.
var/typestatic/special_var = "nice mob"

/mob/slime
// some_var // same as "hello"
special_var = "amazing slime" // not "nice mob"

/mob/slime/normal
// if you don't assign any value to this, this will follow "/mob/slime" together
// This is determined at compiling level
// special_var

/mob/slime/blue
some_var // same as "hello"
special_var = "blueish slime"

/proc/main()
var/mob/slime/S1 = new()
var/mob/slime/normal/S2 = new()
var/mob/slime/S3 = new()
S1.special_var = "Not blue slime"

var/mob/slime/blue/S4 = new()

// from S1 to S3, their special_var was "amazing slime"
// but all of them now have "Not blue slime"
// while S4/special_var is "bluish slime"

// For /mob/slime/normal
// This one has no new value to this type
// and then, it will follow the same value to parent type


I think the majour usecase of this will be caching the same multiple list()

/datum/skill
var/typestatic/list/banned_jobs = null

/datum/skill/alchemy
banned_jobs = list("Warrior", "Archer")

/datum/skill/alchemy/advanced
// uses the same static from its parent

/datum/skill/alchemy/advanced/sorcery
banned_jobs = list("Warrior", "Archer")
// Even if it's the same one from its parent, this is redefined, thus it's another instance.

/datum/skill/archery
banned_jobs = list("Wizard")

/proc/main()
var/datum/skill/alchemy/skill_alch = new()
for(var/each in skill_alch .banned_jobs)
world.log << "[each] is banned job!"

var/datum/skill/alchemy/advanced/skill_alch_adv = new()
skill_alch_adv.banned_jobs += "Soldier"

for(var/each in skill_alch.banned_jobs)
world.log << "[each] is banned job!" // it says soldier too

var/datum/skill/archery/s_archery = new()
for(var/each in s_archery.banned_jobs)
world.log << "[each] is banned job!"
// it only says wizard

var/datum/skill/alchemy/advanced/sorcery/s_sorcery= new()
for(var/each in s_sorcery.banned_jobs)
world.log << "[each] is banned job!"
// it doesn't say "Solider" because its banned_jobs uses different instance.