setting script state!! is it possible??

Creating scripts
Post Reply
Valerious Strongborn
Posts: 15
Joined: Wed Jul 29, 2015 5:03 pm
Has thanked: 0
Been thanked: 7 times

setting script state!! is it possible??

Post by Valerious Strongborn »

hi everyone so i been fooling around and my meter is non functional after re log or detach reattach unless i tp to another region like kitely welcome center.. then it appears and i have been wearing it all along.. so i came up with the problem
the script is not loaded after relog or detach /retach when it make it to another region everything loads back up.. so is there a way to make a script go from not running to running on attach..
when i detach it sets it's state to non running..
and the main script not being running causes the issue i know how to set state from withthe script too off or not running but any way to use another script in the object to set the state of the main script to running upon atach or rez?
i tried
default
{
state_entry()

llSetScriptState("konk combat meter V6.2")(,TRUE);
}
}

this is the stadardsetting script to not running
// llSetScriptState(llGetScriptName(),FALSE);
as you can see what i was trying to do
tried to tweak around it with different methods


and several other atempts is this possible to do.. to set the state of another script to running.. i know you cant do thatin slbut maybe you can here i dunno
any help is greatly apreciated thanks
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Re: setting script state!! is it possible??

Post by Kayaker Magic »

Well, there are obvious syntax errors in the sample second script in your post, extra parentheses that would prevent it from compiling. HOWEVER, you are trying to solve a problem that I do not see. I wear a HUD meter all the time and find that it does come up running after a relog or detach/attach. Perhaps you are logging onto a region with scripts disabled? Try logging onto the Merchant Sandbox where scripts are allowed. My Magic Bullet Meter works fine over a relog, and I give copies of it away with my demo weapons at the archery range on world Panthalassa. Try one of those out and you will see it works after a relog. (Click on it to see that the dialog comes up). I give away the source code for a very simple meter that listens for the Magic Bullet messages, I'll paste a copy of that code here for you to try out. Of course the only way to tell that this is working is to get yourself shot by one of my weapons. The easiest way to do that is to stand in front of one of the cannons on the dock in front of my store on Panthalassa and click on the cannon to fire it!

Code: Select all

    //Simple Magic Bullet Meter
   //This is not a complete HUD, it only shows how to listen for Magic Bullet messages
  //and calculate a health number from them.
 //Put this in a prim and wear it anywhere, it will tell you on open chat when
//you are hit. Replace those llSay calls with your own responses
//  Written by Kayaker Magic
//This code is given away as open source with no restructions, use as you like,
//even use it in products you sell

integer HUNTCHAN= -5013456;        //the channel used to communicate over
 
integer BTBULLET=    1;        //btype, projectile type is a bullet
integer BTARROW=     2;        //an arrow
integer BTLASER=     3;        //particle beam
integer BTSNOWBALL=  4;        //snowball
integer BTEYEBEAM=   5;        //eye beams
 
integer HITPRIM=     0;            //value of type field if hit is on a prim
integer HITAVATAR=   1;            //type value for hit on an avatar
integer HITTERRAIN=  2;            //type for hit on the terrain

        //    Broadcast to bullet effects to announce a hit on anything
string MBINFO = "info";        //info|type|position|rotation|damage|key|shooter|shootee|btype
                                //1 type is a number defined above, type of object hit
                                //2 position is the region co-ord of the thit
                                //3 rotation is direction of hit
                                //4 damage is 0 to 100 percent
                                //5 key is the UUID of the hit object/avatar (NULL_KEY for terrain)
                                //6 shooter is the name of the shooting avatar
                                //7 shootee is the name of the hit prim
                                //8 btype is the type of projectile bullet, see above
string MBBANG=  "BANG";        //BANG|position        Whispered by a weapon to announce a loud noise


integer health = 100;        //start out healthy

default
{
    state_entry()
    {
        llListen(HUNTCHAN,"","","");
        llSetTimerEvent(1.0);   //one second heartbeat
    } //state_entry
    
    
    listen(integer channel, string name, key id, string message)
    {
        list parse=llParseString2List(message,["|"],[]);
        string cmd=llList2String(parse,0);
        if (cmd==MBINFO)        //is it a bullet fired?
        {
            key hid=(key)llList2String(parse,5);
            if (hid==llGetOwner())       //is this for me?
            {
                key shooter = (key)llList2String(parse,6);
                string sname = llList2String(llGetObjectDetails(shooter,[OBJECT_NAME]),0);
                integer damage=(integer)llList2String(parse,4);
                health -= 2*damage;    //do double damage on avatars!!
                if (health<=0)
                {
                    llSay(0,"You have been killed by "+sname);
                    health = 0;        //prevent health from going negative
                }
                else
                    llSay(0,"You have been shot by "+sname+" health="+(string)health);
            }
        }
    }
    
    timer()
    {
        health += 1;
        if (health>100)
            health=100;
    }
}
Post Reply