added automatic registration for non-builtin gate datablocks
This commit is contained in:
		| @@ -1,83 +1,83 @@ | ||||
|  | ||||
| textbrick_idxToPrint = textbrick_idxToPrint or { | ||||
| 	[0x00] = "space", | ||||
| 	 | ||||
| 	[0x01] = "A", | ||||
| 	[0x02] = "B", | ||||
| 	[0x03] = "C", | ||||
| 	[0x04] = "D", | ||||
| 	[0x05] = "E", | ||||
| 	[0x06] = "F", | ||||
| 	[0x07] = "G", | ||||
| 	[0x08] = "H", | ||||
| 	[0x09] = "I", | ||||
| 	[0x0A] = "J", | ||||
| 	[0x0B] = "K", | ||||
| 	[0x0C] = "L", | ||||
| 	[0x0D] = "M", | ||||
| 	[0x0E] = "N", | ||||
| 	[0x0F] = "O", | ||||
| 	[0x10] = "P", | ||||
| 	[0x11] = "Q", | ||||
| 	[0x12] = "R", | ||||
| 	[0x13] = "S", | ||||
| 	[0x14] = "T", | ||||
| 	[0x15] = "U", | ||||
| 	[0x16] = "V", | ||||
| 	[0x17] = "W", | ||||
| 	[0x18] = "X", | ||||
| 	[0x19] = "Y", | ||||
| 	[0x1A] = "Z", | ||||
| 	 | ||||
| 	[0x1B] = "0", | ||||
| 	[0x1C] = "1", | ||||
| 	[0x1D] = "2", | ||||
| 	[0x1E] = "3", | ||||
| 	[0x1F] = "4", | ||||
| 	[0x20] = "5", | ||||
| 	[0x21] = "6", | ||||
| 	[0x22] = "7", | ||||
| 	[0x23] = "8", | ||||
| 	[0x24] = "9", | ||||
| 	 | ||||
| 	[0x25] = "bang", | ||||
| 	[0x26] = "at", | ||||
| 	[0x27] = "pound", | ||||
| 	[0x28] = "dollar", | ||||
| 	[0x29] = "percent", | ||||
| 	[0x2A] = "caret", | ||||
| 	[0x2B] = "and", | ||||
| 	[0x2C] = "asterisk", | ||||
| 	[0x2D] = "minus", | ||||
| 	[0x2E] = "equals", | ||||
| 	[0x2F] = "plus", | ||||
| 	[0x30] = "apostrophe", | ||||
| 	[0x31] = "less_than", | ||||
| 	[0x32] = "greater_than", | ||||
| 	[0x33] = "period", | ||||
| 	[0x34] = "qmark", | ||||
| 	 | ||||
| 	[0x35] = "apostrophe2", | ||||
| 	[0x36] = "colon", | ||||
| 	[0x37] = "comma", | ||||
| 	[0x38] = "curlybracketleft", | ||||
| 	[0x39] = "curlybracketright", | ||||
| 	[0x3A] = "currencysign", | ||||
| 	[0x3B] = "euro", | ||||
| 	[0x3C] = "onehalf", | ||||
| 	[0x3D] = "poundsymbol", | ||||
| 	[0x3E] = "roundbracketleft", | ||||
| 	[0x3F] = "roundbracketright", | ||||
| 	[0x40] = "slashleft", | ||||
| 	[0x41] = "slashright", | ||||
| 	[0x42] = "squarebracketleft", | ||||
| 	[0x43] = "squarebracketright", | ||||
| 	[0x44] = "tilde", | ||||
| 	[0x45] = "umlaut", | ||||
| 	[0x46] = "underscore", | ||||
| 	[0x47] = "verticalbar", | ||||
| } | ||||
|  | ||||
| return function(gate) | ||||
| 	gate.tickStarted = 0 | ||||
| end | ||||
|  | ||||
| textbrick_idxToPrint = textbrick_idxToPrint or { | ||||
| 	[0x00] = "space", | ||||
| 	 | ||||
| 	[0x01] = "A", | ||||
| 	[0x02] = "B", | ||||
| 	[0x03] = "C", | ||||
| 	[0x04] = "D", | ||||
| 	[0x05] = "E", | ||||
| 	[0x06] = "F", | ||||
| 	[0x07] = "G", | ||||
| 	[0x08] = "H", | ||||
| 	[0x09] = "I", | ||||
| 	[0x0A] = "J", | ||||
| 	[0x0B] = "K", | ||||
| 	[0x0C] = "L", | ||||
| 	[0x0D] = "M", | ||||
| 	[0x0E] = "N", | ||||
| 	[0x0F] = "O", | ||||
| 	[0x10] = "P", | ||||
| 	[0x11] = "Q", | ||||
| 	[0x12] = "R", | ||||
| 	[0x13] = "S", | ||||
| 	[0x14] = "T", | ||||
| 	[0x15] = "U", | ||||
| 	[0x16] = "V", | ||||
| 	[0x17] = "W", | ||||
| 	[0x18] = "X", | ||||
| 	[0x19] = "Y", | ||||
| 	[0x1A] = "Z", | ||||
| 	 | ||||
| 	[0x1B] = "0", | ||||
| 	[0x1C] = "1", | ||||
| 	[0x1D] = "2", | ||||
| 	[0x1E] = "3", | ||||
| 	[0x1F] = "4", | ||||
| 	[0x20] = "5", | ||||
| 	[0x21] = "6", | ||||
| 	[0x22] = "7", | ||||
| 	[0x23] = "8", | ||||
| 	[0x24] = "9", | ||||
| 	 | ||||
| 	[0x25] = "bang", | ||||
| 	[0x26] = "at", | ||||
| 	[0x27] = "pound", | ||||
| 	[0x28] = "dollar", | ||||
| 	[0x29] = "percent", | ||||
| 	[0x2A] = "caret", | ||||
| 	[0x2B] = "and", | ||||
| 	[0x2C] = "asterisk", | ||||
| 	[0x2D] = "minus", | ||||
| 	[0x2E] = "equals", | ||||
| 	[0x2F] = "plus", | ||||
| 	[0x30] = "apostrophe", | ||||
| 	[0x31] = "less_than", | ||||
| 	[0x32] = "greater_than", | ||||
| 	[0x33] = "period", | ||||
| 	[0x34] = "qmark", | ||||
| 	 | ||||
| 	[0x35] = "apostrophe2", | ||||
| 	[0x36] = "colon", | ||||
| 	[0x37] = "comma", | ||||
| 	[0x38] = "curlybracketright", | ||||
| 	[0x39] = "curlybracketleft", | ||||
| 	[0x3A] = "currencysign", | ||||
| 	[0x3B] = "euro", | ||||
| 	[0x3C] = "onehalf", | ||||
| 	[0x3D] = "poundsymbol", | ||||
| 	[0x3E] = "roundbracketright", | ||||
| 	[0x3F] = "roundbracketleft", | ||||
| 	[0x40] = "slashleft", | ||||
| 	[0x41] = "slashright", | ||||
| 	[0x42] = "squarebracketright", | ||||
| 	[0x43] = "squarebracketleft", | ||||
| 	[0x44] = "tilde", | ||||
| 	[0x45] = "umlaut", | ||||
| 	[0x46] = "underscore", | ||||
| 	[0x47] = "verticalbar", | ||||
| } | ||||
|  | ||||
| return function(gate) | ||||
| 	gate.tickStarted = 0 | ||||
| end | ||||
|   | ||||
| @@ -1,124 +1,124 @@ | ||||
|  | ||||
| if($Pref::Server::LuaLogic::OPT_TICK_ENABLED $= "") $Pref::Server::LuaLogic::OPT_TICK_ENABLED = true; | ||||
| if($Pref::Server::LuaLogic::OPT_TICK_TIME    $= "") $Pref::Server::LuaLogic::OPT_TICK_TIME    = 0; | ||||
| if($Pref::Server::LuaLogic::OPT_FX_UPDATES   $= "") $Pref::Server::LuaLogic::OPT_FX_UPDATES   = true; | ||||
| if($Pref::Server::LuaLogic::OPT_FX_TIME      $= "") $Pref::Server::LuaLogic::OPT_FX_TIME      = 0.03; | ||||
|  | ||||
| exec("./utilities.cs"); | ||||
| exec("./tcp.cs"); | ||||
| exec("./bricks.cs"); | ||||
| exec("./brickdata.cs"); | ||||
| exec("./cmds.cs"); | ||||
|  | ||||
| function lualogic_loadprintsandcolors() | ||||
| { | ||||
| 	lualogic_definecolor("RED"  , "1 0 0 1"); | ||||
| 	lualogic_definecolor("GREEN", "0 1 0 1"); | ||||
| 	 | ||||
| 	lualogic_defineprint("ARROW"    , "Add-Ons/Print_Logic_Default/prints/arrow.png"); | ||||
| 	lualogic_defineprint("UPARROW"  , "Add-Ons/Print_Logic_Default/prints/uparrow.png"); | ||||
| 	lualogic_defineprint("DOWNARROW", "Add-Ons/Print_Logic_Default/prints/downarrow.png"); | ||||
| 	 | ||||
| 	for(%i = 0; %i < 8; %i++) | ||||
| 	{ | ||||
| 		%a = (%i >> 2) & 1; | ||||
| 		%b = (%i >> 1) & 1; | ||||
| 		%c = (%i >> 0) & 1; | ||||
| 		lualogic_defineprint("COLOR" @ %a @ %b @ %c, "Add-Ons/Print_Logic_Default/prints/color_" @ %a @ %b @ %c @ ".png"); | ||||
| 	} | ||||
| 	 | ||||
| 	lualogic_defineprint("space"             , "Add-Ons/Print_Letters_Default/prints/-space.png"           ); | ||||
| 	 | ||||
| 	lualogic_defineprint("A"                 , "Add-Ons/Print_Letters_Default/prints/A.png"                ); | ||||
| 	lualogic_defineprint("B"                 , "Add-Ons/Print_Letters_Default/prints/B.png"                ); | ||||
| 	lualogic_defineprint("C"                 , "Add-Ons/Print_Letters_Default/prints/C.png"                ); | ||||
| 	lualogic_defineprint("D"                 , "Add-Ons/Print_Letters_Default/prints/D.png"                ); | ||||
| 	lualogic_defineprint("E"                 , "Add-Ons/Print_Letters_Default/prints/E.png"                ); | ||||
| 	lualogic_defineprint("F"                 , "Add-Ons/Print_Letters_Default/prints/F.png"                ); | ||||
| 	lualogic_defineprint("G"                 , "Add-Ons/Print_Letters_Default/prints/G.png"                ); | ||||
| 	lualogic_defineprint("H"                 , "Add-Ons/Print_Letters_Default/prints/H.png"                ); | ||||
| 	lualogic_defineprint("I"                 , "Add-Ons/Print_Letters_Default/prints/I.png"                ); | ||||
| 	lualogic_defineprint("J"                 , "Add-Ons/Print_Letters_Default/prints/J.png"                ); | ||||
| 	lualogic_defineprint("K"                 , "Add-Ons/Print_Letters_Default/prints/K.png"                ); | ||||
| 	lualogic_defineprint("L"                 , "Add-Ons/Print_Letters_Default/prints/L.png"                ); | ||||
| 	lualogic_defineprint("M"                 , "Add-Ons/Print_Letters_Default/prints/M.png"                ); | ||||
| 	lualogic_defineprint("N"                 , "Add-Ons/Print_Letters_Default/prints/N.png"                ); | ||||
| 	lualogic_defineprint("O"                 , "Add-Ons/Print_Letters_Default/prints/O.png"                ); | ||||
| 	lualogic_defineprint("P"                 , "Add-Ons/Print_Letters_Default/prints/P.png"                ); | ||||
| 	lualogic_defineprint("Q"                 , "Add-Ons/Print_Letters_Default/prints/Q.png"                ); | ||||
| 	lualogic_defineprint("R"                 , "Add-Ons/Print_Letters_Default/prints/R.png"                ); | ||||
| 	lualogic_defineprint("S"                 , "Add-Ons/Print_Letters_Default/prints/S.png"                ); | ||||
| 	lualogic_defineprint("T"                 , "Add-Ons/Print_Letters_Default/prints/T.png"                ); | ||||
| 	lualogic_defineprint("U"                 , "Add-Ons/Print_Letters_Default/prints/U.png"                ); | ||||
| 	lualogic_defineprint("V"                 , "Add-Ons/Print_Letters_Default/prints/V.png"                ); | ||||
| 	lualogic_defineprint("W"                 , "Add-Ons/Print_Letters_Default/prints/W.png"                ); | ||||
| 	lualogic_defineprint("X"                 , "Add-Ons/Print_Letters_Default/prints/X.png"                ); | ||||
| 	lualogic_defineprint("Y"                 , "Add-Ons/Print_Letters_Default/prints/Y.png"                ); | ||||
| 	lualogic_defineprint("Z"                 , "Add-Ons/Print_Letters_Default/prints/Z.png"                ); | ||||
| 	 | ||||
| 	lualogic_defineprint("0"                 , "Add-Ons/Print_Letters_Default/prints/0.png"                ); | ||||
| 	lualogic_defineprint("1"                 , "Add-Ons/Print_Letters_Default/prints/1.png"                ); | ||||
| 	lualogic_defineprint("2"                 , "Add-Ons/Print_Letters_Default/prints/2.png"                ); | ||||
| 	lualogic_defineprint("3"                 , "Add-Ons/Print_Letters_Default/prints/3.png"                ); | ||||
| 	lualogic_defineprint("4"                 , "Add-Ons/Print_Letters_Default/prints/4.png"                ); | ||||
| 	lualogic_defineprint("5"                 , "Add-Ons/Print_Letters_Default/prints/5.png"                ); | ||||
| 	lualogic_defineprint("6"                 , "Add-Ons/Print_Letters_Default/prints/6.png"                ); | ||||
| 	lualogic_defineprint("7"                 , "Add-Ons/Print_Letters_Default/prints/7.png"                ); | ||||
| 	lualogic_defineprint("8"                 , "Add-Ons/Print_Letters_Default/prints/8.png"                ); | ||||
| 	lualogic_defineprint("9"                 , "Add-Ons/Print_Letters_Default/prints/9.png"                ); | ||||
| 	 | ||||
| 	lualogic_defineprint("bang"              , "Add-Ons/Print_Letters_Default/prints/-bang.png"            ); | ||||
| 	lualogic_defineprint("at"                , "Add-Ons/Print_Letters_Default/prints/-at.png"              ); | ||||
| 	lualogic_defineprint("pound"             , "Add-Ons/Print_Letters_Default/prints/-pound.png"           ); | ||||
| 	lualogic_defineprint("dollar"            , "Add-Ons/Print_Letters_Default/prints/-dollar.png"          ); | ||||
| 	lualogic_defineprint("percent"           , "Add-Ons/Print_Letters_Default/prints/-percent.png"         ); | ||||
| 	lualogic_defineprint("caret"             , "Add-Ons/Print_Letters_Default/prints/-caret.png"           ); | ||||
| 	lualogic_defineprint("and"               , "Add-Ons/Print_Letters_Default/prints/-and.png"             ); | ||||
| 	lualogic_defineprint("asterisk"          , "Add-Ons/Print_Letters_Default/prints/-asterisk.png"        ); | ||||
| 	lualogic_defineprint("minus"             , "Add-Ons/Print_Letters_Default/prints/-minus.png"           ); | ||||
| 	lualogic_defineprint("equals"            , "Add-Ons/Print_Letters_Default/prints/-equals.png"          ); | ||||
| 	lualogic_defineprint("plus"              , "Add-Ons/Print_Letters_Default/prints/-plus.png"            ); | ||||
| 	lualogic_defineprint("apostrophe"        , "Add-Ons/Print_Letters_Default/prints/-apostrophe.png"      ); | ||||
| 	lualogic_defineprint("less_than"         , "Add-Ons/Print_Letters_Default/prints/-less_than.png"       ); | ||||
| 	lualogic_defineprint("greater_than"      , "Add-Ons/Print_Letters_Default/prints/-greater_than.png"    ); | ||||
| 	lualogic_defineprint("period"            , "Add-Ons/Print_Letters_Default/prints/-period.png"          ); | ||||
| 	lualogic_defineprint("qmark"             , "Add-Ons/Print_Letters_Default/prints/-qmark.png"           ); | ||||
| 	 | ||||
| 	lualogic_defineprint("apostrophe2"       , "Add-Ons/Print_Letters_Extra/prints/-apostrophe2.png"       ); | ||||
| 	lualogic_defineprint("colon"             , "Add-Ons/Print_Letters_Extra/prints/-colon.png"             ); | ||||
| 	lualogic_defineprint("comma"             , "Add-Ons/Print_Letters_Extra/prints/-comma.png"             ); | ||||
| 	lualogic_defineprint("curlybracketleft"  , "Add-Ons/Print_Letters_Extra/prints/-curlybracketleft.png"  ); | ||||
| 	lualogic_defineprint("curlybracketright" , "Add-Ons/Print_Letters_Extra/prints/-curlybracketright.png" ); | ||||
| 	lualogic_defineprint("currencysign"      , "Add-Ons/Print_Letters_Extra/prints/-currencysign.png"      ); | ||||
| 	lualogic_defineprint("euro"              , "Add-Ons/Print_Letters_Extra/prints/-euro.png"              ); | ||||
| 	lualogic_defineprint("onehalf"           , "Add-Ons/Print_Letters_Extra/prints/-onehalf.png"           ); | ||||
| 	lualogic_defineprint("poundsymbol"       , "Add-Ons/Print_Letters_Extra/prints/-poundsymbol.png"       ); | ||||
| 	lualogic_defineprint("roundbracketleft"  , "Add-Ons/Print_Letters_Extra/prints/-roundbracketleft.png"  ); | ||||
| 	lualogic_defineprint("roundbracketright" , "Add-Ons/Print_Letters_Extra/prints/-roundbracketright.png" ); | ||||
| 	lualogic_defineprint("slashleft"         , "Add-Ons/Print_Letters_Extra/prints/-slashleft.png"         ); | ||||
| 	lualogic_defineprint("slashright"        , "Add-Ons/Print_Letters_Extra/prints/-slashright.png"        ); | ||||
| 	lualogic_defineprint("squarebracketleft" , "Add-Ons/Print_Letters_Extra/prints/-squarebracketleft.png" ); | ||||
| 	lualogic_defineprint("squarebracketright", "Add-Ons/Print_Letters_Extra/prints/-squarebracketright.png"); | ||||
| 	lualogic_defineprint("tilde"             , "Add-Ons/Print_Letters_Extra/prints/-tilde.png"             ); | ||||
| 	lualogic_defineprint("umlaut"            , "Add-Ons/Print_Letters_Extra/prints/-umlaut.png"            ); | ||||
| 	lualogic_defineprint("underscore"        , "Add-Ons/Print_Letters_Extra/prints/-underscore.png"        ); | ||||
| 	lualogic_defineprint("verticalbar"       , "Add-Ons/Print_Letters_Extra/prints/-verticalbar.png"       ); | ||||
| } | ||||
| schedule(0, 0, "lualogic_loadprintsandcolors"); | ||||
|  | ||||
| package LuaLogic | ||||
| { | ||||
| 	function onServerDestroyed() | ||||
| 	{ | ||||
| 		deleteVariables("$LuaLogic*"); | ||||
| 		parent::onServerDestroyed(); | ||||
| 	} | ||||
| }; | ||||
| activatePackage("LuaLogic"); | ||||
|  | ||||
| function llr(){ | ||||
| 	deleteVariables("$LuaLogic*"); | ||||
| 	resetAllOpCallFunc(); | ||||
| 	exec("./server.cs"); | ||||
| 	schedule(3000, 0, lualogic_connect, 25000); | ||||
| } | ||||
|  | ||||
| if($Pref::Server::LuaLogic::OPT_TICK_ENABLED $= "") $Pref::Server::LuaLogic::OPT_TICK_ENABLED = true; | ||||
| if($Pref::Server::LuaLogic::OPT_TICK_TIME    $= "") $Pref::Server::LuaLogic::OPT_TICK_TIME    = 0; | ||||
| if($Pref::Server::LuaLogic::OPT_FX_UPDATES   $= "") $Pref::Server::LuaLogic::OPT_FX_UPDATES   = true; | ||||
| if($Pref::Server::LuaLogic::OPT_FX_TIME      $= "") $Pref::Server::LuaLogic::OPT_FX_TIME      = 0.03; | ||||
|  | ||||
| exec("./utilities.cs"); | ||||
| exec("./tcp.cs"); | ||||
| exec("./bricks.cs"); | ||||
| exec("./brickdata.cs"); | ||||
| exec("./cmds.cs"); | ||||
|  | ||||
| function lualogic_loadprintsandcolors() | ||||
| { | ||||
| 	lualogic_definecolor("RED"  , "1 0 0 1"); | ||||
| 	lualogic_definecolor("GREEN", "0 1 0 1"); | ||||
| 	 | ||||
| 	lualogic_defineprint("ARROW"    , "Add-Ons/Print_Logic_Default/prints/arrow.png"); | ||||
| 	lualogic_defineprint("UPARROW"  , "Add-Ons/Print_Logic_Default/prints/uparrow.png"); | ||||
| 	lualogic_defineprint("DOWNARROW", "Add-Ons/Print_Logic_Default/prints/downarrow.png"); | ||||
| 	 | ||||
| 	for(%i = 0; %i < 8; %i++) | ||||
| 	{ | ||||
| 		%a = (%i >> 2) & 1; | ||||
| 		%b = (%i >> 1) & 1; | ||||
| 		%c = (%i >> 0) & 1; | ||||
| 		lualogic_defineprint("COLOR" @ %a @ %b @ %c, "Add-Ons/Print_Logic_Default/prints/color_" @ %a @ %b @ %c @ ".png"); | ||||
| 	} | ||||
| 	 | ||||
| 	lualogic_defineprint("space"             , "Add-Ons/Print_Letters_Default/prints/-space.png"           ); | ||||
| 	 | ||||
| 	lualogic_defineprint("A"                 , "Add-Ons/Print_Letters_Default/prints/A.png"                ); | ||||
| 	lualogic_defineprint("B"                 , "Add-Ons/Print_Letters_Default/prints/B.png"                ); | ||||
| 	lualogic_defineprint("C"                 , "Add-Ons/Print_Letters_Default/prints/C.png"                ); | ||||
| 	lualogic_defineprint("D"                 , "Add-Ons/Print_Letters_Default/prints/D.png"                ); | ||||
| 	lualogic_defineprint("E"                 , "Add-Ons/Print_Letters_Default/prints/E.png"                ); | ||||
| 	lualogic_defineprint("F"                 , "Add-Ons/Print_Letters_Default/prints/F.png"                ); | ||||
| 	lualogic_defineprint("G"                 , "Add-Ons/Print_Letters_Default/prints/G.png"                ); | ||||
| 	lualogic_defineprint("H"                 , "Add-Ons/Print_Letters_Default/prints/H.png"                ); | ||||
| 	lualogic_defineprint("I"                 , "Add-Ons/Print_Letters_Default/prints/I.png"                ); | ||||
| 	lualogic_defineprint("J"                 , "Add-Ons/Print_Letters_Default/prints/J.png"                ); | ||||
| 	lualogic_defineprint("K"                 , "Add-Ons/Print_Letters_Default/prints/K.png"                ); | ||||
| 	lualogic_defineprint("L"                 , "Add-Ons/Print_Letters_Default/prints/L.png"                ); | ||||
| 	lualogic_defineprint("M"                 , "Add-Ons/Print_Letters_Default/prints/M.png"                ); | ||||
| 	lualogic_defineprint("N"                 , "Add-Ons/Print_Letters_Default/prints/N.png"                ); | ||||
| 	lualogic_defineprint("O"                 , "Add-Ons/Print_Letters_Default/prints/O.png"                ); | ||||
| 	lualogic_defineprint("P"                 , "Add-Ons/Print_Letters_Default/prints/P.png"                ); | ||||
| 	lualogic_defineprint("Q"                 , "Add-Ons/Print_Letters_Default/prints/Q.png"                ); | ||||
| 	lualogic_defineprint("R"                 , "Add-Ons/Print_Letters_Default/prints/R.png"                ); | ||||
| 	lualogic_defineprint("S"                 , "Add-Ons/Print_Letters_Default/prints/S.png"                ); | ||||
| 	lualogic_defineprint("T"                 , "Add-Ons/Print_Letters_Default/prints/T.png"                ); | ||||
| 	lualogic_defineprint("U"                 , "Add-Ons/Print_Letters_Default/prints/U.png"                ); | ||||
| 	lualogic_defineprint("V"                 , "Add-Ons/Print_Letters_Default/prints/V.png"                ); | ||||
| 	lualogic_defineprint("W"                 , "Add-Ons/Print_Letters_Default/prints/W.png"                ); | ||||
| 	lualogic_defineprint("X"                 , "Add-Ons/Print_Letters_Default/prints/X.png"                ); | ||||
| 	lualogic_defineprint("Y"                 , "Add-Ons/Print_Letters_Default/prints/Y.png"                ); | ||||
| 	lualogic_defineprint("Z"                 , "Add-Ons/Print_Letters_Default/prints/Z.png"                ); | ||||
| 	 | ||||
| 	lualogic_defineprint("0"                 , "Add-Ons/Print_Letters_Default/prints/0.png"                ); | ||||
| 	lualogic_defineprint("1"                 , "Add-Ons/Print_Letters_Default/prints/1.png"                ); | ||||
| 	lualogic_defineprint("2"                 , "Add-Ons/Print_Letters_Default/prints/2.png"                ); | ||||
| 	lualogic_defineprint("3"                 , "Add-Ons/Print_Letters_Default/prints/3.png"                ); | ||||
| 	lualogic_defineprint("4"                 , "Add-Ons/Print_Letters_Default/prints/4.png"                ); | ||||
| 	lualogic_defineprint("5"                 , "Add-Ons/Print_Letters_Default/prints/5.png"                ); | ||||
| 	lualogic_defineprint("6"                 , "Add-Ons/Print_Letters_Default/prints/6.png"                ); | ||||
| 	lualogic_defineprint("7"                 , "Add-Ons/Print_Letters_Default/prints/7.png"                ); | ||||
| 	lualogic_defineprint("8"                 , "Add-Ons/Print_Letters_Default/prints/8.png"                ); | ||||
| 	lualogic_defineprint("9"                 , "Add-Ons/Print_Letters_Default/prints/9.png"                ); | ||||
| 	 | ||||
| 	lualogic_defineprint("bang"              , "Add-Ons/Print_Letters_Default/prints/-bang.png"            ); | ||||
| 	lualogic_defineprint("at"                , "Add-Ons/Print_Letters_Default/prints/-at.png"              ); | ||||
| 	lualogic_defineprint("pound"             , "Add-Ons/Print_Letters_Default/prints/-pound.png"           ); | ||||
| 	lualogic_defineprint("dollar"            , "Add-Ons/Print_Letters_Default/prints/-dollar.png"          ); | ||||
| 	lualogic_defineprint("percent"           , "Add-Ons/Print_Letters_Default/prints/-percent.png"         ); | ||||
| 	lualogic_defineprint("caret"             , "Add-Ons/Print_Letters_Default/prints/-caret.png"           ); | ||||
| 	lualogic_defineprint("and"               , "Add-Ons/Print_Letters_Default/prints/-and.png"             ); | ||||
| 	lualogic_defineprint("asterisk"          , "Add-Ons/Print_Letters_Default/prints/-asterisk.png"        ); | ||||
| 	lualogic_defineprint("minus"             , "Add-Ons/Print_Letters_Default/prints/-minus.png"           ); | ||||
| 	lualogic_defineprint("equals"            , "Add-Ons/Print_Letters_Default/prints/-equals.png"          ); | ||||
| 	lualogic_defineprint("plus"              , "Add-Ons/Print_Letters_Default/prints/-plus.png"            ); | ||||
| 	lualogic_defineprint("apostrophe"        , "Add-Ons/Print_Letters_Default/prints/-apostrophe.png"      ); | ||||
| 	lualogic_defineprint("less_than"         , "Add-Ons/Print_Letters_Default/prints/-less_than.png"       ); | ||||
| 	lualogic_defineprint("greater_than"      , "Add-Ons/Print_Letters_Default/prints/-greater_than.png"    ); | ||||
| 	lualogic_defineprint("period"            , "Add-Ons/Print_Letters_Default/prints/-period.png"          ); | ||||
| 	lualogic_defineprint("qmark"             , "Add-Ons/Print_Letters_Default/prints/-qmark.png"           ); | ||||
| 	 | ||||
| 	lualogic_defineprint("apostrophe2"       , "Add-Ons/Print_Letters_Extra/prints/-apostrophe2.png"       ); | ||||
| 	lualogic_defineprint("colon"             , "Add-Ons/Print_Letters_Extra/prints/-colon.png"             ); | ||||
| 	lualogic_defineprint("comma"             , "Add-Ons/Print_Letters_Extra/prints/-comma.png"             ); | ||||
| 	lualogic_defineprint("curlybracketleft"  , "Add-Ons/Print_Letters_Extra/prints/-curlybracketleft.png"  ); | ||||
| 	lualogic_defineprint("curlybracketright" , "Add-Ons/Print_Letters_Extra/prints/-curlybracketright.png" ); | ||||
| 	lualogic_defineprint("currencysign"      , "Add-Ons/Print_Letters_Extra/prints/-currencysign.png"      ); | ||||
| 	lualogic_defineprint("euro"              , "Add-Ons/Print_Letters_Extra/prints/-euro.png"              ); | ||||
| 	lualogic_defineprint("onehalf"           , "Add-Ons/Print_Letters_Extra/prints/-onehalf.png"           ); | ||||
| 	lualogic_defineprint("poundsymbol"       , "Add-Ons/Print_Letters_Extra/prints/-poundsymbol.png"       ); | ||||
| 	lualogic_defineprint("roundbracketleft"  , "Add-Ons/Print_Letters_Extra/prints/-roundbracketleft.png"  ); | ||||
| 	lualogic_defineprint("roundbracketright" , "Add-Ons/Print_Letters_Extra/prints/-roundbracketright.png" ); | ||||
| 	lualogic_defineprint("slashleft"         , "Add-Ons/Print_Letters_Extra/prints/-slashleft.png"         ); | ||||
| 	lualogic_defineprint("slashright"        , "Add-Ons/Print_Letters_Extra/prints/-slashright.png"        ); | ||||
| 	lualogic_defineprint("squarebracketleft" , "Add-Ons/Print_Letters_Extra/prints/-squarebracketleft.png" ); | ||||
| 	lualogic_defineprint("squarebracketright", "Add-Ons/Print_Letters_Extra/prints/-squarebracketright.png"); | ||||
| 	lualogic_defineprint("tilde"             , "Add-Ons/Print_Letters_Extra/prints/-tilde.png"             ); | ||||
| 	lualogic_defineprint("umlaut"            , "Add-Ons/Print_Letters_Extra/prints/-umlaut.png"            ); | ||||
| 	lualogic_defineprint("underscore"        , "Add-Ons/Print_Letters_Extra/prints/-underscore.png"        ); | ||||
| 	lualogic_defineprint("verticalbar"       , "Add-Ons/Print_Letters_Extra/prints/-verticalbar.png"       ); | ||||
| } | ||||
| schedule(0, 0, "lualogic_loadprintsandcolors"); | ||||
|  | ||||
| package LuaLogic | ||||
| { | ||||
| 	function onServerDestroyed() | ||||
| 	{ | ||||
| 		deleteVariables("$LuaLogic*"); | ||||
| 		parent::onServerDestroyed(); | ||||
| 	} | ||||
| }; | ||||
| activatePackage("LuaLogic"); | ||||
|  | ||||
| function llr(){ | ||||
| 	deleteVariables("$LuaLogic*"); | ||||
| 	resetAllOpCallFunc(); | ||||
| 	exec("./lualogic.cs"); | ||||
| 	schedule(3000, 0, lualogic_connect, 25000); | ||||
| } | ||||
|   | ||||
| @@ -1,221 +1,242 @@ | ||||
|  | ||||
| function lualogic_escapelogicfunction(%text){ | ||||
| 	%text = strReplace(%text, "\\", "\\/"); | ||||
| 	 | ||||
| 	%text = strReplace(%text, "\r", "\\r"); | ||||
| 	%text = strReplace(%text, "\n", "\\n"); | ||||
| 	%text = strReplace(%text, "\t", "\\t"); | ||||
| 	%text = strReplace(%text, ";" , "\\:"); | ||||
| 	 | ||||
| 	return %text; | ||||
| } | ||||
|  | ||||
| function lualogic_registergatedefinition(%data) | ||||
| { | ||||
| 	if(!isObject(%data)) | ||||
| 		return; | ||||
| 	%id = %data.getID(); | ||||
| 	 | ||||
| 	if((%idx = $LuaLogic::GateDefinitionIDX[%id]) $= "") | ||||
| 	{ | ||||
| 		%idx = $LuaLogic::NumGateDefintions+0; | ||||
| 		$LuaLogic::GateDefinitionIDX[%id] = %idx; | ||||
| 		$LuaLogic::NumGateDefintions++; | ||||
| 	} | ||||
|  | ||||
| 	%def = %id @ ";" @ | ||||
| 		%data.logicUIName @ ";" @ | ||||
| 		%data.logicUIDesc @ ";" @ | ||||
| 		lualogic_escapelogicfunction(%data.logicInit) @ ";" @ | ||||
| 		lualogic_escapelogicfunction(%data.logicUpdate) @ ";" @ | ||||
| 		lualogic_escapelogicfunction(%data.logicInput) @ ";" @ | ||||
| 		(%ports = %data.numLogicPorts) | ||||
| 	; | ||||
| 	 | ||||
| 	for(%i = 0; %i < %ports; %i++) | ||||
| 	{ | ||||
| 		%def = %def @";"@ %data.logicPortType[%i] @";"@ %data.logicPortPos[%i] @";"@ %data.logicPortDir[%i] | ||||
| 				@";"@ (%data.logicPortCauseUpdate[%i] == true) @";"@ %data.logicPortUIName[%i]; | ||||
| 	} | ||||
|  | ||||
| 	$LuaLogic::GateDefintion[%idx] = %def; | ||||
| } | ||||
|  | ||||
| function lualogic_print(%text) | ||||
| { | ||||
| 	echo("LuaLogic -> ", %text); | ||||
| } | ||||
|  | ||||
| function lualogic_roundpos(%pos) | ||||
| { | ||||
| 	return mFloor(getWord(%pos, 0)*4)/4 SPC mFloor(getWord(%pos, 1)*4)/4 SPC mFloor(getWord(%pos, 2)*10)/10; | ||||
| } | ||||
|  | ||||
| function lualogic_roundstudpos(%pos) | ||||
| { | ||||
| 	return mFloor(getWord(%pos, 0)*2)/2 SPC mFloor(getWord(%pos, 1)*2)/2 SPC mFloor(getWord(%pos, 2)*5)/5; | ||||
| } | ||||
|  | ||||
| function lualogic_pos(%pos) | ||||
| { | ||||
| 	%pos = lualogic_roundpos(%pos); | ||||
| 	return getWord(%pos, 0)/0.25 SPC getWord(%pos, 1)/0.25 SPC getWord(%pos, 2)/0.1; | ||||
| } | ||||
|  | ||||
| function lualogic_studpos(%pos) | ||||
| { | ||||
| 	%pos = lualogic_roundstudpos(%pos); | ||||
| 	return getWord(%pos, 0)/0.5*2 + 1 SPC getWord(%pos, 1)/0.5*2 + 1 SPC getWord(%pos, 2)/0.2*2; | ||||
| } | ||||
|  | ||||
| function lualogic_postobrick(%pos) | ||||
| { | ||||
| 	return getWord(%pos, 0)*0.25 SPC getWord(%pos, 1)*0.25 SPC getWord(%pos, 2)*0.1; | ||||
| } | ||||
|  | ||||
| function lualogic_connect(%port) | ||||
| { | ||||
| 	if(isObject(LuaLogicTCP)) | ||||
| 		LuaLogicTCP.delete(); | ||||
| 	%tcp = new TCPObject(LuaLogicTCP); | ||||
| 	%tcp.connect("127.0.0.1:" @ %port); | ||||
| } | ||||
|  | ||||
| function lualogic_send(%data) | ||||
| { | ||||
| 	if(isObject(LuaLogicTCP) && LuaLogicTCP.isConnected) | ||||
| 	{ | ||||
| 		while(strpos(%data, ";;") != -1) | ||||
| 			%data = strReplace(%data, ";;", "; ;"); | ||||
| 		 | ||||
| 		if(strlen(LuaLogicTCP.data) + strlen(%data) >= 1024) | ||||
| 			LuaLogicTCP.sendData(); | ||||
| 		 | ||||
| 		if(LuaLogicTCP.data $= "") | ||||
| 			LuaLogicTCP.data = %data; | ||||
| 		else | ||||
| 			LuaLogicTCP.data = LuaLogicTCP.data @ ";" @ %data; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| function lualogic_sendgatedefinitions() | ||||
| { | ||||
| 	for(%i = 0; %i < $LuaLogic::NumGateDefintions; %i++) | ||||
| 		lualogic_send("GD;" @ $LuaLogic::GateDefintion[%i]); | ||||
| } | ||||
|  | ||||
| function lualogic_sendoptions() | ||||
| { | ||||
| 	lualogic_send("OPT;TICK_ENABLED;"	@ $Pref::Server::LuaLogic::OPT_TICK_ENABLED); | ||||
| 	lualogic_send("OPT;TICK_TIME;"		@ $Pref::Server::LuaLogic::OPT_TICK_TIME); | ||||
| 	lualogic_send("OPT;FX_UPDATES;"		@ $Pref::Server::LuaLogic::OPT_FX_UPDATES); | ||||
| 	lualogic_send("OPT;FX_TIME;"		@ $Pref::Server::LuaLogic::OPT_FX_TIME); | ||||
| } | ||||
|  | ||||
| function lualogic_sendinput(%gate, %argc, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15) | ||||
| { | ||||
| 	%args = %arg0; | ||||
| 	for(%i = 1; %i < %argc; %i++) | ||||
| 		%args = %args @ ";" @ %arg[%i]; | ||||
| 	 | ||||
| 	if(%argc > 0) | ||||
| 		lualogic_send("IN;" @ %gate.getID() @ ";" @ %argc @ ";" @ %args); | ||||
| 	else | ||||
| 		lualogic_send("IN;" @ %gate.getID() @ ";" @ %argc); | ||||
| } | ||||
|  | ||||
| function lualogic_ss(%obj, %state) | ||||
| { | ||||
| 	lualogic_send("SG;" @ %obj @ ";" @ (%state == true)); | ||||
| } | ||||
|  | ||||
| function lualogic_definecolor(%color, %rgb, %allowTransparency) | ||||
| { | ||||
| 	%r = getWord(%rgb, 0); | ||||
| 	%g = getWord(%rgb, 1); | ||||
| 	%b = getWord(%rgb, 2); | ||||
|  | ||||
| 	%alpha = %allowTransparency ? 0.001 : 1; | ||||
|  | ||||
| 	%bestDist = 9e9; | ||||
|  | ||||
| 	for(%i = 0; %i < 64; %i++) | ||||
| 	{ | ||||
| 		%crgba = getColorIDTable(%i); | ||||
| 		if(getWord(%crgba, 3) >= %alpha) | ||||
| 		{ | ||||
| 			%dr = getWord(%crgba, 0) - %r; | ||||
| 			%dg = getWord(%crgba, 1) - %g; | ||||
| 			%db = getWord(%crgba, 2) - %b; | ||||
| 			%dist = %dr*%dr + %dg*%dg + %db*%db; | ||||
|  | ||||
| 			if(%dist < %bestDist) | ||||
| 			{ | ||||
| 				%bestDist = %dist; | ||||
| 				%bestColor = %i; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$LuaLogic::Color[%color] = %bestColor; | ||||
| 	return %bestColor; | ||||
| } | ||||
|  | ||||
| function lualogic_iscolor(%color) | ||||
| { | ||||
| 	return $LuaLogic::Color[%color] !$= ""; | ||||
| } | ||||
|  | ||||
| function lualogic_getcolor(%color) | ||||
| { | ||||
| 	if($LuaLogic::Color[%color] !$= "") | ||||
| 		return $LuaLogic::Color[%color]; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| function lualogic_defineprint(%print, %file) | ||||
| { | ||||
| 	%count = getNumPrintTextures(); | ||||
| 	for(%i = 0; %i < %count; %i++) | ||||
| 	{ | ||||
| 		if(getPrintTexture(%i) $= %file) | ||||
| 		{ | ||||
| 			$LuaLogic::Print[%print] = %i; | ||||
| 			return %i; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return ""; | ||||
| } | ||||
|  | ||||
| function lualogic_isprint(%print) | ||||
| { | ||||
| 	return $LuaLogic::Print[%print] !$= ""; | ||||
| } | ||||
|  | ||||
| function lualogic_getprint(%print) | ||||
| { | ||||
| 	if($LuaLogic::Print[%print] !$= "") | ||||
| 		return $LuaLogic::Print[%print]; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| function lualogic_readfile(%filename){ | ||||
| 	%filestr=""; | ||||
| 	 | ||||
| 	%file=new FileObject(); | ||||
| 	%success=%file.openForRead(%filename); | ||||
| 	 | ||||
| 	if(%success){ | ||||
| 		while(!%file.isEOF()){ | ||||
| 			%line = %file.readLine(); | ||||
| 			%filestr = %filestr @ %line @ "\n"; | ||||
| 		} | ||||
| 	}else{ | ||||
| 		echo("LuaLogic: Failed to read file \"" @ %filename @ "\""); | ||||
| 	} | ||||
| 	%file.close(); | ||||
| 	%file.delete(); | ||||
| 	 | ||||
| 	return %filestr; | ||||
| } | ||||
|  | ||||
| function lualogic_escapelogicfunction(%text){ | ||||
| 	%text = strReplace(%text, "\\", "\\/"); | ||||
| 	 | ||||
| 	%text = strReplace(%text, "\r", "\\r"); | ||||
| 	%text = strReplace(%text, "\n", "\\n"); | ||||
| 	%text = strReplace(%text, "\t", "\\t"); | ||||
| 	%text = strReplace(%text, ";" , "\\:"); | ||||
| 	 | ||||
| 	return %text; | ||||
| } | ||||
|  | ||||
| function lualogic_registergatedefinition(%data){ | ||||
| 	lualogic_registergatedefinition_auto(%data); | ||||
| } | ||||
|  | ||||
| function lualogic_registergatedefinition_auto(%data) | ||||
| { | ||||
| 	if(!isObject(%data)) | ||||
| 		return; | ||||
| 	 | ||||
| 	if(%data.luaLogic_isRegistered) | ||||
| 		return; | ||||
| 	 | ||||
| 	%id = %data.getID(); | ||||
| 	 | ||||
| 	if((%idx = $LuaLogic::GateDefinitionIDX[%id]) $= "") | ||||
| 	{ | ||||
| 		%idx = $LuaLogic::NumGateDefintions+0; | ||||
| 		$LuaLogic::GateDefinitionIDX[%id] = %idx; | ||||
| 		$LuaLogic::NumGateDefintions++; | ||||
| 	} | ||||
|  | ||||
| 	%def = %id @ ";" @ | ||||
| 		%data.logicUIName @ ";" @ | ||||
| 		%data.logicUIDesc @ ";" @ | ||||
| 		lualogic_escapelogicfunction(%data.logicInit) @ ";" @ | ||||
| 		lualogic_escapelogicfunction(%data.logicUpdate) @ ";" @ | ||||
| 		lualogic_escapelogicfunction(%data.logicInput) @ ";" @ | ||||
| 		(%ports = %data.numLogicPorts) | ||||
| 	; | ||||
| 	 | ||||
| 	for(%i = 0; %i < %ports; %i++) | ||||
| 	{ | ||||
| 		%def = %def @";"@ %data.logicPortType[%i] @";"@ %data.logicPortPos[%i] @";"@ %data.logicPortDir[%i] | ||||
| 				@";"@ (%data.logicPortCauseUpdate[%i] == true) @";"@ %data.logicPortUIName[%i]; | ||||
| 	} | ||||
|  | ||||
| 	$LuaLogic::GateDefintion[%idx] = %def; | ||||
| 	 | ||||
| 	%data.luaLogic_isRegistered = true; | ||||
| } | ||||
|  | ||||
| function lualogic_registerAllGateDefinitions(){ | ||||
| 	for(%dbidx=0; %dbidx<DatablockGroup.getCount(); %dbidx++){ | ||||
| 		%db = DatablockGroup.getObject(%dbidx); | ||||
| 		if(%db.isLogic && %db.isLogicGate){ | ||||
| 			lualogic_registergatedefinition_auto(%db); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| lualogic_registerAllGateDefinitions(); | ||||
|  | ||||
| function lualogic_print(%text) | ||||
| { | ||||
| 	echo("LuaLogic -> ", %text); | ||||
| } | ||||
|  | ||||
| function lualogic_roundpos(%pos) | ||||
| { | ||||
| 	return mFloor(getWord(%pos, 0)*4)/4 SPC mFloor(getWord(%pos, 1)*4)/4 SPC mFloor(getWord(%pos, 2)*10)/10; | ||||
| } | ||||
|  | ||||
| function lualogic_roundstudpos(%pos) | ||||
| { | ||||
| 	return mFloor(getWord(%pos, 0)*2)/2 SPC mFloor(getWord(%pos, 1)*2)/2 SPC mFloor(getWord(%pos, 2)*5)/5; | ||||
| } | ||||
|  | ||||
| function lualogic_pos(%pos) | ||||
| { | ||||
| 	%pos = lualogic_roundpos(%pos); | ||||
| 	return getWord(%pos, 0)/0.25 SPC getWord(%pos, 1)/0.25 SPC getWord(%pos, 2)/0.1; | ||||
| } | ||||
|  | ||||
| function lualogic_studpos(%pos) | ||||
| { | ||||
| 	%pos = lualogic_roundstudpos(%pos); | ||||
| 	return getWord(%pos, 0)/0.5*2 + 1 SPC getWord(%pos, 1)/0.5*2 + 1 SPC getWord(%pos, 2)/0.2*2; | ||||
| } | ||||
|  | ||||
| function lualogic_postobrick(%pos) | ||||
| { | ||||
| 	return getWord(%pos, 0)*0.25 SPC getWord(%pos, 1)*0.25 SPC getWord(%pos, 2)*0.1; | ||||
| } | ||||
|  | ||||
| function lualogic_connect(%port) | ||||
| { | ||||
| 	if(isObject(LuaLogicTCP)) | ||||
| 		LuaLogicTCP.delete(); | ||||
| 	%tcp = new TCPObject(LuaLogicTCP); | ||||
| 	%tcp.connect("127.0.0.1:" @ %port); | ||||
| } | ||||
|  | ||||
| function lualogic_send(%data) | ||||
| { | ||||
| 	if(isObject(LuaLogicTCP) && LuaLogicTCP.isConnected) | ||||
| 	{ | ||||
| 		while(strpos(%data, ";;") != -1) | ||||
| 			%data = strReplace(%data, ";;", "; ;"); | ||||
| 		 | ||||
| 		if(strlen(LuaLogicTCP.data) + strlen(%data) >= 1024) | ||||
| 			LuaLogicTCP.sendData(); | ||||
| 		 | ||||
| 		if(LuaLogicTCP.data $= "") | ||||
| 			LuaLogicTCP.data = %data; | ||||
| 		else | ||||
| 			LuaLogicTCP.data = LuaLogicTCP.data @ ";" @ %data; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| function lualogic_sendgatedefinitions() | ||||
| { | ||||
| 	for(%i = 0; %i < $LuaLogic::NumGateDefintions; %i++) | ||||
| 		lualogic_send("GD;" @ $LuaLogic::GateDefintion[%i]); | ||||
| } | ||||
|  | ||||
| function lualogic_sendoptions() | ||||
| { | ||||
| 	lualogic_send("OPT;TICK_ENABLED;"	@ $Pref::Server::LuaLogic::OPT_TICK_ENABLED); | ||||
| 	lualogic_send("OPT;TICK_TIME;"		@ $Pref::Server::LuaLogic::OPT_TICK_TIME); | ||||
| 	lualogic_send("OPT;FX_UPDATES;"		@ $Pref::Server::LuaLogic::OPT_FX_UPDATES); | ||||
| 	lualogic_send("OPT;FX_TIME;"		@ $Pref::Server::LuaLogic::OPT_FX_TIME); | ||||
| } | ||||
|  | ||||
| function lualogic_sendinput(%gate, %argc, %arg0, %arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10, %arg11, %arg12, %arg13, %arg14, %arg15) | ||||
| { | ||||
| 	%args = %arg0; | ||||
| 	for(%i = 1; %i < %argc; %i++) | ||||
| 		%args = %args @ ";" @ %arg[%i]; | ||||
| 	 | ||||
| 	if(%argc > 0) | ||||
| 		lualogic_send("IN;" @ %gate.getID() @ ";" @ %argc @ ";" @ %args); | ||||
| 	else | ||||
| 		lualogic_send("IN;" @ %gate.getID() @ ";" @ %argc); | ||||
| } | ||||
|  | ||||
| function lualogic_ss(%obj, %state) | ||||
| { | ||||
| 	lualogic_send("SG;" @ %obj @ ";" @ (%state == true)); | ||||
| } | ||||
|  | ||||
| function lualogic_definecolor(%color, %rgb, %allowTransparency) | ||||
| { | ||||
| 	%r = getWord(%rgb, 0); | ||||
| 	%g = getWord(%rgb, 1); | ||||
| 	%b = getWord(%rgb, 2); | ||||
|  | ||||
| 	%alpha = %allowTransparency ? 0.001 : 1; | ||||
|  | ||||
| 	%bestDist = 9e9; | ||||
|  | ||||
| 	for(%i = 0; %i < 64; %i++) | ||||
| 	{ | ||||
| 		%crgba = getColorIDTable(%i); | ||||
| 		if(getWord(%crgba, 3) >= %alpha) | ||||
| 		{ | ||||
| 			%dr = getWord(%crgba, 0) - %r; | ||||
| 			%dg = getWord(%crgba, 1) - %g; | ||||
| 			%db = getWord(%crgba, 2) - %b; | ||||
| 			%dist = %dr*%dr + %dg*%dg + %db*%db; | ||||
|  | ||||
| 			if(%dist < %bestDist) | ||||
| 			{ | ||||
| 				%bestDist = %dist; | ||||
| 				%bestColor = %i; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	$LuaLogic::Color[%color] = %bestColor; | ||||
| 	return %bestColor; | ||||
| } | ||||
|  | ||||
| function lualogic_iscolor(%color) | ||||
| { | ||||
| 	return $LuaLogic::Color[%color] !$= ""; | ||||
| } | ||||
|  | ||||
| function lualogic_getcolor(%color) | ||||
| { | ||||
| 	if($LuaLogic::Color[%color] !$= "") | ||||
| 		return $LuaLogic::Color[%color]; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| function lualogic_defineprint(%print, %file) | ||||
| { | ||||
| 	%count = getNumPrintTextures(); | ||||
| 	for(%i = 0; %i < %count; %i++) | ||||
| 	{ | ||||
| 		if(getPrintTexture(%i) $= %file) | ||||
| 		{ | ||||
| 			$LuaLogic::Print[%print] = %i; | ||||
| 			return %i; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return ""; | ||||
| } | ||||
|  | ||||
| function lualogic_isprint(%print) | ||||
| { | ||||
| 	return $LuaLogic::Print[%print] !$= ""; | ||||
| } | ||||
|  | ||||
| function lualogic_getprint(%print) | ||||
| { | ||||
| 	if($LuaLogic::Print[%print] !$= "") | ||||
| 		return $LuaLogic::Print[%print]; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| function lualogic_readfile(%filename){ | ||||
| 	%filestr=""; | ||||
| 	 | ||||
| 	%file=new FileObject(); | ||||
| 	%success=%file.openForRead(%filename); | ||||
| 	 | ||||
| 	if(%success){ | ||||
| 		while(!%file.isEOF()){ | ||||
| 			%line = %file.readLine(); | ||||
| 			%filestr = %filestr @ %line @ "\n"; | ||||
| 		} | ||||
| 	}else{ | ||||
| 		echo("LuaLogic: Failed to read file \"" @ %filename @ "\""); | ||||
| 	} | ||||
| 	%file.close(); | ||||
| 	%file.delete(); | ||||
| 	 | ||||
| 	return %filestr; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Redo
					Redo