Jump to content

Multiple Commands per Button?


Fanta UwU
 Share

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

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

Recommended Posts

I have a materials texture HUD script that I want to make it... well. Perfect. I figured I'd ask here and see what I can do.

It is perfectly usable and fine and all, but the one thing I want to figure out is HOW I can make it do multiple lists per button instead of just one list that comes first per button. So I can use ONE button to apply to multiple faces at once, while keeping how the script works and not just a entire overhaul of it.

It was something I've kind of built and butchered on my own with little knowledge as I don't really want to use a 1k+ texture HUD that isn't even full perm, is difficult to understand, and just.... overly complicated tbh.

This I found extremely easy for others and myself to use, but... It only listens to one command per linked child prim (or button on the HUD, to put it simply). I want to figure out what I can change to make it listen to more than one 'list' and still use the same layout of using the list function in such a way.

_____

integer listener = -2000;

list lTex = [
"button_name", "diffuse=dUUID", "normals=nUUID","specular=sUUID", 100, 10, -1, 0,

"ListEnd"];

default
{

  state_entry()
  {
      string dUUID = llList2String(lTex,1);
      string nUUID = llList2String(lTex,2);
      string sUUID = llList2String(lTex,3);
      integer iGl = llList2Integer(lTex,4);
      integer iEnv = llList2Integer(lTex,5);
      integer iLink = llList2Integer(lTex,6);
      integer iFace = llList2Integer(lTex,7);
      llSetLinkPrimitiveParamsFast
(PRIM_LINK_TARGET,[PRIM_TEXTURE,iFace,dUUID,<1,1,0>,ZERO_VECTOR,0.0,PRIM_NORMAL,iFace,nUUID,<1,1,0>,ZERO_VECTOR,0.0,PRIM_SPECULAR,iFace,sUUID,<1,1,0>,ZERO_VECTOR,0.0,<1,1,1>,iGl,iEnv]); 
      llListen (listener,"","","");
}

______

I think the issue is PRIM_LINK_TARGET listens to only one command, as PRIM_LINK_TARGET I believe applies to the linked prim name of the button on the HUD? I can maybe replace it with something else that might make it listen to more than one list per button?

This isn't the whole/both (as the HUD has a script as well for obvious reasons) script as I do actually sell this script on MP and would honestly love to update it and send out to people who have purchased it. To be able to do more than one list per linked prim button. So people do not have to put multiple scripts in the mesh for this, making it take up more resources than necessary. But this is the main function of the script, I believe!

Thank you to everyone in advance for helping me with this!

If more info on the script is needed, please do send me a DM through forums, but the script above should cover it. (Which hopefully would not end up in a complete overhaul of the list function...)

Link to comment
Share on other sites

1 hour ago, Muiregwen said:

I think the issue is PRIM_LINK_TARGET listens to only one command, as PRIM_LINK_TARGET I believe applies to the linked prim name of the button on the HUD?

PRIM_LINK_TARGET is one of the specifications that must be inside the list of stuff, as it specifies by means of a following integer the number of the linkset to which the next stuff is to be applied, so something like

integer linknum = 2;

llSetLinkPrimitiveParamsFast( linknum, [PRIM_TEXTURE, integer face, string texture, vector offset, vector repeat, float angle, 
                 PRIM_LINK_TARGET, 3, PRIM_TEXTURE....,
                          PRIM_LINK_TARGET, 4, PRIM_TEXTURE, ....]);

starts at child 2 and sets a texture on a particular face using the next few entries in the list, and then says "Now go to child 3", and starts reeling off a new load of stuff to be done to number 3, then child 4, and so on. You can keep on adding another PRIM_LINK_TARGET, then a number, then whatever is to be done to it.

The integers that follow PRIM_LINK_TARGET must be defined or worked out to correspond to the buttons you want to texture, and you must also know the face number, and the string or UUID or the texture is going to vary, but typically the repeat vector will be <1.0,1.0,0.0>, the offset <0.0,0.0,0.0> and the angle 0.0.

 

If however you are going to be picking up small sections of one particular texture to apply to the buttons then repeats are going to be less than 1.0 and offsets will vary between -1.0 and 1.0.  (and yes, better to do it that way than have an individual 512x512 for each of the 16 or so buttons in your hud - it has been done and charged money for)

Edited by Profaitchikenz Haiku
  • Like 1
Link to comment
Share on other sites

59 minutes ago, Jenna Huntsman said:

The above script is incomplete - you've only given us the state_entry event, which only runs when the script first starts - the touch event is the one that really matters.

OH! The main bulk of the script is in the mesh; holds the list of what each button is supposed to do and turns the list into a string with the parameters of the list’s function.

The touch_start gets the link name of the button and sends it to the listener/receiver and that would be about all it does in the HUDs side of things.

I am thinking that doing something with the strided function will read it differently.  I have been unable to get it to actually work in terms of it being something functional though. 

Link to comment
Share on other sites

1 hour ago, Muiregwen said:

So I can use ONE button to apply to multiple faces at once

You need to therefore specify first the child number, via PRIM_LINK_TARGET, then the face number, and having done it for one face, you repeat PRIM_LINK_TARGET with the same child number, but specify a new face number, tedious,. I know.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

"He had a large map, which was perfectly blank.

The crew were much pleased

for they found it to be

a map they could all understand "

:)

 

