Change font size
It is currently Tue May 21, 2013 9:54 pm

Forum rules


Image



Post a new topicPost a reply Page 1 of 3   [ 27 posts ]
Go to page 1, 2, 3  Next
Author Message
 Post subject: Trying to find....
PostPosted: Thu Jun 07, 2012 4:04 pm 

Joined: Thu Jun 07, 2012 3:59 pm
Posts: 10
Good morning all,

I've been having a touch of difficulty trying to find out if something has made it into OpenSim as yet.

In certain circles in SL, certain "board games" have gained some popularity. I have been searching through both OpenSim and Google to see if something similar has been released in OpenSim as Open Source, so far I've turned up nothing.

So I turn to the forums to find out .... does anyone know if this sort of content has made it's way into OpenSim and where such stuff can be found?

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Thu Jun 07, 2012 5:02 pm 
Furious Typer
User avatar

Joined: Mon Oct 25, 2010 7:42 pm
Posts: 214
Location: Canada
There was some discussion of games here:

viewtopic.php?f=13&t=3434&p=18735#p18735

However I know what you mean from SL. The UNA tabletops and the like with chairs scripted to interact with HUDs etc. I've never seen those outside SL. If the ones in SL are still for sale for hundreds of lindens I doubt creators will share any aspect of them for free. However I've seen some scripting geniuses on here so nothing is impossible to create. It just might take some time to figure out.


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Fri Jun 08, 2012 4:57 am 
OSG Elite
User avatar

Joined: Sat Jun 14, 2008 12:28 am
Posts: 360
Location: Australia
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


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Fri Jun 08, 2012 4:57 pm 

Joined: Thu Jun 07, 2012 3:59 pm
Posts: 10
Thanks for the help guys. It looks like it's given me a few things to check out, so hopefully I get some stuffo ut of it ;)


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Fri Jun 08, 2012 6:44 pm 
Furious Typer

Joined: Mon Apr 25, 2011 6:48 pm
Posts: 70
Cam,

Nice! Small and simple. What about using osMessageObject, instead of llSay on open chat. Should cut lag tremendously and not spam chat.

Now to work this for NPC chess... :ugeek:

Shad


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Sat Jun 09, 2012 12:02 am 
OSG Elite
User avatar

