Jump to content
KiondraeLoc

Jump Drive for Spaceship

Recommended Posts

How do I code a Jump Drive script that lets me type in any x,y,z coordinates on channel 17 that will teleport my spaceship to the specified location anywhere in the region I want to go?

Edited by KiondraeLoc

Share this post


Link to post
Share on other sites

On state_entry: Use llListen on channel 17

On listen: Use llSetRegionPos and the message that was heard, typecasted to vector. You might want to store the me typecasted vector as a variable first and check if it's equal to ZERO_VECTOR. If it is, the script should return and do nothing instead of moving, because you'd end up in a bottom corner of the sim. 

That's the simplest way to do it, without any fancy effects since you didn't specify. I've bolded the words you should look into or ask  about you're confused, unless you actually want someone else to write the script for you

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites
11 minutes ago, Wulfie Reanimator said:

On state_entry: Use llListen on channel 17

On listen: Use llSetRegionPos and the message that was heard, typecasted to vector. 

That's the simplest way to do it, without any fancy effects since you didn't specify. I've bolded the words you should look into or ask  about you're confused, unless you actually want someone else to write the script for you

I was doing something like this: 

float message1;
float message2;
float message3;
integer listenHandle = 0;
string message(string src, string divider)
{
     integer index = llSubStringIndex( src, divider );
    if(~index)
        return llDeleteSubString( src, index, -1);
    return src;
}
string message1(string src, string divider) {
    integer index = llSubStringIndex( src, divider );
    if(~index)
        return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
    return src;
}

default
{

  state_entry() {llListen(17, "","", "");
    }
    
    listen(integer channel, string name, key id, string message)
    {
    if (message(message, " ") == "alt")
            {
               
            }
          
                message1 = (float)message1(message, " ");
              
         
   
                llSetRegionPos(<message1, 0,0>);
           
              
            }
        
    }
 

 

But, I'm not sure because I have very light knowledge of scripting.

Share this post


Link to post
Share on other sites

the hard part is evaluating that the typed input is valid and to make the typed entry as simple as possible for the player. Is faster for example to type #2

#1: /17 <128.0,128.0,20.0>
#2: /17 128 128 20

whether using #1 or #2 we have to check that the input coordinate is in bounds

a way to do this using example #2

...

 

// arena bounding box    
list arena = [
   <128.0,128.0,20.0>,  // arena origin. z = bottom of arena
   <                      
    50.0,               // x width from origin center
    50.0,               // y width from origin center
    100.0               // z height from origin bottom
   >                    // 50,50,100 = 100x100x100 arena box
];

default
{
    state_entry()
    {
        llListen(17, "", llGetOwner(), "");    
    }
    
    listen (integer channel, string name, key id, string text)
    {
    
        list coord = llParseString2List(text, [" "], []);
        vector v = llList2Vector(arena, 0);
        vector w = llList2Vector(arena, 1);
        
        // when input coordinate is out of bounds default to origin coordinate
        float f = llList2Float(coord, 0);
        if (f >= (v.x - w.x) && f <= (v.x + w.x)) v.x = f;
        f = llList2Float(coord, 1);
        if (f >= (v.y - w.y) && f <= (v.y + w.y)) v.y = f;
        f = llList2Float(coord, 2);
        if (f >= (v.z) && f <= (v.z + w.z)) v.z = f;

        llSetRegionPos(v); 
    }
}

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, ellestones said:

the hard part is evaluating that the typed input is valid and to make the typed entry as simple as possible for the player. Is faster for example to type #2

#1: /17 <128.0,128.0,20.0>
#2: /17 128 128 20

whether using #1 or #2 we have to check that the input coordinate is in bounds

a way to do this using example #2

...

 


// arena bounding box    
list arena = [
   <128.0,128.0,20.0>,  // arena origin. z = bottom of arena
   <                      
    50.0,               // x width from origin center
    50.0,               // y width from origin center
    100.0               // z height from origin bottom
   >                    // 50,50,100 = 100x100x100 arena box
];

default
{
    state_entry()
    {
        llListen(17, "", llGetOwner(), "");    
    }
    
    listen (integer channel, string name, key id, string text)
    {
    
        list coord = llParseString2List(text, [" "], []);
        vector v = llList2Vector(arena, 0);
        vector w = llList2Vector(arena, 1);
        
        // when input coordinate is out of bounds default to origin coordinate
        float f = llList2Float(coord, 0);
        if (f >= (v.x - w.x) && f <= (v.x + w.x)) v.x = f;
        f = llList2Float(coord, 1);
        if (f >= (v.y - w.y) && f <= (v.y + w.y)) v.y = f;
        f = llList2Float(coord, 2);
        if (f >= (v.z) && f <= (v.z + w.z)) v.z = f;

        llSetRegionPos(v); 
    }
}

 

Thanks, this most certainly helps.

Share this post


Link to post
Share on other sites

the script I posted above was just to show the concept of a arena bounding box and how to process typed inputs. As game design is actual terrible as wrote. It takes as inputs absolute coordinates when relative inputs should be the design

 

examples of relative inputs are something like:

/17 10 10 5

/17 -20 50 30

/17 40 0 100

/17 5 -12

/17 0

etc

i post another example code which shows a way relative can be done. I would suggest you go with some kinda relative coord method rather than absolute in your game design

// arena bounding box    
list arena = [
   <128.0,128.0,20.0>,  // arena origin. z = bottom of arena
   <                      
    50.0,               // x width from origin center
    50.0,               // y width from origin center
    100.0               // z height from origin bottom
   >                    // 50,50,100 = 100x100x100 arena box
];

default
{
    state_entry()
    {
        llListen(17, "", llGetOwner(), "");    
    }
    
    listen (integer channel, string name, key id, string text)
    {
    
        list coord = llParseString2List(text, [" "], []);
        vector v = llList2Vector(arena, 0);
        vector w = llList2Vector(arena, 1);
        
        // when input coordinate is out of bounds default to origin coordinate
        if (llAbs(llList2Integer(coord, 0)) <= w.x)  v.x += llList2Float(coord, 0);
        if (llAbs(llList2Integer(coord, 1)) <= w.y)  v.y += llList2Float(coord, 1);
        float f = llList2Float(coord, 2);
        if (f >= 0.0 && f <= w.z) v.z += f;

        llSetRegionPos(v); 
    }
}

 

Edited by ellestones
@ waffle

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...