Difference between revisions of "Talk:If"

From Second Life Wiki
Jump to navigation Jump to search
(Added info about parse order for if statements)
Line 22: Line 22:


::Sounds like a good idea then. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 14:01, 29 October 2008 (UTC)
::Sounds like a good idea then. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 14:01, 29 October 2008 (UTC)
It seems LSL parses if statements right to left. Which might cause issues for setting variables in if statements.<br />
Ex: if(a==3 && (a=3) && (a=4))llSay(0, "After statement: "+(string)a);<br />
This will output "After statement: 3"</nowiki>
--[[User:Jasdac Stockholm|Jasdac Stockholm]] ([[User talk:Jasdac Stockholm|talk]]) 06:43, 31 January 2015 (PST)

Revision as of 06:43, 31 January 2015

I would appreciate an example that shows the appropriate "if / elseif / else" construction. I assume that this will work:

 if (a == "Loren") {
   llSay(0, "Lorem ipsum sic amet!");
 } else if (a == "Bob") {
   llSay(0, "Babble dabble rabble rouse.");
 } else {
   llSay(0, "Gobbledygook?  or English?");
 }

- Kendown Baroque 12:12, 29 August 2007 (PDT)



This page is missing documentation on one of the major flaws of the LSL if() else() statement. When writing an if() else(), residents need to know that there is a limit of 23 else() statements (not including the first if() statement). Further documentation of this limitation including a workaround can be found in the if() statement article at http://rpgstats.com/wiki/index.php?=Ifelse . I would add this documentation myself but I'm not sure how or where in the article to add it.

Kaiden Ruxton 23:47, 18 January 2008 (PST)

It looks like this limit is no longer in existence. i tested it with 50 else if and got a friend who tested about 120 without an error in LSL2 or mono. the connected jira VWR-811 is marked as resolved since about a week too. So the info can be removed?
Zai signature.png Lynch (talk|contribs) 03:20, 29 October 2008 (UTC)
Sounds like a good idea then. -- Strife (talk|contribs) 14:01, 29 October 2008 (UTC)



It seems LSL parses if statements right to left. Which might cause issues for setting variables in if statements.
Ex: if(a==3 && (a=3) && (a=4))llSay(0, "After statement: "+(string)a);
This will output "After statement: 3"</nowiki> --Jasdac Stockholm (talk) 06:43, 31 January 2015 (PST)