This repository has been archived by the owner on Jan 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 710
/
Copy pathAchievements_tombailey94.js
65 lines (58 loc) · 1.89 KB
/
Achievements_tombailey94.js
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
62
63
64
65
//Achievements mod by tombailey94
// version 0.0.1
var achvs = [false,false,false,false];
var achvNames = ["Getting Wood","Bedtime already?","Into The Nether","DIAMONDS!"];
function unlockAchv(intIndex){
achvs[intIndex] = true;
clientMessage(achvNames[intIndex] + " unlocked.");
}
function destroyBlock(x, y, z, side) {
blockId = getTile(x,y,z);
if(blockId == 17 && !achvs[0]) { //if player has mined wood for the first time
unlockAchv(0);
} else if(blockId == 56 && !achvs[3]) { //if player has mined diamond ore for the first time
unlockAchv(3);
}
}
function useItem(x,y,z,itemId,blockId,side) {
if(blockId == 247 && !achvs[2]) { //if player has touched a nether reactor core for the first time
unlockAchv(2);
} else if(blockId == 26 && !achvs[1]) { //if player has touched a bed for the first time
unlockAchv(1);
}
}
/*function newLevel() { //load world
for(var i=0;i<achvs.length;i++){
achvs[i] = ModPE.readData("achievement" + i);
}
}
function leaveGame() { //exit world
for(var i=0;i<achvs.length;i++){
ModPE.saveData("achievement" + i, achvs[i]);
}
}*/
function procCmd(cmd) {
var commandElements = cmd.split(" ");
if(commandElements[0] == "achvs") { //if command was /achievements // suggestion: shorten it
if(commandElements.length==1) {
for(var i=0;i<achvs.length;i++){
if(achvs[i]) { //achievement unlocked
clientMessage(achvNames[i] + " unlocked.");
} else { //achievement locked
clientMessage(achvNames[i] + " locked.");
}
}
} else if(commandElements.length==2){
if(commandElements[1] == "reset") {
for(var i=0;i<achvs.length;i++){
achvs[i] == false;
}
clientMessage("Achievements reset.");
} else {
clientMessage("Your parameters were wrong. Achievements command only allows for 'reset' parameter.");
}
} else {
clientMessage("Your parameters were wrong. Achievements command only allows for 'reset' parameter.");
}
}
}