Illegal mixing of tabs and spaces

When I check my stats screen:

This is your stat screen.

*stat_chart
 text Name
 text Surname
 text Age
 text Power
 text Gender
 text wealth

 text Skills
 percent Agility
 percent Charm
 percent Intelligence

 text Relations
 percent Anemos
 percent Kasai
 percent Dahlia
 percent Amanzi
 percent Parents

*temp current_inventory ""

*if (item_amount > 0)
	*if (has_food)
		*set current_inventory &" food"
	*if (has_money)
		*set current_inventory &" money"
	*if (has_clothes)
		*set current_inventory &" clothes"
	*if (has_tools)
		*set current_inventory &" tools"
	*if (has_books)
		*set current_inventory &" books"

*else
	*set current_inventory " None."

An error shows saying that

choicescript_stats line 26: Illegal mixing of spaces and tabs; this line has a tab, but there were spaces on line 21

Line 21 is

 percent Parents

can anyone help

All of the text and percent things set here have been indented by one space. Removing the indentation should fix the error hopefully?

*stat_chart
 text Name
 text Surname
 text Age
 text Power
 text Gender
 text wealth

 text Skills
 percent Agility
 percent Charm
 percent Intelligence

 text Relations
 percent Anemos
 percent Kasai
 percent Dahlia
 percent Amanzi
 percent Parents

then it says it needs at least one row which is the indentations so that didn’t work thank you though

Hm possibly indent the stats with tabs instead of a space?

that didnt work either but now i messed up this whole part it gave me a super long list of errors dealing with this

This is your stat screen.
	
*stat_chart
 text Name
 text Surname
 text Age
 text Power
 text Gender
 text wealth
	
 text Skills
 percent Agility
 percent Charm
 percent Intelligence
	
 text Relations
 percent Anemos
 percent Kasai
 percent Dahlia
 percent Amanzi
 percent Parents

and the error was of course

Illegal mixing of spaces and tabs; this line has a tab, but there were spaces on-

then it gave me a super long list of these lines

but i never had a problem with these lines before

It doesn’t seem like you have spaces and tabs on the same line, but you have tabs in the empty lines between each set of stats, and spaces used to indent each stat. Try removing all tabs or unifying the indentation type using your development environment’s indentation tools or Find-and-Replace tool, perhaps?

I have no idea on how to do that
Or how i did that

That’s alright, it can be complex when starting out. Your best bet is to have a read through these threads and find a suitable solution:

https://forum.choiceofgames.com/search?q=illegal%20mixing%20tabs%20spaces

1 Like

before i start searching wtf is a tab cause right now im thinking it’s this

image

It is! It does two things mostly:

  1. Transitions between things the keyboard can select onscreen such as text inputs or buttons.
  2. Creates a type of indentation in text.
	Indented text (tab).
    Indented text (spaces).
Not indented text.

If you click and drag your mouse over the indented text above you should be able to see the difference between tab and space indents.

thank you this helped
and the problem is solved

1 Like

If using Microsoft Word, you can click options to literally view where you have tabs and spaces:

File --> Options --> Display

*set current_inventory &" food"

Something else nobody has noticed:

This doesn’t really make sense and is formatted incorrectly. This might be the source of some of your error messages.

1 Like

That’s just concatenation, and it actually is formatted in a manner that functions without error. I’m sure it could have been formatted more obviously and explicitly like this:

*set current_inventory (current_inventory & " food")

…but that’s unnecessary. In the same way that it’s perfectly normal and acceptable to code:

*if has_food

…and unnecessary to explicitly define it as:

*if has_food = true

The concatenation operator ( & ) only requires a value following it. You can leave blank the value that precedes it, and ChoiceScript will automatically recognize that the preceding value should be the current value of the variable being set.

Now, that does mean that if you’re trying to add to the front of your variable’s value, you’ll have to call out both sides of the operator. Like so:

*if gender = "f"
    *set name "Ms. " & name
*if gender = "m"
    *set name "Mr. " & name
*if gender = "n"
    *set name "Mx. " & name

But when adding to the back of the variable’s value? It’s fine to only specify the following side of the concatenation operator.

As for what concatenation actually does? It basically just glues two values together, side-by-side. For example:

*temp variable 4 + 4
${variable}

The above will display 8. Because it added the values together. However…

*temp variable 4 & 4
${variable}

…that will display 44. It really is just gluing the values together. Side-by-side.

2 Likes

Thanks for the correction! That makes more sense.

1 Like

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