Zet0rz / nZombies-Unlimited

nZombies Unlimited
MIT License
43 stars 15 forks source link

LOGIC System #9

Open Zet0rz opened 6 years ago

Zet0rz commented 6 years ago

A system that registers LOGIC objects similarly to ENT and PANEL objects. Should support defining custom logic objects, that each have a set of inputs and outputs, as well as Initialize and Think functions. Logic objects should be able to be enabled and disabled. Should be able to be tied to an entity, or be a "floating logic unit" (which is purely run by code). Should be connectable to other Logic-enabled entities or units.

Overall Logic system:

Logic unit support:

Zet0rz commented 6 years ago

Logic unit creation, networking, and connection now works! They act like our very own custom object type! :D

local LOGIC = {}

-- These are only used for UI; any output can be connected (you can make secret code-only outputs this way)
LOGIC.Outputs = {
    "UponPrintA", "UponPrintAnything"
}

LOGIC.Inputs = {
    ["Print"] = {
        Function = function(self, activator, caller, args, ...)
            print(str)
            print(type(str), str == "A")
            if str == "A" then print("Firing output") self:Output("OnPrintA", str) end
            self:Output("UponPrintAnything", str)
        end
    }
}
nzu.RegisterLogicUnit("nzu_logic_test", LOGIC)