I can help you do anything you need. Just ask what you want done.
-Gandolf
Some help would be nice.
In the opencard I made these two strings:
LET locations$ = "1:3:5:7:9:16:17:18:19:20:21:22:23:24:25"
LET board$ = "1:0:1:0:1:0:1:0:1:0:0:0:0:0:1:1:1:1:1:1:1:1:1:1"
In the mousedown, I made a script that locates the sprite the player clicked on. This shows the red border around the right piece, etc.
But it also gets the players location in the two strings above.
LET currlocation$ = NTHFIELD$(locations$,":",spriteselected)
LET location = val(location$)
LET left$ = ""
LET right$ = ""
LET up$ = ""
LET down$ = ""
IF NTHFIELD$(board$,":",location - 1) = "1" then
LET left$ = "block"
END IF
IF NTHFIELD$(board$,":",location + 1) = "1" then
LET right$ = "block"
END IF
IF NTHFIELD$(board$,":",location + 5) = "1" then
LET up$ = "block"
END IF
IF NTHFIELD$(board$,":",location - 5) = "1" then
LET down$ = "block"
END IF
Becouse there are 15 sprites and 15 numbers in the location string, the number in currlocation$ is the number of the square you are on. This then is converted to an integer to do some math with it to check if there are pieces that block the players piece.
This all works.
But the pieces aren't static so I have to update the strings.
Example:
If I move sprite two from square 3 to 2 (one to the left):
LET locations$ = "1:3:5:7:9:16:17:18:19:20:21:22:23:24:25"
becomse
LET locations$ = "1:2:5:7:9:16:17:18:19:20:21:22:23:24:25"
And
LET board$ = "1:0:1:0:1:0:1:0:1:0:0:0:0:0:1:1:1:1:1:1:1:1:1:1"
becomse
LET board$ = "1:1:0:0:1:0:1:0:1:0:0:0:0:0:1:1:1:1:1:1:1:1:1:1"
I tried to use this code:http://www.silvercreator.net/cgi-bin/yabb/YaBB.pl?board=sccode;action=display;num=1215970619
to do this but the strings become messed up.
Could any of you help me with updating these two strings?
First one bit confuses me.
LET location = val(location$)
The var location$ isn't in the script, so I have no idea how that affects the code.
Second I've ran into problems with changefield too but I figured a better way to get what I need done.
Instead of using changefield I put a number in front of each number and use the replace command.
LET locations$ = "1;1:2;3:3;5:4;7:5;9:6;16:7;17:8;18:9;19:10;20:11;21:12;22:13;23:14;24:15;25"
LET board$ = "1;1:2;0:3;1:4;0:5;1:6;0:7;1:8;0:9;1:10;0:11;0:12;0:13;0:14;0:15;1:16;1:17;1:18;1:19;1:20;1:21;1:22;1:23;1:24;1"
If I wanted to change the first number of locations$ to 2, I would do this:
PRINT "Before : " + locations$
LET changelocplaceto = 1
LET changenumberto = 2
LET data$ = STR$(changelocplaceto) + ";" + STR$(changenumberto)
LET locations$ = REPLACE$(locations$, NTHFIELD$(locations$, ":", changelocplaceto), data$)
PRINT "After : " + locations$
The outcome would appear like this:
Before : 1;1:2;3:3;5:4;7:5;9:6;16:7;17:8;18:9;19:10;20:11;21:12;22:13;23:14;24:15;25
After : 1;2:2;3:3;5:4;7:5;9:6;16:7;17:8;18:9;19:10;20:11;21:12;22:13;23:14;24:15;25
It changes the number of changelocplaceto. If you would change that var to any other number, it would still work.
-Gandolf
The change works in location but with board it is a bit confusing.
LET board$ = "1*1:2*0:3*1:4*0:5*1:6*0:7*1:8*0:9*1:10*0:11*0:12*0:13*0:14*0:15*1:16*1:17*1:18*1:19*1:20*1:21*1:22*1:23*1:24*1:25*1"
What the code has to do is:
If I move a piece from sqaure 3 to 1 it has to replace 2*0 with 2*1 and 3*1 with 3*0. However, I can't seem to get it work. It just changes the first 1 it encounters. =/
I can't answer. It's past midnight here so I have to get some sleep.