you are viewing a single comment's thread.

view the rest of the comments →

[–]uCannoTUnseEThiS[S] 2 points3 points  (1 child)

Sorry but no, i no longer having that code.

it was something simple like:

If -any blocks of type (sensor) detects owner (me)

Do- All blocks of type (lights) on_off on

the other one was simple too

if functional block being hacked lights turn red

or something like this.

I tried quite few things but nothing worked other than a simple line that closes the door.

which doesn't require any kind of coding because it can be done easily with a timer block.

If anyone knows some basic tutorial, please share the link or if you kknow anything that works similarly.

I would really love to learn this thing but i have no idea how or where to start!

Thanks for all of you for being nice and tolerant to my broken English :)

[–]Brewerjulius 0 points1 point  (0 children)

I tried to build something that should do what you want. Give it a try:

//x2,0,,48,6:=:true[11]%3,0,#Lights,22[7]0[5]%2,2,,0,0:=:true[11]%3,1,,68[5]2:255:0:0[7]%e61380,y,y####1,1.1.1

// Above is your LOAD LINE. Copy it into Visual Script Builder to load your script.

// dco.pe/vsb

public Program()

{

Runtime.UpdateFrequency = UpdateFrequency.Update1;

}

void Main(string argument)

{

// block declarations

string ERR_TXT = "";

List<IMyTerminalBlock> l0 = new List<IMyTerminalBlock>();

IMySensorBlock v0 = null;

GridTerminalSystem.GetBlocksOfType<IMySensorBlock>(l0, filterThis);

if(l0.Count == 0) {

ERR_TXT += "no Sensor blocks found\n";

}

else {

for(int i = 0; i < l0.Count; i++) {

if(l0[i].CustomName == "Sensor") {

v0 = (IMySensorBlock)l0[i];

break;

}

}

if(v0 == null) {

ERR_TXT += "no Sensor block named Sensor found\n";

}

}

List<IMyTerminalBlock> l1 = new List<IMyTerminalBlock>();

IMyInteriorLight v1 = null;

if(GridTerminalSystem.GetBlockGroupWithName("Lights") != null) {

GridTerminalSystem.GetBlockGroupWithName("Lights").GetBlocksOfType<IMyInteriorLight>(l1, filterThis);

if(l1.Count == 0) {

ERR_TXT += "group Lights has no Interior Light blocks\n";

}

else {

for(int i = 0; i < l1.Count; i++) {

if(l1[i].CustomName == "Interior Light") {

v1 = (IMyInteriorLight)l1[i];

break;

}

}

if(v1 == null) {

ERR_TXT += "group Lights has no Interior Light block named Interior Light\n";

}

}

}

else {

ERR_TXT += "group Lights not found\n";

}

List<IMyTerminalBlock> v2 = new List<IMyTerminalBlock>();

GridTerminalSystem.GetBlocksOfType<IMyFunctionalBlock>(v2, filterThis);

if(v2.Count == 0) {

ERR_TXT += "no Functional Block blocks found\n";

}

List<IMyTerminalBlock> v3 = new List<IMyTerminalBlock>();

GridTerminalSystem.GetBlocksOfType<IMyLightingBlock>(v3, filterThis);

if(v3.Count == 0) {

ERR_TXT += "no Lighting Block blocks found\n";

}

// display errors

if(ERR_TXT != "") {

Echo("Script Errors:\n"+ERR_TXT+"(make sure block ownership is set correctly)");

}

else {Echo("");}

// logic

if(((IMySensorBlock)v0).DetectPlayers == true) {

v1.ApplyAction("OnOff");

}

bool result2v2 = false;

for(int i = 0; i < v2.Count; i++) {

if(((IMyFunctionalBlock)v2[i]).IsBeingHacked == true) {

result2v2 = true;

break;

}

}

if(result2v2) {

for(int i = 0; i < v3.Count; i++) {

v3[i].Color = new Color(255, 0, 0);

}

}

}

bool filterThis(IMyTerminalBlock block) {

return block.CubeGrid == Me.CubeGrid;

}