Variable help

Hopefully this question makes sense and yes I know the code isn’t properly set up but it’s just to show a visual to help understand what my question is. The part of the game I am working is where the player can pick 4 of 8 farmhands and I was not sure how to set up the code in order to set up the variable as parts of the game change depending on the choices of farmhands and of course I can’t guess who people would pick as there are a few different combinations that could be chosen. As I don’t want to keep using generic terms for when writing about the farmhands I would like to be able to put in their names if that is possible to do.

Martin – No direct farming experience, but has worked in various factories looking for a change in career
    *set farmhand +1
    *set inexperencedhand1 or 2 or 3 or 4
Samuel – 2 years experience working on a farm, enjoys being in nature, is a plant whisperer
    *set farmhand +1
    *set experencedhand 1 or 2 or 3 or 4
Frederick – 5 years experience working on a farm, has had short stays at various farms but don’t know why but seems like a hard worker
    *set farmhand +1
    *set experencedhand 1 or 2 or 3 or 4
Daniel – No direct farm experience, new arrival from England, worked as a shopkeeper
    *set farmhand +1
     *set inexperencedhand1 or 2 or 3 or 4
Samantha – 3 years experience working on a farm
    *set farmhand +1
    *set experencedhand 1 or 2 or 3 or 4
Molly – 4 years experience working on a farm, seems to have a way with plants (according to her anyway)
    *set farmhand +1
    *set experencedhand 1 or 2 or 3 or 4
Margret – No direct farm experience, former telephone operator in Toronto and decided to move for a simpler life style, claims to have a very nice garden at home
    *set farmhand +1
    *set inexperencedhand1 or 2 or 3 or 4
Lucy – No direct farm experience, former secretary, claims to be able to keep plants alive
    *set farmhand +1
    *set inexperencedhand1 or 2 or 3 or 4

The easiest solution, or at least the first one that comes to mind, is to have a set of booleans to determine who is a farmhand like this:

*create is_martin_farmhand false
*create is_samuel_farmhan false

That way, you can have diverging paths like so:

*if (is_martin_farmhand)
   Martin works.
*if (is_samuel_farmhand)
   Samuel works.

Although, it’s a slight ordeal if you want to just list off names.

2 Likes

Or you can just create a string;

*create farmhand " "

In this way, you can avoid creating unnecessary variables;

*if (farmhand = "Martin")
  Martin works.

*if (farmhand = "Samuel")
  Samuel works.
4 Likes

Or one more:

*create farmhand “ “

Set farmhand to Martin or Samuel.
Then in the text type:

${farmhand} works.

3 Likes

That works too! I just prefer Booleans, so I won’t end up with messes like this:

*if ((farmhand_1 = "Martin") or (farmhand_2 = "Martin"))
   Martin works.
1 Like

Cause at the moment I will be having the game set up like this and I wanted to know if it was possible to have the people’s names like below

If farm hand are 4 experienced
"Blah Blah Blah" ${farmhand} says
If farm hands are 2 inexperienced and 2 experienced
"Blah Blah Blah" ${farmhand} says
If farm hands are 1 inexperienced and 3 experienced
"Blah Blah Blah" ${farmhand} says
If farm hands are 3 inexperienced and 1 experienced
"Blah Blah Blah" ${farmhand} says

Instead of

If farm hand are 4 experienced
"Blah Blah Blah" they say
If farm hands are 2 inexperienced and 2 experienced
"Blah Blah Blah" a farmhand says
If farm hands are 1 inexperienced and 3 experienced
"Blah Blah Blah" one of them says
If farm hands are 3 inexperienced and 1 experienced
"Blah Blah Blah" they say

In all these sentences, should ${farmhand} be the first person chosen? Or do you need to print the four names?

Probably you need to split your variables. On one side, keep an “experience” count, so you know how many of the chosen people are experienced. Then you can keep a list of names as people are chosen.

*set farmhand[0] ”Martin"

So you can print them (remember to create the variables)

