I don't know if anyone will ever care enough about these forum posts to actually read them, but I will post another silly mistake that I made, and figured out, and fixed on my own. I should say, i've had no formal education in programing, and i'm trying to force my way into learning how to write scripts, so I'm quite pleased with myself when I can find a mistake. Hopefully someone can learn from this.
Here's the bad code:
Code:
if(get_property("sourceTerminalSpam") < 10 )
{
float spam = get_property("sourceTerminalSpam")
float spammod = (10 - spam);
print_html ("You can still install <font color=FF0000>" + spammod + "</font> Source terminal SPAM chip");
}
Here's the fixed code:
Code:
if(get_property("sourceTerminalSpam")[COLOR="#FF0000"].to_int()[/COLOR] < 10 )
{
float spam = get_property("sourceTerminalSpam")[COLOR="#FF0000"].to_int();[/COLOR]
float spammod = (10 - spam);
print_html ("You can still install <font color=FF0000>" + (spammod) + "</font> Source terminal SPAM chip");
}
The change is in red.
Data Types is a great reference page for learning.
Final Code:
Code:
if(get_property("sourceTerminalSpam").to_int() < 10 )
{
[COLOR="#FF0000"]int[/COLOR] spam = get_property("sourceTerminalSpam").to_int();
print_html ("You can still install <font color=FF0000>" + [COLOR="#FF0000"](10 - spam)[/COLOR] + "</font> Source terminal SPAM chip"); }
Changes again are in red.
I ended up changing float to int, and putting the math inside the ()
The only difference in the final output is this:
You can still install 3.0 Source terminal SPAM chip <-- FLOAT will add the .0
You can still install 3 Source terminal SPAM chip <-- INT takes away the .0 and leaves a whole number