( I know, you had second thoughts, I just couldn't resist quoting Lewis Caroll for an empty response :)

Edited by Profaitchikenz Haiku
  • Like 1
  • Haha 1
Link to comment
Share on other sites

1 hour ago, Fanta UwU said:

OH! The main bulk of the script is in the mesh; holds the list of what each button is supposed to do and turns the list into a string with the parameters of the list’s function.

The touch_start gets the link name of the button and sends it to the listener/receiver and that would be about all it does in the HUDs side of things.

I am thinking that doing something with the strided function will read it differently.  I have been unable to get it to actually work in terms of it being something functional though. 

I'd recommend against doing bulk data storage within the mesh itself, as (presumably) most of the time it won't be needed and is just sat there eating server resources.

Regardless, with your current method I'd probably use JSON for this - below is a simple example of how you can use JSON to store the appropriate data for a given button. As to actually applying it, as Prof said above you'll want to use llSetLinkPrimitiveParamsFast in combo with PRIM_LINK_TARGET. I like JSON over strided lists as you don't need to maintain a constant offset, and you don't need to use multiple to store different forms of data (e.g. the materials themselves, the actions of the buttons, etc.).

Experiment with how you store the data, again, below is a very simple example but shows the concept.

string JSON = "{\"buttons\":{\"button1\":{\"link\":3,\"face\":[1,2],\"mat\":\"wood\"},\"button2\":{\"link\":3,\"face\":[3,4],\"mat\":\"glass\"},\"button3\":{\"link\":3,\"face\":[1,2],\"mat\":\"glass\"}},\"mats\":{\"wood\":[\"diffKey\",\"normKey\",\"specKey\"],\"glass\":[\"gDiffKey\",\"gNormKey\",\"gSpecKey\"]}}";

default
{
    state_entry()
    {
        llSay(0, "JsonExample!");
    }

    touch_start(integer total_number)
    {
        llSay(0, "Getting data...");
        string action = llJsonGetValue(JSON,["buttons","button1"]); //returns the JSON for container button1
        llSay(0,"button1 = " + action);
        string material = llJsonGetValue(JSON,["mats",llJsonGetValue(action,["mat"]),0]); //returns the diffuse key for the material "wood"
        llSay(0,"wood diffuse = " + material);
    }
}

 

Edited by Jenna Huntsman
  • Thanks 1
Link to comment
Share on other sites

2 hours ago, Profaitchikenz Haiku said:

( I know, you had second thoughts, I just couldn't resist quoting Lewis Caroll for an empty response :)

i misread the OP, unlike somebody named Prof who never. i like the poem tho

  • Like 2
Link to comment
Share on other sites

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