var list/db
// Functions
proc/db_get(s) {var list/l = splittext(s,"."); switch(l.len){if(1){return global.db[l[1]]};if(2){return global.db[l[1]][l[2]]};if(3){return global.db[l[1]][l[2]][l[3]]};if(4){return global.db[l[1]][l[2]][l[3]][l[4]]};if(5){return global.db[l[1]][l[2]][l[3]][l[4]][l[5]]};if(6){return global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]]};if(7){return global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]][l[7]]};if(8){return global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]][l[7]][l[8]]};if(9){return global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]][l[7]][l[8]][l[9]]}}}
proc/db_set(s,v=list()) {var list/l = splittext(s,"."); switch(l.len){if(1){global.db[l[1]] = v};if(2){global.db[l[1]][l[2]] = v};if(3){global.db[l[1]][l[2]][l[3]] = v};if(4){global.db[l[1]][l[2]][l[3]][l[4]] = v};if(5){global.db[l[1]][l[2]][l[3]][l[4]][l[5]] = v};if(6){global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]] = v};if(7){global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]][l[7]] = v};if(8){global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]][l[7]][l[8]] = v};if(9){global.db[l[1]][l[2]][l[3]][l[4]][l[5]][l[6]][l[7]][l[8]][l[9]] = v}}}
proc/db_gen(A,B) {if(!A||!B){return list()};var/a = db_get(A), b = db_get(B), c, d, e, f, id;for(c in a){for(d in b){id = "[d] [c]"; e = a[c]; f = b[d]; db_set(A, db_get(A) + list("[id]" = db_com(e,f)))}};return db_get(A)}
proc/db_com(list/a,list/b) {var j,list/n = new;for(j in a){if(j in n){n[j] += a[j]}; else n[j] = a[j]};for(j in b){if(j in n){n[j] += b[j]}; else n[j] = b[j]};return n}
// Modify The Database Below
proc/InitializeDatabase()
db = new
/* Items */
db_set("item", list("weapon","armor"))
db_set("item.weapon", list("types","list"))
db_set("item.weapon.types", list(
"Dagger" = list("DMG"=3, "ACC"=90, "CRI"=10),
"Sword" = list("DMG"=5, "ACC"=70, "CRI"=5),
"Axe" = list("DMG"=8, "ACC"=55, "CRI"=10),
))
db_set("item.weapon.list", db_get("item.weapon.types"))
/* Enchantments */
db_set("item.enchantments", list(
"Powerful" = list("DMG"=5),
"Accurate" = list("ACC"=10),
"Deadly" = list("CRI"=10),
"Sharp" = list("BLD"=5),
))
db_set("item.weapon.list", db_gen("item.weapon.list", "item.enchantments"))
ID:2444347
Mar 27 2019, 7:04 pm
|
|
Mar 27 2019, 7:04 pm
|
|
To use/Demo
|
WIP - 5270 items generated.
proc/InitializeDatabase() |
O:
else {parent_type = /obj; New(){world << ":D"}} |