Help with a script

lostcalpolydude

Developer
Staff member
I only put that in, because Mafia kept telling me, it couldn't figure out what 'F' was...

Probably due to some other code change that you haven't bothered to post here (which in general makes it harder for people to help you). The block that you say doesn't work for you works just fine for me.
 

icon315

Member
I only put that in, because Mafia kept telling me, it couldn't figure out what 'F' was...

I figured out what the issue was, aside from the "int f;"
Maybe you had F instead of f, which are two different variables? Couldn't tell without the actual error.
I had this in too:
if (my_inebriety() < inebriety_limit() && my_adventures() > 0)

while my drunkeness was 14, it was effectively NOT < inebriety_limit()...

Not sure if this is a question, but it should be <=
 

Pazleysox

Member
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
 

heeheehee

Developer
Staff member
while my drunkeness was 14, it was effectively NOT < inebriety_limit()...

This sounds like a fundamental misunderstanding of what inebriety_limit() returns. That function returns the highest possible drunkenness at which you can still adventure unimpaired. For a new character, this will be 14.

Note that this is different from KoL's notion of liver space, as demonstrated in Ed.
 
Top