I think I will try to answer this for you
Kinda seems to me like you have a lot of fluff in the script that you dont neccessarily need, but im not going for that now, just helping you to fix up the part you want fixed.
Quote:
Originally Posted by MegaMasterX90875
I'm trying to make a script that tokenizes and sets X/Y coordinates according to tokenized results. This is what I have so far (Note: It's in GS1):
|
NPC Code:
if (playerchats&&EditMode=1&&strcontains(#c,/move chair1)) {
tokenize #c;
this.x = strtofloat(#t(3));
this.y = strtofloat(#t(4));
}
I think unless you have gs2 enabled on your server (Correct me If Im wrong someone) this.x and this.y will not set the x and y of the npc. just use x and y. Another thing you might want to look at to clean up your code some, is nesting your statements, makes things more readable.
NPC Code:
if (playerchats) {
if (strequals(#c,blah1)) {
}
else if (strequals(#c,blah2)) {
}
else if (strequals(#c,blah3)) {
}
}
The first mistake I see is if you want something to be
Quote:
The /move chair1 is supposed to be like /move chair1 <NewX> <NewY>
|
You probably wanted to see if it "startswith" /move chair1
Tokens start at 0 so they would be like this
/move = #t(0)
chair1 = #t(1)
xnumber = #t(2)
ynumber = #t(3)
NPC Code:
if (playerchats) {
if (startswith(/move chair1,#c)) {
tokenize #c;
x = strtofloat(#t(2));
y = strtofloat(#t(3));
}
}
You had the x as 3 and the y as 4, so you were probably moving the chair completely away from the board on the y, because there was no value.
Quote:
And, can I make it check to see if it's on a wall? How do I do that?
|
Try using onwall2(x,y,w,h) for checking if the tile is a blocking tile or not.
Edit: Yen got the Onwall better then I did, and setshape2