Joined: Sat Jun 14, 2008 12:28 am
Posts: 360
Location: Australia
Shad,
osMessageObject uses dataserver, and it has been suggested that dataserver should only be used when no other solution can be found, I am not sure why, but anyway, I mentioned the issue of chat spam in my previous post, so to enforce this, my latest script uses a system channel to avoid chat spam issues and crosstalk.
This New board script uses llDetectedTouchST(0) to create the entire board on a single prim, no other functionality has been added at this point, but reducing 64 prims and 64 scripts down to one makes me happy.
Here is the one prim chess board script. (btw it is built using scale variables so it doesnt matter what size it is, it will still work, unless it is bigger than 10m x 10m then you might need to modify your OpenSim.ini to fix the 10 meter limit (here...
Code:
    ;; The factor the 10 m distances llimits are multiplied by
    ; ScriptDistanceLimitFactor = 1.0
change the 1.0 to 2.0 for 20 meters, 3.0 for 30 meters etc.
So anyway the script...
Code:
//Simple chess board script V0.2
//by Cam Chevalier
//09-June-2012
integer width = 8;
integer height = 8;
integer channel = 9876;


default
{
    touch_start(integer total_number)
    {
        vector st = llDetectedTouchST(0);
        integer x = llFloor(st.x * width);
        integer y = llFloor(st.y * height);       
        vector center =llGetPos();
        vector size = llGetScale();
        float wFactor=size.x/8;
        float wstep = wFactor/2;
        float hFactor=size.y/8;
        float hstep = hFactor/2;
        float tFactor=size.z;

        vector placex;
        if (x==0){ placex= (center -<wstep+wFactor*3,0,0>);}
        if (x==1){ placex= (center -<wstep+wFactor*2,0,0>);}
        if (x==2){ placex= (center -<wstep+wFactor,0,0>);}
        if (x==3){ placex= (center -<wstep,0,0>);}
        if (x==4){ placex= (center +<wstep,0,0>);}
        if (x==5){ placex= (center +<wstep+wFactor,0,0>);}
        if (x==6){ placex= (center +<wstep+wFactor*2,0,0>);}
        if (x==7){ placex= (center +<wstep+wFactor*3,0,0>);}       
        vector placexy;
        if (y==0){ placexy= (placex -<0,hstep+hFactor*3,0>);}
        if (y==1){ placexy= (placex -<0,hstep+hFactor*2,0>);}
        if (y==2){ placexy= (placex -<0,hstep+hFactor,0>);}
        if (y==3){ placexy= (placex -<0,hstep,0>);}
        if (y==4){ placexy= (placex +<0,hstep,0>);}
        if (y==5){ placexy= (placex +<0,hstep+hFactor,0>);}
        if (y==6){ placexy= (placex +<0,hstep+hFactor*2,0>);}
        if (y==7){ placexy= (placex +<0,hstep+hFactor*3,0>);}
        vector finalpos = placexy+<0,0,tFactor>;
         llSay(channel,(string)finalpos);
    }
}
Put a chess board texture on the top face,

and the matching "piece" script
Code:
//piece script V-0.2
//by Cam Chevalier
//09-June-2012
integer Channel=9876;
string player="White";
integer i;
default
    {
        touch_start(integer total_number)
        {
            i= llListen(Channel, "", NULL_KEY, "" );
            llSay(0,"moving "+ player); 
         }

        listen( integer channel, string name, key id, string message )
         {
            llSetPos(message);
            llListenRemove(i);
         } 
    }

Best results are gained when the pieces are the same height as the thickness of the board, if you want to change that then play with tFactor (thicknessFactor).
Regards Cam


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Sat Jun 09, 2012 12:21 am 
Furious Typer

Joined: Mon Apr 25, 2011 6:48 pm
Posts: 70
Cam,

Question, since the dataserver isn't the best option, could this be applied to an object where the pieces are linked to the board, thus using MessageLinked, instead of Listen/llSay? I'm certain it could be, but I'm learning here.

Shad


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Sat Jun 09, 2012 11:49 pm 
OSG Elite
User avatar

Joined: Sat Jun 14, 2008 12:28 am
Posts: 360
Location: Australia
Shad, yes it seems it can,
The following scripts prove it, thanks for the prompt, I hadn't worked with llMessageLinked before so this was a good learning exercise for me, I hope you can get something out of it,
and the script just got less laggy, and all the pieces can be (must be) linked for easy portability.

When linking make sure the board is the last prim linked (root prim) for it to work.
Code:
//Simple chess board script V0.3
//by Cam Chevalier
//09-June-2012
integer width = 8;
integer height = 8;
integer child;

default
{
     link_message(integer sender_num, integer num, string str, key id)
{child=num;}

    touch_start(integer b)
    {
        vector st = llDetectedTouchST(0);
        integer x = llFloor(st.x * width);
        integer y = llFloor(st.y * height);       
        vector size = llGetScale();
        float wFactor=size.x/8;
        float wstep = wFactor/2;
        float hFactor=size.y/8;
        float hstep = hFactor/2;
        float tFactor=size.z;

        vector placex;
        if (x==0){ placex= ( -<wstep+wFactor*3,0,0>);}
        if (x==1){ placex= ( -<wstep+wFactor*2,0,0>);}
        if (x==2){ placex= ( -<wstep+wFactor,0,0>);}
        if (x==3){ placex= ( -<wstep,0,0>);}
        if (x==4){ placex= ( <wstep,0,0>);}
        if (x==5){ placex= ( <wstep+wFactor,0,0>);}
        if (x==6){ placex= ( <wstep+wFactor*2,0,0>);}
        if (x==7){ placex= ( <wstep+wFactor*3,0,0>);}       
        vector placexy;
        if (y==0){ placexy= (placex -<0,hstep+hFactor*3,0>);}
        if (y==1){ placexy= (placex -<0,hstep+hFactor*2,0>);}
        if (y==2){ placexy= (placex -<0,hstep+hFactor,0>);}
        if (y==3){ placexy= (placex -<0,hstep,0>);}
        if (y==4){ placexy= (placex +<0,hstep,0>);}
        if (y==5){ placexy= (placex +<0,hstep+hFactor,0>);}
        if (y==6){ placexy= (placex +<0,hstep+hFactor*2,0>);}
        if (y==7){ placexy= (placex +<0,hstep+hFactor*3,0>);}
        vector finalpos = placexy+<0,0,tFactor>;
        llMessageLinked(child, 0,(string)finalpos, NULL_KEY);
    }
}

and
Code:
//piece script V-0.3
//by Cam Chevalier
//09-June-2012
string player="White";
default
{
    touch_start(integer b)
    {
    llSay(0,"moving "+ player); 
    llMessageLinked(1, llGetLinkNumber(), player, NULL_KEY);
    }
    link_message(integer sender_num, integer num, string str, key id)
    {
    llSetPos(str);
    }             
}


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Sun Jun 10, 2012 1:09 am 
Furious Typer

Joined: Mon Apr 25, 2011 6:48 pm
Posts: 70
Cam,

I use llMessageLinked in the Neurotronic NPC Brain, to have the multiple scripts communicate asynchronously. It's proved very useful. I wasn't sure how it would fit with your game board, but glad it helped. :D

Thought I'd post some games found in the LSL Wiki and SL LSL Wiki Script Libraries. These could be modified, using Cams' scripts as a foundation.

Go

Petanque

Minesweeper

Tic Tac Toe

This script, while not a game, could certainly be used within a Checkers game, to help control the movement of the game pieces.

Zigzag Sequence

Shad


Top
 Profile  
 
 Post subject: Re: Trying to find....
PostPosted: Sun Jun 10, 2012 6:25 am 
Furious Typer

Joined: Sun Jan 03, 2010 5:20 am
Posts: 52
It's great to see discussion of games here.

One game I'm hoping might make it over here is the card game of Spades -- a weekly game with friends is currently the only reason I'm keeping a plot of land in SL. I'd love to be able to play it here in OSgrid.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 3   [ 27 posts ]
Go to page 1, 2, 3  Next


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net