forked from MCCTeam/Minecraft-Console-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-script-with-world-access.cs
61 lines (52 loc) · 1.64 KB
/
sample-script-with-world-access.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//MCCScript 1.0
MCC.LoadBot(new WatchLamp());
//MCCScript Extensions
/* The ChatBot will access the world on a regular basis to watch for a lamp.
* This is an example of how the world around the player can be accessed from a C# script. */
class WatchLamp : ChatBot
{
/* == CONFIG == */
int lampX = 0;
int lampY = 64;
int lampZ = 0;
/* == CODE == */
int checkCount = 0;
Location lampLoc;
public WatchLamp()
{
if (!Settings.TerrainAndMovements)
{
LogToConsole("WARNING: Terrain handling is disabled in INI file.");
LogToConsole("WARNING: This means this bot cannot watch for lamps.");
UnloadBot();
}
else
{
lampLoc = new Location(lampX, lampY, lampZ);
LogToConsole("Watching lamp at " + lampLoc);
}
}
public override void Update()
{
if (checkCount > 10)
{
checkCount = 0;
Material blockType = GetWorld().GetBlock(lampLoc).Type;
switch (blockType)
{
case Material.RedstoneLampOn:
//Lamp is on. All right. Nothing to say here.
break;
case Material.RedstoneLampOff:
LogToConsole("Lamp at " + lampLoc + " is currently turned OFF !!!");
for (int i = 0; i < 3; i++)
Console.Beep();
break;
default:
LogToConsole("Block at " + lampLoc + " is not a lamp: " + blockType + "...");
break;
}
}
else checkCount++;
}
}