Lots of changes

This commit is contained in:
Ryan Ward 2020-03-02 15:15:09 -05:00
parent 363fd4e639
commit 8063aa432c
3 changed files with 6 additions and 162 deletions

View File

@ -4,7 +4,7 @@ Table of contents
--- ---
# Update 14.2.0 - Oh my let's Stringify # Update 14.2.0 - Destroy!
Full Update Showcase Full Update Showcase
--- ---
```lua ```lua
@ -71,7 +71,7 @@ multi:lightloop()
``` ```
Going Forward: Going Forward:
--- ---
- - There is no longer any plans for sterilization! Functions do not play nice on different platforms and there is no simple way to ensure that things work.
Added: Added:
--- ---
@ -80,7 +80,7 @@ Added:
Fixed: Fixed:
--- ---
- Issue with connections not returning a handler for managing a specified conn object. - Issue with connections not returning a handle for managing a specific conn object.
- Issue with connections where connection chaining wasn't working properly. This has been addressed. - Issue with connections where connection chaining wasn't working properly. This has been addressed.
```lua ```lua
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
@ -104,7 +104,7 @@ Changed:
- Destroying an object converts the object into a 'destroyed' type. - Destroying an object converts the object into a 'destroyed' type.
- connections now have type 'connector_link' - connections now have type 'connector_link'
```lua ```lua
OnExample = multi:newConnection() OnExample = multi:newConnection() -- Type Connector, Im debating if I should change this name to multi:newConnector() and have connections to it have type connection
conn = OnExample(...) conn = OnExample(...)
print(conn.Type) -- connector_link print(conn.Type) -- connector_link
``` ```

View File

@ -1,75 +0,0 @@
--[[
MIT License
Copyright (c) 2020 Ryan Ward
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
local bin = pcall(require,"bin")
if not bin then return error("The bin library is required to use sterilization!") end
local multi,thread = require("multi"):init()
local sterilizer = {}
----------
-- Helpers
----------
local function inList(t,o)
for i,v in pairs(t) do
if v==o then
return v
end
end
end
---------------------
-- State Saving Stuff
---------------------
multi.OnObjectCreated(function(obj)
print(obj.Type)
end)
function IngoreObject()
-- Tells system to not sterilize this object
end
function sterilizer:ToString()
-- Turns the object into a string
end
function sterilizer:newFromString(str)
-- Creates an object from string
end
function sterilizer:ToFile(path)
-- Turns multi object into a string
end
function sterilizer:fromFile(path)
-- Loads multi object form file
end
function sterilizer:SetStateFlag(opt)
-- manage the states
end
function sterilizer:quickStateSave(b)
-- enables quick state saving
end
function sterilizer:saveState(path,opt)
-- Saves entire state to file
end
function sterilizer:loadState(path)
-- Loads entire state from file
end
function sterilizer:setDefualtStateFlag(opt)
-- sets the default flags for managing states
end
return sterilizer

View File

@ -1,85 +1,4 @@
package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path package.path="?.lua;?/init.lua;?.lua;?/?/init.lua;"..package.path
-- local sterilizer = require("multi.integration.sterilization")
multi,thread = require("multi"):init() multi,thread = require("multi"):init()
local function inList(t,o,n)
local c = 1 multi:lightloop()
if not o["$__COUNTER__$"] then
o["$__COUNTER__$"] = 1
end
if o["$__COUNTER__$"]==n then
return o
end
for i,v in pairs(t) do
if v==o then
o["$__COUNTER__$"] = o["$__COUNTER__$"] + 1
if o["$__COUNTER__$"]==n then
return o
end
end
end
end
local function initLoop(t,max)
for i,v in pairs(t) do
v["$__COUNTER__$"] = max
end
return t
end
function _getPath(tbl, obj, conn, loop, path, orig)
local max = 100
if not loop then loop = initLoop({package,_G,math,io,os,debug,string,table,coroutine},max) end
if not path then path = {} end
if not ref then ref = {} end
for k, v in pairs(tbl) do
if type(v) == "table" and type(k)~="number" and not inList(loop,v,max) then -- Only go this deep
if v~=orig and k=="Parent" then
--
else
--print(table.concat(path,".").."."..k)
table.insert(ref,v)
table.insert(loop,v)
table.insert(path,k)
if v==obj then
conn(table.concat(path,".").."."..k,ref)
end
_getPath(v, obj, conn, loop, path, orig)
table.remove(path)
table.remove(ref)
end
end
if v==obj and orig[k] then
conn(k,ref)
elseif v==obj then
if type(k)=="number" then return end
local str = table.concat(path,".").."."..k
conn(str,ref)
end
end
end
function getPath(tbl,obj)
local instances = {}
_getPath(tbl, obj, function(ins)
table.insert(instances,ins)
end,nil,nil,tbl)
local min = math.huge
local ins
for i,v in pairs(instances) do
if #v<min then
ins = v
min = #v
end
end
return ins or false
end
test = {}
test.temp = {}
test.temp.hello = multi:newAlarm(3)
test.temp.yo = multi:newEvent()
local hmm = test.temp.hello
local hmm2 = test.temp.yo
local hmm3 = multi.DestroyedObj.t()
for i,v in pairs(hmm3) do
print(i,v)
end
-- print(getPath(_G, hmm))
-- print(getPath(_G, hmm2)) -- Cannot index into multi because of __index
-- print(getPath(multi, hmm3))