I have brought part of that discussion over because it was part of Odball Otoole's guitar museum post and I didnt want to upset that thread, and take it off topic, but as Jamie mentioned this conversation was started there...
Sarah Kline wrote:
If we can find 'somebody' who could write a simple script to move a prim on a board by clicking on a target prim square..it would be the basis of many board games combined with Jamies dice and of course chess & checkers....bet Neb would do it with NPC's lol
OK you found somebody, I have written such a script, this is it in the barest form, exactly as Sarah described,
2 scripts,
First rez a cube, place the "board" script in this prim, then rez a cone, and place the "piece" script in it.
Now touch the cone, it will say "moving White", now touch the cube and it will say its co-ords and the piece will move exactly over the cube,
so make a chess board by following these instructions
Quote:
Rez a box, place the "board" script in it, in edit window, check "Use Grid" open grid options, set Grid Units to 1meter, and enable "sub unit snapping" select box and from overhead view grab "green and red" triangles and allow to snap to place, now shift/drag to duplicate and snap right next to first prim, now colour one of them dark. Select both prims using the shift key, duplicate the pair, 3 more times and snap all in one line, now select all 8 and duplicate in the other direction, now rotate these 8 pieces so they are opposite colours as in checkerboard, snap into place, select all 16 prims and duplicate 4 times, snapping as you go, to end up with a checker board, every square scripted.
To make a chequers board, leave the dark squares unscripted
There is no more functionality than that for now, messages are on open chat channel 0 change that [in the "board" script llSay(0, and in the "piece" script llListen(0,] I left it there for debugging, you wont want the position spamming chat.(in fact any chat will upset the game so change it immediately) But the "moving White" is a good indicator of when you have touched the piece, it wont move unless you touch the piece first then the square next, duplicate the scripted cone "piece" as many times as you like, and still the only piece to move will be the piece that you touched, you can change the player from "White" to" Black" on half the pieces, but theres a lot more scripting to be done to make it do anything more.
This is a simple beginning script to get this idea rolling.
Code:
//piece script V-0.1
//by Cam Chevalier
string player="White";
integer i;
default
{
touch_start(integer b)
{
i= llListen(0, "", NULL_KEY, "" );
llSay(0,"moving "+ player);
}
listen( integer channel, string name, key id, string message )
{
llSetPos(message);
llListenRemove(i);
}
}
Code:
//board script V-0.1
//by Cam Chevalier
default
{
touch_start(integer b)
{
llSay(0, (string)(llGetPos()+<0,0,0.5>));
}
}
There is nothing stopping many pieces landing on the same square and there is nothing stopping several people from touching things and messing up the play (you'll just all have to learn to get along and play by the rules) but listen script only starts on touch and is removed after piece has moved, so nothing is left listening, its not a lag monster. I will start messing around with allowable moves and, preoccupied spaces next, checkers for now, chess would be a serious undertaking (maybe some day) And probably improve the board by using llDetectedTouchST(0); to create the whole board with one prim, instead of 64.
Have fun kids, see you in the sandbox
Cam