de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 If... and/or statements?
PostPosted: Sat Aug 06, 2011 7:01 am 
Offline
Veteran
User avatar
Is this possible?

Let's say I have a script I want to check if the player has a paddle OR hairbrush as a toy (toys.paddle and/or toys.hairbrush are true).

Do I have to do a multi-level "if... else" or can I use some sort of "if toy a exists... and/or if toy b exists, do the following..." syntax?

Hypothetical Example 1
if(loadBoolean("toys.paddle")) OR (loadBoolean("toys.hairbrush"))
show("You have the right toys")
else
show ("You need either a hairbrush or a paddle to play.")

Hypothetical Example 2
if(loadBoolean("toys.paddle")) AND (loadBoolean("toys.hairbrush"))
show("You have the right toys")
else
show ("You need both a hairbrush and a paddle to play.")

Is something like this doable?


Top
 Profile Send private message 
 
 Re: If... and/or statements?
PostPosted: Sat Aug 06, 2011 9:42 am 
Offline
Site Admin
User avatar
The lines above are nearly good :

Code:
if(loadBoolean("toys.paddle") | loadBoolean("toys.hairbrush"))
show("You have the right toys")
else
show ("You need either a hairbrush or a paddle to play.")

if(loadBoolean("toys.paddle") & loadBoolean("toys.hairbrush"))
show("You have the right toys")
else
show ("You need both a hairbrush and a paddle to play.")


You may also look for loadFirstTrue() for the first one above
Code:
def have = loadFirstTrue("toys.paddle", "toys.hairbrush")
if(have==null)
  show ("You need either a hairbrush or a paddle to play.")
elseif(have=="toys.paddle")
  show("Use a paddle")
else
  show("Use an hairbrush")

I added loadFirstTrue() for that but the code above is not as simple as I would like, but it add a thing : priority between items.


Top
 Profile Send private message 
 
 Re: If... and/or statements?
PostPosted: Sat Aug 06, 2011 9:46 am 
Offline
Veteran
User avatar
Whoa, awesome! So it's that | "pipe" thing, eh? Cool to know!

The first example(s) is exactly what I needed... perfect!

The second one... I don't think it matters that it's a bit more complicated, since it adds a very useful feature though one probably not used as often as the first option.

Will use these right away in my current work... thank you for the quick reply!


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.