add rainbow wires
This commit is contained in:
parent
7922e85545
commit
4501eea02e
@ -1,21 +1,30 @@
|
||||
function lualogic_addwire(%wire)
|
||||
{
|
||||
%color = %wire.getColorID();
|
||||
|
||||
function lualogic_getlayer(%wire) {
|
||||
// -1 if the brick is rainbow, its color ID otherwise
|
||||
if(%wire.getColorFxId()==6) {
|
||||
return -1;
|
||||
} else {
|
||||
return %wire.getColorId();
|
||||
}
|
||||
}
|
||||
|
||||
function lualogic_addwire(%wire) {
|
||||
%layer = lualogic_getlayer(%wire);
|
||||
|
||||
%box = %wire.getWorldBox();
|
||||
|
||||
|
||||
%minX = mFloatLength(getWord(%box, 0)*2, 0)/2;
|
||||
%minY = mFloatLength(getWord(%box, 1)*2, 0)/2;
|
||||
%minZ = mFloatLength(getWord(%box, 2)*5, 0)/5;
|
||||
|
||||
|
||||
%maxX = mFloatLength(getWord(%box, 3)*2, 0)/2;
|
||||
%maxY = mFloatLength(getWord(%box, 4)*2, 0)/2;
|
||||
%maxZ = mFloatLength(getWord(%box, 5)*5, 0)/5;
|
||||
|
||||
|
||||
%min = lualogic_pos(%minX SPC %minY SPC %minZ);
|
||||
%max = lualogic_pos(%maxX SPC %maxY SPC %maxZ);
|
||||
|
||||
lualogic_send("W;" @ %wire.getID() @ ";" @ %color @ ";" @ %min @ ";" @ %max);
|
||||
|
||||
lualogic_send("W;" @ %wire.getID() @ ";" @ %layer @ ";" @ %min @ ";" @ %max);
|
||||
%wire.logicIsAdded = true;
|
||||
}
|
||||
|
||||
@ -56,23 +65,22 @@ function lualogic_removegate(%gate)
|
||||
}
|
||||
}
|
||||
|
||||
function lualogic_sendall()
|
||||
{
|
||||
%groups = mainBrickGroup.getCount();
|
||||
for(%i = 0; %i < %groups; %i++)
|
||||
{
|
||||
function lualogic_sendall() {
|
||||
%num_groups = mainBrickGroup.getCount();
|
||||
for(%i = 0; %i < %num_groups; %i++) {
|
||||
%group = mainBrickGroup.getObject(%i);
|
||||
%bricks = %group.getCount();
|
||||
for(%a = 0; %a < %bricks; %a++)
|
||||
{
|
||||
|
||||
%num_bricks = %group.getCount();
|
||||
for(%a = 0; %a < %num_bricks; %a++) {
|
||||
%brick = %group.getObject(%a);
|
||||
|
||||
%data = %brick.getDataBlock();
|
||||
if(%data.isLogic && %brick.isPlanted() && !%brick.logicIsRemoved)
|
||||
{
|
||||
if(%data.isLogicWire)
|
||||
if(%data.isLogic && %brick.isPlanted() && !%brick.isDead() && !%brick.logicIsRemoved) {
|
||||
if(%data.isLogicWire) {
|
||||
lualogic_addwire(%brick);
|
||||
else if(%data.isLogicGate)
|
||||
} else if(%data.isLogicGate) {
|
||||
lualogic_addgate(%brick);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,13 +144,47 @@ package LuaLogic_Bricks
|
||||
%brick.Logic_HandlePlant();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function fxDtsBrick::setColorFx(%brick, %fx, %bypass) {
|
||||
%data = %brick.getDatablock();
|
||||
if( // If the brick is a wire - act specially
|
||||
isObject(%brick) &&
|
||||
%brick.isPlanted &&
|
||||
!%brick.isDead() &&
|
||||
%data.isLogic &&
|
||||
%data.isLogicWire
|
||||
) {
|
||||
if(%bypass) { // If this is a glow update generated by logic backend - act normally
|
||||
if(%brick.getColorFxId()!=6) { // If the brick is not rainbow, act normally
|
||||
parent::setColorFx(%brick, %fx);
|
||||
} else { // if the brick is rainbow, do nothing
|
||||
return;
|
||||
}
|
||||
} else { // If this is a manual FX change on a wire - act specially
|
||||
if(
|
||||
(%fx==0 && %brick.getColorFxId()==6) ||
|
||||
(%fx==6 && (%brick.getColorFxId()==0 || %brick.getColorFxId()==3))
|
||||
) { // If toggling rainbowness - act normally, and send a color update if the brick is added
|
||||
parent::setColorFx(%brick, %fx);
|
||||
if(%brick.logicIsAdded) {
|
||||
lualogic_send("SL;" @ %brick @ ";" @ lualogic_getlayer(%brick));
|
||||
}
|
||||
} else { // If not toggling rainbowness - do nothing
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else { // The brick is not a wire - act normally
|
||||
parent::setColorFx(%brick, %fx);
|
||||
}
|
||||
}
|
||||
|
||||
function fxDTSBrickData::onColorChange(%data, %obj)
|
||||
{
|
||||
parent::onColorChange(%data, %obj);
|
||||
|
||||
if(isObject(%obj) && %obj.isPlanted() && !%obj.isDead() && %data.isLogic && %data.isLogicWire)
|
||||
lualogic_send("SL;" @ %obj @ ";" @ %obj.getColorID());
|
||||
|
||||
if(isObject(%obj) && %obj.isPlanted() && !%obj.isDead() && %data.isLogic && %data.isLogicWire && %obj.logicIsAdded) {
|
||||
lualogic_send("SL;" @ %obj @ ";" @ lualogic_getlayer(%obj));
|
||||
}
|
||||
}
|
||||
|
||||
function fxDTSBrickData::onDeath(%this, %brick)
|
||||
|
@ -21,7 +21,7 @@ function serverCmdLST(%client, %time)
|
||||
|
||||
function serverCmdLSM(%client, %mult){
|
||||
if(%client.isAdmin || %client.isSuperAdmin){
|
||||
%mult = mFloor(mClamp(%mult, 1, 1000));
|
||||
%mult = mFloor(mClamp(%mult, 1, 10000));
|
||||
$Pref::Server::LuaLogic::OPT_TICK_MULT = %mult;
|
||||
messageAll('', '\c3%1\c6 has set the logic tick multiplier to \c3%2\c6.', %client.name, %mult);
|
||||
lualogic_sendoptions();
|
||||
|
@ -42,7 +42,7 @@ function LuaLogicTCP::onLine(%this, %line)
|
||||
{
|
||||
%brick = getField(%line, %i);
|
||||
if(isObject(%brick))
|
||||
%brick.setColorFX(3);
|
||||
%brick.setColorFX(3, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -51,7 +51,7 @@ function LuaLogicTCP::onLine(%this, %line)
|
||||
{
|
||||
%brick = getField(%line, %i);
|
||||
if(isObject(%brick))
|
||||
%brick.setColorFX(0);
|
||||
%brick.setColorFX(0, true);
|
||||
}
|
||||
}
|
||||
case "TPS":
|
||||
|
Loading…
x
Reference in New Issue
Block a user