Jump to content

RFC: holo vendor


Tabris Daxter
 Share

You are about to reply to a thread that has been inactive for 4553 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

hi all,

here is one of my current projects not quite done yet but i need help with a couple of parts.

 

CODE:

string product_name(integer index)
{
    list gLstMnu = [];
    integer a = 0;
    integer holodisp = llGetInventoryNumber(INVENTORY_OBJECT)+1;
    while (a < holodisp)
    {
        if (llGetSubString(llGetInventoryName(INVENTORY_OBJECT,a),0,3) == "HOLO")
        {
            gLstMnu += llGetInventoryName(INVENTORY_OBJECT,a);
        }
        a++;
    }
    return llList2String(gLstMnu,index);
}

integer x = 0;
integer gChan;
string purchased_object;
integer cost;
string gNoteCard = "VendorConfig";
integer gNCline;
key gNCquery;
key pID;
float pCUT;
string pNAME;
integer gCut;

default
{
    state_entry()
    {
        llSay(0,"Vendor Online.");
        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
    }

    changed(integer a)
    {
        if (a & (CHANGED_OWNER | CHANGED_INVENTORY))
        {
            llResetScript();
        }
    }
    
    run_time_permissions( integer perm )
    {
        if (perm & PERMISSION_DEBIT)
        {
            state running;
        }
        else
        {
            llSay(0,"Permission not granted. \nscript now shuting down.");
            llSetScriptState(llGetScriptName(),0);
        }
    }
}

 

the main part i need help with is here:

