Jump to content
Sign in to follow this  
Followers 1
Ah!

If - else.........How many ?

Recommended Posts

Anyone know how many Earwigo "If - else" functions can be nested ?

Share this post


Link to post

Theoretically, the only limit might be in performance. I believe the cartridge would experience slowness before you have server problems.

 

I hope you’d be able to avoid such a structure by being smart about what you’re testing and grouping similar arguments together. 

Share this post


Link to post
15 hours ago, Ranger Fox said:

Theoretically, the only limit might be in performance. I believe the cartridge would experience slowness before you have server problems.

 

I hope you’d be able to avoid such a structure by being smart about what you’re testing and grouping similar arguments together. 

Thanks for your reply.   Unfortunately, despite my name - Alan Smart - being smart is my biggest problem.   My other problem, at the moment, is I have 30+ images and I wish to change the  media of a zone depending on the value of a variable.   That is,  if the variable =1 the zone has image A, if variable = 2 the zone has image B  etc.  It looks like it should be simple but I can't do it.   In the change media option the choice is from the list of media only so I created expressions to compare media name  (or visible is the only choice) to the value of a variable.  I then created an IF ELSE function to go through and find the matching media to the variable.   I gave the media numerical names to match the variable range.    I think this might be trying to compare a string with a number.   Any suggestions?

 

Edited by Ah!
Forgot something

Share this post


Link to post
7 hours ago, Ah! said:

I have 30+ images and I wish to change the  media of a zone depending on the value of a variable.   That is,  if the variable =1 the zone has image A, if variable = 2 the zone has image B  etc. 

 

How does this variable get its new values?

 

Wouldn't it be possible to assign the media its new resource at the same time?

 

If not, maybe you could use a table where each item would be a media.

Then the zone media would be assigned by a LUA statement like this one:

 

zmediaMyZone = myTableOfZmedia[myVariable]

 

 

Share this post


Link to post
1 hour ago, Tungstène said:

 

How does this variable get its new values?

 

Wouldn't it be possible to assign the media its new resource at the same time?

 

If not, maybe you could use a table where each item would be a media.

Then the zone media would be assigned by a LUA statement like this one:

 

zmediaMyZone = myTableOfZmedia[myVariable]

 

 

 

Thanks for your reply.

The variable gets it value from the actions of the player when in a zone.   

I have now solved this problem.  Although I'm not very familiar with Lua I did some searching and found the function  "tostring(v)" .  Referring to my above reply, I used  "tostring(v)"  to change the numerical variable to a string before comparing it to the name of the media variables.  This was all I had to do to make everything I had written work OK.   

Thanks again to all.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  
Followers 1

×
×
  • Create New...