Jump to content

logical variable


Xiija
 Share

Recommended Posts

 is there any way to make this a one liner?

 string sound =  llGetInventoryName(INVENTORY_SOUND, 0);
 if( sound == "") { sound = "e87dab12-e497-72a3-581e-2b8a8254b521"; }
         

i tried the normal thing you would do outside SL, but.. NEWP lol

 string sound =  llGetInventoryName(INVENTORY_SOUND, 0) || "e87dab12-e497-72a3-581e-2b8a8254b521" ;

Edited by Xiija
Link to comment
Share on other sites

I mean it's still 2 lines, but if you want to be fancy:

 string sound;
 if(sound=llGetInventoryName(INVENTORY_SOUND, 0)){}else sound="e87dab12-e497-72a3-581e-2b8a8254b521";

should do the same thing.

Edit: actually, as an academic exercise:

 string sound = llGetSubString(
   llGetInventoryName(INVENTORY_SOUND, 0))+
   "e87dab12-e497-72a3-581e-2b8a8254b521",
   0,35);

 

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

if ( !llGetInventoryNumber(INVENTORY_SOUND) ) { sound = "e87dab12-e497-72a3-581e-2b8a8254b521"; }

Well, you still need to have the line

string sound;

so I guess it's still two lines.   :(

 

Edited by Rolig Loon
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

10 minutes ago, Rolig Loon said:

if ( !llGetInventoryNumber(INVENTORY_SOUND) ) { sound = "e87dab12-e497-72a3-581e-2b8a8254b521"; }

You can roll if statements into a llList2* (a trick I learned form @Mollymews)

string sound = llList2String([llGetInventoryName(INVENTORY_SOUND,0),"UUID"],!llGetInventoryNumber(INVENTORY_SOUND) );

the '!' in this case is necessary to 'normalize' the inventory number to either a 0 or a 1 index.

you can think of this kind of like the ? ternary operator in C :

string sound = llGetInventoryNumber(INVENTORY_SOUND) ? llGetInventoryName(INVENTORY_SOUND,0) : "UUID";

 

Edited by Quistess Alpha
  • Like 4
Link to comment
Share on other sites

Not to drift too far off the theme, but I would add @Dora Gustafson, who had an easy facility with math and a playful creative edge. I miss her quiet patience. We have all learned from each other and from some talented scripters who are no longer with us for one reason or another. There's risk in starting to name all the people who have enriched the collective toolkit, but there have been a few clear standouts along the way.

  • Like 3
Link to comment
Share on other sites

1 hour ago, Innula Zenovka said:

i miss some other old school people as well, like @Dora Gustafson @Jopsy Pendragon @Sei Lisa @Grandma Bates @Pedro Oval @Strife Onizuka @Adeon Writer @Becky Pippen @Haravikk Mistral @Cubey Terra @Argent Stonecutterto name some. Some of who used to post across the street as well. I even miss @LepreKhaun sometimes, who knew their stuff even when our scripting conversations (in a previous life) could get quite robust sometimes

but this said life goes on, and we still got old school, with their vast knowledge of all things LSL, like @Rolig Loon @Qie Niangao @NeoBokrug Elytis and you @Innula Zenovka and a few others who pop in now and again

big ups to a bunch of other people as well who have since carried this forum in good stead

 

edit add

other old school person is @James Argonaut who build the first vehicle before there was vehicles as we know them today

for posterity here is the link: https://secondlife.fandom.com/wiki/James_Argonaut_Car_Script

is an impulse engine.  I used this script as the basis to make a hoverboard on Inworldz when they first started and never had vehicles either. Only problem was that to keep it flying then had to hammer the server on a really fast time which caused all kinds of issues for the server. But still was way cool, blasting across the public access regions with heaps  of sound, glow and particle trails. brawwwmmm!! old school

Edited by Mollymews
  • Like 7
Link to comment
Share on other sites

12 hours ago, Innula Zenovka said:

i forgot about Chalice. I first saw Chalice on the Linden Weapons Testing Sandbox region back in the day. There was nothing that Chalice didn't know about scripting physical objects

 

edit delete some stuff I really shouldn't talk about in public

Edited by Mollymews
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...