I’m wondering if something like this would work for you:

[Startup]
*create farmhand1 "Unknown"
*create farmhand2 "Unknown"
*create farmhand3 "Unknown"
*create farmhand4 "Unknown"

*create fh1experience 0
*create fh2experience 0
*create fh3experience 0
*create fh4experience 0

[Choosing Farmhands]
*choice
    #Martin – No direct farming experience, but has worked in various factories looking for a change in career
        *set farmhand1 "Martin"
        *set fh1experience 1 or 2 or 3 or 4
            Choose your second farmhand.
                *choice
                    #Samuel – 2 years experience working on a farm, enjoys being in nature, is a plant whisperer
                        *set farmhand2 "Samuel"
                        *set fh2experience 1 or 2 or 3 or 4
                            Choose your third farmhand.
                                *choice
                                    #Frederick – 5 years experience working on a farm, has had short stays at various farms but don’t know why but seems like a hard worker
                                        *set farmhand3 "Frederick"
                                        *set fh3experience 1 or 2 or 3 or 4
                                            Choose your last farmhand.
                                                *choice
                                                    #Daniel – No direct farm experience, new arrival from England, worked as a shopkeeper
                                                        *set farmhand4 "Daniel"
                                                        *set fh4experience 1 or 2 or 3 or 4
                                                        *finish

[Dialogue Scene]
You decide to ask your farmhands for their opinions.

*if (fh1experience = 4)
    "Blah blah blah blah" ${farmhand1} says.
    *finish
*if (fh2experience = 4)
    "Blah blah blah blah" ${farmhand2} says.
    *finish
*if (fh3experience = 4)
    "Blah blah blah blah" ${farmhand3} says.
    *finish
*if (fh4experience = 4)
    "Blah blah blah blah" ${farmhand4} says.
    *finish

This might be a little different than what you’re asking, but hopefully it points you in the right direction.

1 Like

I would do something like this working from @ItsAidrian 's suggestion with a few minor changes to the code and an extra variable. Just to make the coding for the farmhands cleaner to do and simpler.

in startup.txt

*create hired 0
*create farmhand1 "Unknown"
*create farmhand2 "Unknown"
*create farmhand3 "Unknown"
*create farmhand4 "Unknown"
*create fh1experience 0
*create fh2experience 0
*create fh3experience 0
*create fh4experience 0

Then when choosing your farmhands code it like this; (Only doing it for two choices just so you can see what I mean)

*label hire_farmhands
*if (hired = 2)
    *goto youre_hired
*choice
    *hide_reuse #Martin – No direct farming experience, but has worked in various factories looking for a change in career.
        *if (farmhand1 = "unknown")
            *set farmhand1 "Martin"
            *set fh1experience 2
            *set hired + 1
            *goto hire_farmhands
        *elseif (farmhand2 = "unknown")
            *set farmhand2 "Martin"
            *set fh2experience 2
            *set hired + 1
            *goto hire_farmhands
        *elseif (farmhand3 = "unknown")
            *set farmhand3 "Martin"
            *set fh3experience 2
            *set hired + 1
            *goto hire_farmhands
        *else
            *set farmhand4 "Martin"
            *set fh4experience 2
            *set hired + 1
            *goto hire_farmhands
    *hide_reuse #Samuel – 2 years experience working on a farm, enjoys being in nature, is a plant whisperer.
        *if (farmhand1 = "unknown")
            *set farmhand1 "Samuel"
            *set fh1experience 3
            *set hired + 1
            *goto hire_farmhands
        *elseif (farmhand2 = "unknown")
            *set farmhand2 "Samuel"
            *set fh2experience 3
            *set hired + 1
            *goto hire_farmhands
        *elseif (farmhand3 = "unknown")
            *set farmhand3 "Samuel"
            *set fh3experience 3
            *set hired + 1
            *goto hire_farmhands
        *else
            *set farmhand4 "Samuel"
            *set fh4experience 3
            *set hired + 1
            *goto hire_farmhands
2 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.