--Description: allows up to 9 behaviours on the same object. --Description: apply your desired behaviours to hidden objects & make the hidden objects not spawn at start --Description: link them to this object via the link system in the order you define below --Description: make sure to include any sub folders inside "scriptbank" --Description: [BehaviourName1$=""] --Description: [BehaviourName2$=""] --Description: [BehaviourName3$=""] --Description: [BehaviourName4$=""] --Description: [BehaviourName5$=""] --Description: [BehaviourName6$=""] --Description: [BehaviourName7$=""] --Description: [BehaviourName8$=""] --Description: [BehaviourName9$=""] g_behaviour_chain = {} function behaviour_chain_properties(e, behaviourname1, behaviourname2, behaviourname3, behaviourname4, behaviourname5, behaviourname6, behaviourname7, behaviourname8, behaviourname9) for i, behaviourname in ipairs({behaviourname1, behaviourname2, behaviourname3, behaviourname4, behaviourname5, behaviourname6, behaviourname7, behaviourname8, behaviourname9}) do if behaviourname ~= "" then g_behaviour_chain[e][i] = {} g_behaviour_chain[e][i].name = behaviourname end end g_behaviour_chain[e].gotlinks = false end function behaviour_chain_init(e) g_behaviour_chain[e] = {} end function behaviour_chain_main(e) if not g_behaviour_chain[e].gotlinks then for a = 0, 9 do local c = GetEntityRelationshipID(e, a) if c > 0 and c ~= e then local str = g_behaviour_chain[e][a+1].name local path = {} for substring in str:gmatch("([^\\]+)") do table.insert(path, substring) end local fpath = g_behaviour_chain[e][a+1].name g_behaviour_chain[e][a+1].script = Include(fpath..".lua") local fname = path[#path].."_init" g_behaviour_chain[e][a+1].init = _G[fname] if g_behaviour_chain[e][a+1].init ~= nil then g_behaviour_chain[e][a+1].init(e) else g_behaviour_chain[e][a+1].init = _G[fname.."_name"] if g_behaviour_chain[e][a+1].init ~= nil then g_behaviour_chain[e][a+1].init(e,name) end end g_behaviour_chain[e][a+1].globalname = _G["g_"..path[#path]] if g_behaviour_chain[e][a+1].globalname ~= nil then g_behaviour_chain[e][a+1].globalname[e] = g_behaviour_chain[e][a+1].globalname[c] g_behaviour_chain[e][a+1].globalarray = g_behaviour_chain[e][a+1].globalname[e] end fname = path[#path].."_main" g_behaviour_chain[e][a+1].main = _G[fname] end end g_behaviour_chain[e].gotlinks = true else for a = 1, 9 do if g_behaviour_chain[e][a] ~= nil then if g_behaviour_chain[e][a].main ~= nil then g_behaviour_chain[e][a].main(e) end end end end end