Jump to content

HELP! Trying to Build and HUD controlled light emitter.


Hawk Umino
 Share

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

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

Recommended Posts

Currently trying to build a point light emitter that will be controlled via menu that will be activated by a HUD button. So far this is what i have:

 

// Color Change per Popup Menu
integer Hud_channel = -180123;
list prim_nr = [2,3,4];
list vects = [<1,0,0>,<0,1,0>,<1,1,1>,<0,0,0>,<0.5,0.5,0>,<0,0,1>,<1,0.5,0>,<1,1,0>,<1,0.5,0.5>,<0.2,0,0.2>,<0.5,1,1>,<0.2,0.2,0.4>];
list cols = ["Red","Green","White","Black","Gold","Blue","Orange","Yellow","Pink","Purple","Sky","Lavender"];
float menu;
integer channel;
integer lst_hdl;
default
{
    state_entry()
    {
        llOwnerSay( "Communication channel is set to "+(string) Hud_channel);
        llListen( Hud_channel, "","","");
    }
    
     listen(integer channel, string name, key id, string h)
    {
        if(llGetOwnerKey(id) == llGetOwner())
        {
            if(h == "go")
            {
               llSetTimerEvent(intensity);
            }
            else if(h == "stop")
            {
            
            }
        }
    }
    
    on_rez(integer num)
    {
        llResetScript();
    }
    touch_start(integer num)
    {
        key owner = llGetOwner();
        if(llDetectedKey(0) == owner)
        {
            channel = (integer)llFrand(-9000- 1000);
            llDialog(owner,"Color Changer",cols,channel);
            lst_hdl = llListen(channel, "", owner, "");
            llSetTimerEvent(15);
        }
    }

    listen(integer number, string name, key id, string message)
    {
        integer index = llListFindList(cols, (list)message);
        if(index != -1)
        {
            integer count;
            integer max=llGetListLength(prim_nr);
            for(count=0;count<max;count++)
            {
                vector new_color = llList2Vector(vects,index);
                llSetLinkPrimitiveParams(llList2Integer(prim_nr,count),[PRIM_COLOR, 0,new_color,1,
                                                                        PRIM_POINT_LIGHT,TRUE,new_color,10,10,0.75]);
            }
            //llSetColor(llList2Vector(vects, index),ALL_SIDES);
            llListenRemove(lst_hdl);
            llSetTimerEvent(0);
        }
    }
    timer()
    {
        llSetTimerEvent(0);
        llListenRemove(lst_hdl);
    }
}
Link to comment
Share on other sites


steph Arnott wrote:

You can not have two identical events in the same state. Listen is allready defined.

So i combine the first and second listen events into the first:

// Color Change per Popup Menuinteger Hud_channel = -180123;list prim_nr = [2,3,4];list vects = [<1,0,0>,<0,1,0>,<1,1,1>,<0,0,0>,<0.5,0.5,0>,<0,0,1>,<1,0.5,0>,<1,1,0>,<1,0.5,0.5>,<0.2,0,0.2>,<0.5,1,1>,<0.2,0.2,0.4>];list cols = ["Red","Green","White","Black","Gold","Blue","Orange","Yellow","Pink","Purple","Sky","Lavender"];float menu;integer channel;integer lst_hdl;default{    state_entry()    {        llOwnerSay( "Communication channel is set to "+(string) Hud_channel);        llListen( Hud_channel, "","","");    }         listen(integer channel, string name, key id, string h, integer number, string message)    {        if(llGetOwnerKey(id) == llGetOwner())        {            if(h == "go")            {               llSetTimerEvent(intensity);            }            else if(h == "stop")            {                        }        }    }        on_rez(integer num)    {        llResetScript();    }    touch_start(integer num)    {        key owner = llGetOwner();        if(llDetectedKey(0) == owner)        {            channel = (integer)llFrand(-9000- 1000);            llDialog(owner,"Color Changer",cols,channel);            lst_hdl = llListen(channel, "", owner, "");            llSetTimerEvent(15);        }    }    {        integer index = llListFindList(cols, (list)message);        if(index != -1)        {            integer count;            integer max=llGetListLength(prim_nr);            for(count=0;count<max;count++)            {                vector new_color = llList2Vector(vects,index);                llSetLinkPrimitiveParams(llList2Integer(prim_nr,count),[PRIM_COLOR, 0,new_color,1,                                                                        PRIM_POINT_LIGHT,TRUE,new_color,10,10,0.75]);            }            //llSetColor(llList2Vector(vects, index),ALL_SIDES);            llListenRemove(lst_hdl);            llSetTimerEvent(0);        }    }    timer()    {        llSetTimerEvent(0);        llListenRemove(lst_hdl);    }}