state running
{
    touch_start(integer num_detected)
    {
        integer i;
        for(i = 0; i < num_detected; ++i) 
        {
            if (llGetLinkName(llDetectedLinkNumber(i)) == "Previous")
            {
                llOwnerSay(product_name(x--));
                llRezAtRoot(product_name(x),llGetPos()+<0.0,0.0,1.5>,ZERO_VECTOR,ZERO_ROTATION,gChan);
                if (x == i+1)
                {
                    llWhisper(gChan,"KILL");
                }
                else if (x == llGetInventoryNumber(INVENTORY_OBJECT))
                {
                    x = 0;
                }
            }
            else if (llGetLinkName(llDetectedLinkNumber(i)) == "Next")
            {
                llOwnerSay(product_name(x++));
                llRezAtRoot(product_name(x),llGetPos()+<0.0,0.0,1.5>,ZERO_VECTOR,ZERO_ROTATION,gChan);
                if (x == i+1)
                {
                    llWhisper(gChan,"KILL");
                }
                else 
                if (x == llGetInventoryNumber(INVENTORY_OBJECT))
                {
                    x = 0;
                }
            }
            else if (llGetLinkName(llDetectedLinkNumber(i)) == "Pay Button")
            {
                llOwnerSay(llGetLinkName(llDetectedLinkNumber(i)));
                purchased_object = product_name(x);
                state purchase;
            }
            else if (llGetLinkName(llDetectedLinkNumber(i)) == "Holo Tank")
            {
                llWhisper(gChan,"KILL");
            }
        }   
    }

1.  the idea is if i click next (or previous) it kills the current item and then rezzes the new one. currently it just rezzes over the top of the current item.

i know i could just alpha the current item & wait for "garbage collection" but i don't believe that that's an ideal solution.

2. another problem i'm having in the same section is that it's skipping the first item. it says the name of item 1 but rezzes item 2.

3. how can i get it to loop back to the start when i get to the end of the items.

 

TODO:

email or http comms to a distribution server.

DB comms for an update list

 

USUAL COMMENT:

i know it's probably "dirty" but thats how i code.

alot of this is from scratch but some is Frankensteined in.

 

Link to comment
Share on other sites

I met a similar objective with a standard holodeck as described here:

Art gallery in holodeck-- Tutorial

http://virtualoutworlding.blogspot.com/2010/11/art-gallery-in-holodeck-tutorial.html

An object rezzed by a holodeck normally has a die script so it can remove itself when the scene is changed

You dont want to give a customer an object with a die script, of course.  The scheme I used was to put a proper object into the contents of holo-rezzed object and deliver that to the customer.

TKR

   

 

 

Link to comment
Share on other sites

Or push the llDie() script into the object only when it's time for it to go away, using llRemoteLoadScriptPin().

Probably obvious but: the die script must be in a not-running state in the scripted object that pushes it to the target, so to prevent the inevitable, it's best if the die script checks something like the name of the containing object in state_entry and sets itself not running if it's inside the pushing object.  (Lest one fine day you forget, Set Scripts Running, and *poof*.)

Link to comment
Share on other sites

integer gChan;	// <==== Whatever the main script is using.  NB: "Whisper" probably won't have enough rangedefault{	changed(integer Change){		if(Change && CHANGED_OWNER){			llRemoveInventory(llGetScriptName());		}	}	listen(integer ChannelIn, string FromName, key FromID, string Message){		if(ChannelIn == gChan){			llDie();		}	}	state_entry(){		llListen(gChan, "", "", "KILL");	}}

 

Link to comment
Share on other sites

ty,

guys if you actually read the script,

@ PeterCanessa Oh, whisper is enough because it only rezzes @ <0,0,1.5> above the rezzing object.

@ Tharkis Olafson, there are 2 objects, one has the prefix HOLO & the other has the prefix BOXED (not shown due to copy & paste fubar)

@Thinkerer Melville, i don't want a commercial solution, i'd rather make it myself. thats what this forum is about. also USD$10 is pretty expensive, ~2500L$

and as there is a whisper command it should be obvious (and didn't think i needed to post it) that there is a second script in the HOLO object.

here are both scripts:

HOLO VENDOR:

string product_name(integer index){    list gLstMnu = [];    integer a = 0;    integer holodisp = llGetInventoryNumber(INVENTORY_OBJECT)+1;    while (a < holodisp)    {        if (llGetSubString(llGetInventoryName(INVENTORY_OBJECT,a),0,3) == "HOLO")        {            gLstMnu += llGetInventoryName(INVENTORY_OBJECT,a);        }        a++;    }    return llList2String(gLstMnu,index);}integer x = 0;integer gChan;string purchased_object;integer cost;string gNoteCard = "Config";integer gNCline;key gNCquery;key pID;float pCUT;string pNAME;integer gCut;default{    state_entry()    {        llSay(0,"Vendor Online.");        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);    }    changed(integer a)    {        if (a & (CHANGED_OWNER | CHANGED_INVENTORY))        {            llResetScript();        }    }        run_time_permissions( integer perm )    {        if (perm & PERMISSION_DEBIT)        {            state running;        }        else        {            llSay(0,"Permission not granted. \nscript now shuting down.");            llSetScriptState(llGetScriptName(),0);        }    }}state running{    state_entry()    {        llSay(0, llGetObjectName()+" Ready!");        gChan = (integer) ( "0xF" + llGetSubString( llGetKey(),0,6 ) );        llSensorRepeat("","",AGENT,10,PI,30);        llSetLinkPrimitiveParams(2,[PRIM_COLOR,ALL_SIDES,<0.0, 0.0, 1.0>,0.25,PRIM_GLOW,ALL_SIDES,0.1]);        gNCquery = llGetNotecardLine(gNoteCard, gNCline);    }    touch_start(integer num_detected)    {        integer i;        for(i = 0; i < num_detected; ++i)         {            if (llGetLinkName(llDetectedLinkNumber(i)) == "Previous")            {                llOwnerSay(product_name(x--));                llRezAtRoot(product_name(x),llGetPos()+<0.0,0.0,1.5>,ZERO_VECTOR,ZERO_ROTATION,gChan);                if (x == i+1)                {                    llWhisper(gChan,"KILL");                }                else if (x == llGetInventoryNumber(INVENTORY_OBJECT))                {                    x = 0;                }            }            else if (llGetLinkName(llDetectedLinkNumber(i)) == "Next")            {                llOwnerSay(product_name(x++));                llRezAtRoot(product_name(x),llGetPos()+<0.0,0.0,1.5>,ZERO_VECTOR,ZERO_ROTATION,gChan);                if (x == i+1)                {                    llWhisper(gChan,"KILL");                }                else                 if (x == llGetInventoryNumber(INVENTORY_OBJECT))                {                    x = 0;                }            }            else if (llGetLinkName(llDetectedLinkNumber(i)) == "Pay Button")            {                llOwnerSay(llGetLinkName(llDetectedLinkNumber(i)));                purchased_object = product_name(x);                state purchase;            }            else if (llGetLinkName(llDetectedLinkNumber(i)) == "Holo Tank")            {                llWhisper(gChan,"KILL");            }        }       }        no_sensor()    {        llSay(gChan,"KILL");        llListenRemove(gChan);        state standby;    }            dataserver(key lquery, string data)    {        if (gNCquery == lquery)        {            if (data != EOF)            {                list tmp = llParseString2List(data, ["="], []);                string setting = llList2String(tmp,0);                if (setting == "PARTNER_KEY")                {                    pID = llStringTrim(llList2String(tmp,1),STRING_TRIM);                }                else if (setting == "PARTNER_CUT")                {                    pCUT = llList2Float(tmp,1);                }                else if (setting == "PARTNER_NAME")                {                    pNAME = llStringTrim(llList2String(tmp,1),STRING_TRIM);                }            }            gNCquery = llGetNotecardLine(gNoteCard, ++gNCline);        }    }}state standby{    state_entry()    {        llSensorRepeat("","",AGENT,10,PI,30);        llSay(0,"standby mode");        llSetLinkPrimitiveParams(2,[PRIM_COLOR,ALL_SIDES,llGetColor(1),0,PRIM_GLOW,ALL_SIDES,0]);    }    /*    touch(integer num)    {        state running;    }    */    sensor(integer num)    {        state running;    }}state purchase{    state_entry()    {        llWhisper(0,"Right Click to Purchase");        list tmp = llCSV2List(purchased_object);        cost = llList2Integer(tmp,2);        llSetPayPrice(PAY_HIDE, [cost,PAY_HIDE,PAY_HIDE,PAY_HIDE]);        gCut = llRound(cost * pCUT);        llOwnerSay("Cut Payed To " + pNAME + " is L$" + (string)gCut);    }        money(key id, integer price)    {        list tmp = llCSV2List(purchased_object);        if (price == cost)        {            llRegionSayTo(id,0,"Thakyou for Purchasing " + llList2String(tmp,1));            llGiveInventory(id,"BOXED,"+ llList2String(tmp,1)); //gives a seperate item            llGiveMoney(pID,gCut);        }        else if (price < cost)        {            llRegionSayTo(id,0,"Sorry, You Didn't Pay Enough to Purchase.\nThe Price is L$" +(string)cost + " for "+ llList2String(tmp,1));            llGiveMoney(id,price);        }        else if (price > cost)        {            llRegionSayTo(id,0,"You Payed too Much to Purchase.\nThe Price is L$" +(string)cost + " for "+ llList2String(tmp,1));            llGiveMoney(id,price);        }        state running;    }}

 Kill script in the rezzed holo object

integer gChan;default{    on_rez(integer a)    {        gChan = a;        llListen(gChan,"", NULL_KEY,  "");        //llOwnerSay("Listening on: " + (string)a);        llSetPrimitiveParams([PRIM_TEMP_ON_REZ,TRUE]);        llTargetOmega(<0.0,0.0,1.0>,0.25,0.01);    }        listen(integer chan, string name, key id, string msg)    {        if (msg == "KILL")        {            llDie();        }    }}

 


Link to comment
Share on other sites

This fragment might help with the questions of how to kill the last object, how to loop round, and how not to skip one.

I've not been able to test it, but I think it's right.

integer x;integer max;integer chan;list items =["a","b","c"];key last_rezzed;vector offset;default{	state_entry(){		max=llGetListLength(items)-1;		chan = -1*((integer)llFrand(100000.0)+10000);	}	object_rez(key id){		last_rezzed = id;//grab the key of the item i just rezzed	}	touch_end(integer total_number)	{		if(last_rezzed){			llRegionSayTo(last_rezzed,chan,"die"); //if there's a rezzed item, kill it		}		string s = (string) llGetLinkPrimitiveParams(llDetectedLinkNumber(0),[PRIM_NAME]);		if("Next"==s){			++x;			if(x>max){				x=0;			}		}		else if("Back"==s){			--x;			if(x<0){				x=max;			}		}		llRezAtRoot(llList2String(items,x),			llGetPos()+offset*llGetRot(),			ZERO_VECTOR,			llGetRot(),			chan);	}}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4553 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...