ID:1616373
 
(See the best response by Zecronious.)
Code:
mob/verb/create_movie2()
//src.money-=src.actors*5000
//src << "$-[5000*src.actors] for paying actors"
var/namemovie
do
namemovie=input("What is the name of the movie?") as text
while(namemovie=="")
var/input_category=input("Which category?") in list("Drama", "Foreign", "Action", "Suspense", "Cartoon", "Adventure","Comedy","Documentary","Horror", "Musical", "Mystery","Romance","Sci-fi")
var/obj/movie/m=new /obj/movie(input_category, namemovie);
var/input_first_audience=input("Which will be the target audience for this movie?") in list("Children","Teenagers","Adults","Mature","Everyone")
var/newpoints=0
switch(input_category)
if("Drama")
switch(input_first_audience)
if("Children")
newpoints=2
if("Teenagers")
newpoints=3
if("Adults")
newpoints=5
if("Mature")
newpoints=4
if("Everyone")
newpoints=3
if("Foreign")
switch(input_first_audience)
if("Children")
newpoints=3
if("Teenagers")
newpoints=3
if("Adults")
newpoints=4
if("Mature")
newpoints=4
if("Everyone")
newpoints=4


Problem description:This is how I did it. Is there any better way to do it? I call them nested because loops like that are also called nested
Looks good to me. If there's multiple values which leads to the same newpoint value, you can combine the switch if().

Ex:
switch(input_first_audience)
if("Children")
newpoints=2
if("Teenagers", "Everyone") // If the value is either Teenagers or Everyone
newpoints=3
if("Mature")
newpoints=4
if("Adults")
newpoints=5
else // An example of a safety check. Note that none of the above are else if since the first appearance of else will be treated as the final option followed by that if condition
world.log << "Missing value: [input_first_audience]"

if("Foreign")
switch(input_first_audience)
if("Children", "Teenagers")
newpoints=3
else // Anything aside from the above... whih can be also done as if("Adults", "Mature","Everyone")
newpoints=4
Best response
A nested switch statement works but is lengthy and isn't easy to maintain. I'd suggest using associative lists.

mob/var
dramaPoints = list("Children" = 2, "Teenagers" = 3, "Adults" = 5, "Mature" = 4, "Everyone" = 3)
foreignPoints = list("Children" = 3, "Teenagers" = 3, "Adults" = 4, "Mature" = 4, "Everyone" = 4)

mob/verb/create_movie2()

//src.money-=src.actors*5000
//src << "$-[5000*src.actors] for paying actors"

// Name the movie
var/namemovie = ""
while(namemovie == "")
namemovie = input("What is the name of the movie?") as text

// Select movie category
var/categories = list("Drama", "Foreign", "Action", "Suspense", "Cartoon", "Adventure","Comedy","Documentary","Horror", "Musical", "Mystery","Romance","Sci-fi")
var/input_category = input("Which category?") in categories
var/obj/movie/m = new /obj/movie(input_category, namemovie)

// Select auidence
var/audiences = list("Children","Teenagers","Adults","Mature","Everyone")
var/input_first_audience = input("Which will be the target audience for this movie?") in audiences

// Calculate points
var/newpoints = 0

switch(input_category)
if("Drama")
newpoints = dramaPoints[input_first_audience]

if("Foreign")
newpoints = foreignPoints[input_first_audience]