But im getting a sytax error on string h

Link to comment
Share on other sites


steph Arnott wrote:

The par you remove has now put the code block out side the event, you need to move it into the listen event

Well since I can't have two listen events, how should it be written? Because If i move the first listen event won't it do the same thing?

Link to comment
Share on other sites


Hawk Umino wrote:

 im getting a sytax error on string h


Because the Listen event only has four arguments: integer Channel, string Name, key ID and string Message. Check out the Wiki to confirm.

Yours has six (below). string h and integer number are not used. You should collect the whole of your listen event together and use message in place of h and number... doesn't seem to be used?

listen(integer channel, string name, key id, string h, integer number, string message)

Also, intensity (also inside your listen) isn't recognised as a global variable.

I've not read the whole script, but you'll have to at least follow Steph's advice as well as mine before you'll be able to get this to even compile.

Link to comment
Share on other sites

The problems you are having are problems with logic, and only incidentally with syntax.  At this point, it's smartest to step back and look at your original script -- before you started adding things to it.  If you must use a borrowed script instead of writing one for yourself, never start modifying it until you understand what it does. Otherwise, you'll just create a mess.

So, work through the original script line by line.  Ask yourself what will happen when someone touches it.  What things happen, and it what logical order? What are all of the various bits in each event meant to do?  What would happen if they were not there?  When you have all of that figured out, test it.  Try changing a few things at a time to see whether you understood correctly.  If you did, then get bolder and start making more substantial changes.  But always be prepared to back up, rip out your changes, and try again from the last stage when you had a working script.

That's the way scripting is done, by keeping the logic clear in your head at all times.

BTW, I see that you tried to add the switch that we discussed in your earlier thread.  It's not quite there yet, but you're getting close.

Apart from logic, which really is the heart of what you need to address, there's good reason to learn some basic syntax. I suggest spending time with some fundamental tutorials >>> http://wiki.secondlife.com/wiki/LSL_Tutorial

Link to comment
Share on other sites


Freya Mokusei wrote:


Hawk Umino wrote:

 im getting a sytax error on string h


Because the Listen event only has four arguments: integer
Channel
, string
Name
, key
ID
and string
Message
.
to confirm.

Yours has six (below). string
h
and integer
number
are not used. You should collect the whole of your listen event together and use
message
 in place of
h
and
number
... doesn't seem to be used?
listen(integer channel, string name, key id, string h, integer number, string message)

Also,
intensity
 (also inside your listen)
.

I've not read the whole script, but you'll have to at least follow Steph's advice as well as mine before you'll be able to get this to even compile.

Alright, i will try that. but I used "h" directly underneath the the listen in the "if/else" statement. Unless i wrote that wrong...

Link to comment
Share on other sites


Rolig Loon wrote:

The problems you are having are problems with logic, and only incidentally with syntax.  At this point, it's smartest to step back and look at your original script -- before you started adding things to it.  If you must use a borrowed script instead of writing one for yourself, never start modifying it until you understand what it does. Otherwise, you'll just create a mess.

So, work through the original script line by line.  Ask yourself what will happen when someone touches it.  What things happen, and it what logical order? What are all of the various bits in each event meant to do?  What would happen if they were not there?  When you have all of that figured out, test it.  Try changing a few things at a time to see whether you understood correctly.  If you did,
then
get bolder and start making more substantial changes.  But always be prepared to back up, rip out your changes, and try again from the last stage when you had a working script.

That's the way scripting is done, by keeping the logic clear in your head at all times.

BTW, I see that you tried to add the switch that we discussed in
.  It's not quite there yet, but you're getting close.

Apart from logic, which really is the heart of what you need to address, there's good reason to learn some basic syntax. I suggest spending time with some fundamental tutorials >>>

I did get the mesh working properlly, I had to go a different route and make a HUD controlled resizer that just made the speaker get bigger and smaller, instead of creating animated mesh.  But in terms of this, i will just have to step back for a moment, i have been trying to figure this out for 4 hours strait already.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3011 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...