2 KiB
2 KiB
API Reference
api api.parser.json api.parser.xml api.url api.util api.protocol api.ext.* api.ext.exec(fn, ,..) api.ecs api.world
Entity Component System (ECS)
Read the Full Documentation here https://bakpakin.github.io/tiny-ecs/doc
Below are some helper functions to make things more efficient
commit()
obj = { foo = "bar", mycomponent = { a = 1 } }
api.ecs.add( api.world, obj )
obj.foo = "flop"
obj.commit('Xhappened')
-- commit notifies all systems to rebuild entitycache
-- because normally systems filter on an entitycache (=fast)
-- which would still rely on foo = "bar".
-- Only do this when you actually need a system to pick
-- up on a change.
also api.ext.exec('Xhappened') is called so extensions can respond to the change.
api.parser.xml
local xml = api.parser.xml.newParser()
local testXml = [[
<testOne param="param1value">
<testTwo paramTwo="param2value">
<testThree>
testThreeValue
</testThree>
<testThree duplicate="one" duplicate="two">
testThreeValueTwo
</testThree>
<test_Four something="else">
testFourValue
</test_Four>
<testFive>
<testFiveDeep>
<testFiveEvenDeeper>
<testSix someParam="someValue"/>
</testFiveEvenDeeper>
</testFiveDeep>
</testFive>
testTwoValue
</testTwo>
</testOne>
]]
util.traverseXML( xml:ParseXmlText(testXml), function(node,raw)
print_r(node)
-- {
-- tag = "div",
-- prop = {
-- style = "color:red; display:none"
-- }
-- }
end)
api.ext.exec
This allows batch-firing a function on each extension (if exist)
api.ext.exec('init', 123, "foo") -- call .init(123,"foo") on each extension