RedCliffs Issue (placing units based on their type)


Sorry. Beginner here, and I imagine my mistake is simple, but I’m not sure how to proceed

I’m trying to dynamically place my characters based on their type. I’d like to eventually select my units dynamically as well, but this is the beginning.

I am trying to set global last in the choice function and then access it in the place function, but it’s always blank when I look at it in the log.

Thanks in advance!

def roundStartFunction(state):
    global counter
    global last
    counter = 0
    last = 0

def choiceFunction(state):
    type = myTeam[counter % 9][0]
    last = type
    return type
def placeFunction(state):
    n = myTeam[counter % 9][1]
    counter += 1
    game.log("OUTPUT = ", last)
    return 5
    if last == "warrior":
        return 0
    if last == "knight":```

Just looks like you are missing the global call in your placeFunction to me.
global last like you have in your roundStartFunction

1 Like

Perfect! Thanks!

I added “global counter” to the placeFunction as well. I’m not sure why it was able to increment the global counter from within the function scope? Or was the value persisting within the function?