Skip to content

Instantly share code, notes, and snippets.

@rubenwardy
Last active December 17, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/6968b70a3853a3036d69 to your computer and use it in GitHub Desktop.
Save rubenwardy/6968b70a3853a3036d69 to your computer and use it in GitHub Desktop.
-- stuff
def = {
c = {"blah","blah2"}
}
-- comp
blah = {
depends = {"blah3"}
}
-- dependancy tree checker
yamm.validate = {
c = function (def)
for i=1,#def.c do
print("Looking for dependancies to "..def.c[i])
local cur_type = yamm.types[def.c[i]]
if cur_type and yamm.types[def.c[i]].depends then
-- check component dependancies
for a=1,#cur_type.depends do
local cur_dep = cur_type.depends[a]
print("--> "..cur_dep)
if not yamm.validate.find_in_def(def,cur_dep) then
print(" > added")
table.insert(def.c,cur_dep)
end
end
end
end
end,
find_in_def = function(def,find)
for i=1,#def.c do
if def.c[i] == find then
print("found "..find.." at "..i)
return i
end
end
return false
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment