Quote:
Originally Posted by fatcat123
Log onto the server "Dev iKiDD". I added you it so you can see it for yourself.
|
Again, I suspect a broken array:
Quote:
Originally Posted by Crow
Edit: Only thing I can think of is a broken toolEntries array. What does yours look like?
|
Show me yours, please.
Edit: Nevermind. I ****ed up one of the lines, not even sure how I managed to do that. Line 79:
PHP Code:
this.toolIdx %= this.toolEntries.size() - 1;
Needs to be replaced with this instead:
PHP Code:
this.toolIdx %= this.toolEntries.size();
Edit²: Full code, fixed:
PHP Code:
//#CLIENTSIDE
function onCreated() {
// staff tool stuff
this.toolOn = false;
this.toolIdx = 0;
// add new items here
this.toolEntries = {
{ "Exit", "block.png" },
{ "Update Level", "block.png" }
};
}
// draw the staff tool
function DrawTool(create) {
// create image objects
if (create) {
// background
temp.x = GraalControl.width / 2 - this.toolEntries.size() * 20;
temp.p = GetPolyRect(temp.x, GraalControl.height - 104, 8 + this.toolEntries.size() * 40, 64);
with (findImg(200)) {
polygon = temp.p;
red = green = blue = 0;
alpha = 0.75; mode = 1;
layer = 5;
}
// text
with (findImg(201)) {
x = temp.x + 8;
y = GraalControl.height - 58;
text = thiso.toolEntries[thiso.toolIdx][0];
font = "Arial"; zoom = 0.5;
red = green = blue = 1;
layer = 6;
}
// icons
for (temp.i = 0; i < this.toolEntries.size(); i++) {
with (findImg(202 + i)) {
x = temp.x + 8 + i * 40;
y = GraalControl.height - 96;
image = thiso.toolEntries[i][1];
partx = party = 0;
partw = parth = 32;
alpha = 0.5; mode = 1;
layer = 6;
}
}
}
// update text & alpha
findImg(201).text = this.toolEntries[this.toolIdx][0];
temp.ci = this.toolIdx; // current tool
temp.li = (ci > 0 ? ci - 1 : this.toolEntries.size() - 1); // last tool
findImg(202 + ci).alpha = 1;
findImg(202 + li).alpha = 0.5;
}
// reposition the staff tool when resizing Graal
function GraalControl.onResize(nw, nh) {
if (!this.toolOn)
return;
DrawTool(true);
}
// keyboard stuff
function GraalControl.onKeyDown(code) {
if (code == 69) { // E
if (!this.toolOn) {
this.toolOn = true;
this.toolIdx = 0;
DrawTool(true);
} else {
this.toolIdx++;
this.toolIdx %= this.toolEntries.size();
DrawTool(false);
}
} elseif (code == 87) { // W
if (!this.toolOn)
return;
temp.f = ReplaceText(this.toolEntries[this.toolIdx][0].upper(), " ", "_");
("StaffTool" @ temp.f)();
}
}
// close staff tool
function StaffToolEXIT() {
this.toolOn = false;
hideImgs(200, 201 + this.toolEntries.size());
}
// update level
function StaffToolUPDATE_LEVEL() {
shared.chat("");
sleep(0.05);
shared.chat("update level");
}
// Dusty's, restyled
function ReplaceText(txt, a, b) {
if (txt.pos(a) < 0)
return txt;
temp.len = a.length();
temp.txtpos = txt.positions(a);
temp.newtxt = txt.substring(0, txtpos[0]);
for (temp.i: temp.txtpos) {
temp.p = txt.substring(i + temp.len).pos(a);
temp.newtxt @= b;
temp.newtxt @= txt.substring(i + temp.len, temp.p);
}
return temp.newtxt;
}
// Crow's :3
function GetPolyRect(x, y, w, h)
return { x, y, x + w, y, x + w, y + h, x, y + h };
If a mod would be so kind and edit the first post with this.