Let's say I want to let player pick a class. And after that I want to show him a button - different one for each class.
So right now working code looks like this:
Code: Select all
init:
image template_image = "/gui/window_icon.png"
screen warrior_screen:
add "template_image"
text "warrior"
screen thief_screen:
add "template_image"
text "thief"
screen wizard_screen:
add "template_image"
text "wizard"
screen test_thingy:
if player_class == 'warrior': # button for the warrior character
button:
xsize 250
use warrior_screen
action NullAction
elif player_class == 'thief': # button for the thief character
button:
xsize 250
use thief_screen
action NullAction
elif player_class == 'wizard': # button for the wizard character
button:
xsize 250
use wizard_screen
action NullAction
label start:
menu:
"Pick a class"
"Warrior":
$ player_class = 'warrior'
"Thief":
$ player_class = 'thief'
"Wizard":
$ player_class = 'wizard'
call screen test_thingy
return
The problem is with the screen test_thingy. It looks fine with 3 classes, but what if I need a few dozens of them?
Also only thing that changes in there is the name of the screen they are using, depending on what class (player_class) is chosen by the player:
Code: Select all
screen test_thingy:
if player_class == 'warrior':
button:
xsize 250
use warrior_screen
action NullAction
elif player_class == 'thief':
button:
xsize 250
use thief_screen
action NullAction
elif player_class == 'wizard':
button:
xsize 250
use wizard_screen
action NullAction
What I'm asking is - is that possible to add a variable to the use statement?
Something like (following example doesn't work):
Code: Select all
screen test_thingy:
button:
xsize 250
use "[player_class]_screen"
action NullAction