remove colon syntax from oop
This commit is contained in:
48
sim/main.lua
48
sim/main.lua
@@ -139,31 +139,31 @@ while 1 do
|
||||
local max = vectotable(data[i+4])
|
||||
local bounds = {min[1], min[2], min[3], max[1], max[2], max[3]}
|
||||
|
||||
local wire = Wire:new(tonumber(data[i+1]), tonumber(data[i+2]), bounds)
|
||||
sim:addwire(wire)
|
||||
local wire = Wire.new(Wire, tonumber(data[i+1]), tonumber(data[i+2]), bounds)
|
||||
Simulation.addwire(sim, wire)
|
||||
|
||||
i = i + 4
|
||||
elseif data[i] == "G" then
|
||||
local objref = tonumber(data[i+1])
|
||||
local definition = sim:getdefinitionbyref(tonumber(data[i+2]))
|
||||
local definition = Simulation.getdefinitionbyref(sim, tonumber(data[i+2]))
|
||||
|
||||
assert(definition, "No gate definition for objref "..objref)
|
||||
|
||||
local position = vectotable(data[i+3])
|
||||
local rotation = tonumber(data[i+4])
|
||||
local gate = definition:constructgate(objref, position, rotation)
|
||||
local gate = GateDefitinion.constructgate(definition, objref, position, rotation)
|
||||
|
||||
sim:addgate(gate)
|
||||
Simulation.addgate(sim, gate)
|
||||
--print(gate.objref)
|
||||
gate.definition.init(gate)
|
||||
gate.definition.logic(gate)
|
||||
|
||||
i = i + 4
|
||||
elseif data[i] == "RW" then
|
||||
sim:removewire(tonumber(data[i+1]))
|
||||
Simulation.removewire(sim, tonumber(data[i+1]))
|
||||
i = i + 1
|
||||
elseif data[i] == "RG" then
|
||||
sim:removegate(tonumber(data[i+1]))
|
||||
Simulation.removegate(sim, tonumber(data[i+1]))
|
||||
i = i + 1
|
||||
elseif data[i] == "GD" then
|
||||
--print("---------------------------------------[[[[")
|
||||
@@ -192,28 +192,28 @@ while 1 do
|
||||
if not port.direction then print(line) end
|
||||
end
|
||||
|
||||
local definition = GateDefinition:new(objref, name, desc, init, logic, input, global, ports)
|
||||
sim:addgatedefinition(definition)
|
||||
local definition = GateDefinition.new(GateDefitinion, objref, name, desc, init, logic, input, global, ports)
|
||||
Simulation.addgatedefinition(sim, definition)
|
||||
|
||||
i = i + 8 + numports*5
|
||||
elseif data[i] == "SL" then
|
||||
local wire = sim:getwirebyref(tonumber(data[i+1]))
|
||||
local wire = Simulation.getwirebyref(sim, tonumber(data[i+1]))
|
||||
if wire ~= nil then
|
||||
wire:setlayer(tonumber(data[i+2]))
|
||||
Wire.setlayer(wire, tonumber(data[i+2]))
|
||||
end
|
||||
|
||||
i = i + 2
|
||||
elseif data[i] == "SP" then
|
||||
local gate = sim:getgatebyref(tonumber(data[i+1]))
|
||||
local gate = Simulation.getgatebyref(sim, tonumber(data[i+1]))
|
||||
if gate ~= nil then
|
||||
gate.ports[tonumber(data[i+2])]:setstate(toboolean(data[i+3]))
|
||||
Port.setstate(gate.ports[tonumber(data[i+2])], toboolean(data[i+3]))
|
||||
end
|
||||
|
||||
i = i + 3
|
||||
elseif data[i] == "SG" then
|
||||
local wire = sim:getwirebyref(tonumber(data[i+1]))
|
||||
local wire = Simulation.getwirebyref(sim, tonumber(data[i+1]))
|
||||
if wire ~= nil then
|
||||
wire.group:setstate(toboolean(data[i+2]))
|
||||
Group.setstate(wire.group, toboolean(data[i+2]))
|
||||
end
|
||||
|
||||
i = i + 2
|
||||
@@ -245,7 +245,7 @@ while 1 do
|
||||
local userid = data[i+1]
|
||||
local objref = tonumber(data[i+2])
|
||||
|
||||
local obj = sim:getwirebyref(objref) or sim:getgatebyref(objref)
|
||||
local obj = Simulation.getwirebyref(sim, objref) or Simulation.getgatebyref(sim, objref)
|
||||
|
||||
if obj ~= nil then
|
||||
local info = ""
|
||||
@@ -277,20 +277,20 @@ while 1 do
|
||||
client:send("SINFO\t" .. data[i+1] .. "\t" .. sim.nwires .. "\t" .. sim.ngates .. "\t" .. sim.ninports .. "\t" .. sim.noutports .. "\n")
|
||||
i = i + 1
|
||||
elseif data[i] == "TICK" then
|
||||
sim:tick()
|
||||
Simulation.tick(sim)
|
||||
ticks = ticks + 1
|
||||
elseif data[i] == "TEST" then
|
||||
local gate = sim:getgatebyref(tonumber(data[i+1]))
|
||||
gate:testlogic(tonumber(data[i+2]))
|
||||
local gate = Simulation.getgatebyref(sim, tonumber(data[i+1]))
|
||||
Gate.testlogic(gate, tonumber(data[i+2]))
|
||||
i = i + 2
|
||||
elseif data[i] == "IN" then
|
||||
local gate = sim:getgatebyref(tonumber(data[i+1]))
|
||||
local gate = Simulation.getgatebyref(sim, tonumber(data[i+1]))
|
||||
local argc = tonumber(data[i+2])
|
||||
local argv = {}
|
||||
for a = i+3, i+3+argc-1 do
|
||||
argv[#argv+1] = collapseescape(data[a])
|
||||
end
|
||||
sim:queuegateinput(gate, argv)
|
||||
Simulation.queuegateinput(sim, gate, argv)
|
||||
|
||||
i = i+2+argc
|
||||
elseif data[i] == "SAVE" then
|
||||
@@ -303,7 +303,7 @@ while 1 do
|
||||
i = i + 1
|
||||
end
|
||||
elseif err == "closed" then
|
||||
sim = Simulation:new()
|
||||
sim = Simulation.new(Simulation)
|
||||
acceptclient()
|
||||
end
|
||||
|
||||
@@ -339,9 +339,9 @@ while 1 do
|
||||
|
||||
if time-lastfxtime >= OPT_FX_TIME then
|
||||
if OPT_FX_UPDATES then
|
||||
sim:sendfxupdate()
|
||||
Simulation.sendfxupdate(sim)
|
||||
end
|
||||
sim:sendcallbacks()
|
||||
Simulation.sendcallbacks(sim)
|
||||
lastfxtime = time
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user