Code: Select all
#display the plants:
$ xfield = 1
$ yfield = 1
#field1, for each plant
if 'plant1' in field1:
if '0' in field1:
show plantnew zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
size (109, 92)
if '1' in field1:
show plant1 zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
zoom 0.60
if '2' in field1:
show plant1 zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if 'plant2' in field1:
if '0' in field1:
show plantnew zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field1:
show plant2 zorder 2 as ha1 at Position(ypos=plant_ypos-15, yanchor='bottom', xpos=plant_xpos+120*(xfield-1)+20, xanchor='left'):
zoom 0.60
if '2' in field1:
show plant2 zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if 'plant3' in field1:
if '0' in field1:
show plantnew zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field1:
show plant3_new zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if '2' in field1:
show plant3_ripe zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if 'plant4' in field1:
if '0' in field1:
show plantnew zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field1:
show plant4_new zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if '2' in field1:
show plant4_ripe zorder 2 as ha1 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
#field2, for each plant
$ xfield = 2
$ yfield = 1
if 'plant1' in field2:
if '0' in field2:
show plantnew zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field2:
show plant1 zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
zoom 0.60
if '2' in field2:
show plant1 zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if 'plant2' in field2:
if '0' in field2:
show plantnew zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field2:
show plant2 zorder 2 as ha2 at Position(ypos=plant_ypos-15, yanchor='bottom', xpos=plant_xpos+120*(xfield-1)+20, xanchor='left'):
zoom 0.60
if '2' in field2:
show plant2 zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if 'plant3' in field2:
if '0' in field2:
show plantnew zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field2:
show plant3_new zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if '2' in field2:
show plant3_ripe zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if 'plant4' in field2:
if '0' in field2:
show plantnew zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left'):
if '1' in field2:
show plant4_new zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')
if '2' in field2:
show plant4_ripe zorder 2 as ha2 at Position(ypos=plant_ypos, yanchor='bottom', xpos=plant_xpos+120*(xfield-1), xanchor='left')1. How could I use the same code in a loop that repeats 16 times?
The only difference in the code parts is the 'field' variable (field1, field2, field3...) and 'as' statement (as ha1, as ha2, ...).
2. Is there a way to use a string as variable name? Something like:
fieldvar = 'field' + fieldnum
if '0' in fieldvar: # replacing if '0' in field1:, if '0' in field2:, ...


