Porter's Coding Problems thread

So I just started writing my story for the CScomp, yup, it took me four days to come up with a story but that doesn’t matter.

I am currently busy with the stat screen but for some reason I get this.

choicescript_stats line 11: Non-existent variable ‘intelligence [ i ]intelligence[ /i ]’
(don’t mind the spaces, needed so it doesn’t mess things up here)

And here is the code in my stat screen.

[b]Personal[/b]
*stat_chart
    text name                  [i]Name[/i]
    text gender                [i]Gender[/i]
    text job                   [i]Job[/i]
    percent health             [i]Health[/i]
*line_break
[b]Stats[/b]
*stat_chart
    percent strength           [i]Strength[/i]        
    percent intelligence       [i]Intelligence[/i]        
    percent charisma           [i]Charisma[/i]        
    percent agility            [i]Agility[/i]            
    percent reflexes           [i]Reflexes[/i]    

Now, I don’t see any problems myself since “Health” is exactly coded the same way as the others with percent yet they don’t seem to work.

And yes, I have all of the variables seen above created in my startup file.

If I have any other problems (that won’t give anything away from my story) I will post them here.

Alright, heh, this is awkward. I seem to have found the problem and that is that for some reason if I use “tab” in the 2nd stat chart everything just goes wrong and people start dieing. :blush:

I’ve just and copied and pasted that into a new choicescript project and created all the variables and it worked fine. Double check the spelling of intelligence in startup thats all I can think of would cause the variable not being recognised.

edit: I see you’ve fixed it yourself so ignore the above.

Hello, I am back again.

*create porter "20"
*create love_porter false
*if love_porter true
    *set porter "lover"
*if porter < 25
    *set porter "enemy"
*if porter < 50
    *set porter "associate"
*if porter < 75
    *set porter "friend"
*if porter < 100
    *set porter "best friend"

So I tried this for a “simple” relationship system yet I get the error line 30: Not a number: enemy
But if I go to the stat screen it shows Porter in the Relationships list as an enemy so it works there, but for some reason not in the startup scene…
(and no, I’m not going to add myself to the story, or maybe I will, who knows. I am using myself for testing purposes)

Remove the quotemarks on the create porter number.

I still get the same error.

Sorry was trying to respond there on an answer thing the size of a stamp. It was tiny and I could see one letter at a time. The forum formatting’s a bit messed up for me.

I think there’s a way to hold both numbers and strings on a variable, I can’t remember how. So I’d say do

*create porter_rel 20
*create porter "nothing"
*create love_porter false

*if (love_porter = true)
    *set porter "lover"
*if porter_rel < 25
    *set porter "enemy"
*if porter_rel < 50
    *set porter "associate"
*if porter_rel < 75
    *set porter "friend"
*if porter_rel < 100
    *set porter "best friend"

Only there’s another problem with the above coding, because 20, for instance falls into all of those categories.

Godfeather is correct.

Elseif would then require a *goto after it.

You can make just ifs work but you have to be careful in using them so that every possible number falls into one of the categories.

Ohhhh right, totally forgot about that.

So it’s the actual equations themselves that need to be adjusted?

I tried doing something like this but it also doesn’t seem to work.

*if (love_porter=true)
    *set porter_rel 100
*if porter_rel > 0 
    *set porter "Enemy"
*if porter_rel < 24 
    *set porter "Enemy"
*if porter_rel > 25
    *set porter "Associate"
*if porter_rel < 49
    *set porter "Associate"
*if porter_rel > 50
    *set porter "Friend"
*if porter_rel < 74
    *set porter "Friend"
*if porter_rel > 75
    *set porter "Best friend"
*if porter_rel < 89
    *set porter "Best friend"
*if porter_rel > 90
    *set porter "Lover"
*if porter_rel < 100
    *set porter "Lover"

You can do it with elseif. You can also do it with ifs.

When using *elseif you need to remember to *goto or *finish after each statement.
When using *if you need to be certain you’re covering all of the numbers.

So

*if (porter_rel < 25)
	*set porter "enemy"
*if (porter_rel >=25) and (porter_rel < 50)
	*set porter "associate"
*if (porter_rel >=50) and (porter_rel <75) 
	*set porter "friend"
*if (porter_rel >=75)
	*set porter "best friend"

Is the same as

*if (porter_rel < 25)
	*set porter "enemy"
	*goto next
*elseif (porter_rel < 50)
	*set porter "associate"
	*goto next
*elseif (porter_rel < 75)
	*set porter "friend"
	*goto next
*else (porter_rel < 100)
	*set porter "best friend"
	*goto next

Agh, Godfeather beat me to the punch! :stuck_out_tongue_closed_eyes:
Also, thanks Godfeather! I’ll archive that for future reference! :smile:

So yes, your overall code should look like:

*create porter_rel 20
*create porter "nothing"
*create love_porter false

*if (love_porter = true)
    *set porter "lover"
*if (porter_rel < 25)
    *set porter "enemy"
*if (porter_rel >= 25) and (porter_rel < 50)
    *set porter "associate"
*if (porter_rel >= 50) and (porter_rel < 75)
    *set porter "friend"
*if porter_rel >= 75
    *set porter "best friend"

Well, there just seem to be getting more and more problems, if I do

*set porter_love true

Then it will just be ignored and the porter variable, in this case the number is 20 will stay Enemy
and if I try to do

*set porter +10

So it will become 30 instead of 20 then I will get the error line XX: Not a number: Enemy and in the stat screen it will just stay Enemy

Try placing *if porter_love at the bottom of your code, like this:

*create porter_rel 20
*create porter "nothing"
*create porter_love false

*if (porter_rel < 25)
    *set porter "enemy"
*if (porter_rel >= 25) and (porter_rel < 50)
    *set porter "associate"
*if (porter_rel >= 50) and (porter_rel < 75)
    *set porter "friend"
*if porter_rel >= 75
    *set porter "best friend"
*if (porter_love = true)
    *set porter "lover"

As far as the other issue goes,

*set porter +10

will not work because porter is a string variable, meaning it can only display text or numerical values.

Do this instead:

*set porter_rel +10

porter_rel acts as the numerical value that determines what text/relationship status “porter” will output.

oh heh yeah, the *set porter thing was just stupid from me, should have seen that.
Yet it still doesn’t work, same for the love_porter variable when I put it at the bottom.

Strange, it’s working in my tests.

Are you using love_porter or porter_love?

love_porter, same as everywhere in my code, I’ll try to change it to porter_love to see if that works

nvm, *set var +xx works now but if I do for example *set porter_rel + 50, it will become 70 which should mean that porter = “friend” but in the stat screen its still “enemy”


I could just use normal percentages for the relationships but that’s, um, overused? and it just doesn’t tell that much, “Porter likes you for 50%”.

Paste this code and see if it works for changing the status to “lover.”

*create porter_rel 20
*create porter "nothing"
*create love_porter true

*if (porter_rel < 25)
    *set porter "enemy"
*if (porter_rel >= 25) and (porter_rel < 50)
    *set porter "associate"
*if (porter_rel >= 50) and (porter_rel < 75)
    *set porter "friend"
*if porter_rel >= 75
    *set porter "best friend"
*if (love_porter = true)
    *set porter "lover"

Afterwards, change love_porter to “false” and place *set porter_rel + 50 above the *if statements, like this.

*create porter_rel 20
*create porter "nothing"
*create love_porter false

*set porter_rel +50

*if (porter_rel < 25)
    *set porter "enemy"
*if (porter_rel >= 25) and (porter_rel < 50)
    *set porter "associate"
*if (porter_rel >= 50) and (porter_rel < 75)
    *set porter "friend"
*if porter_rel >= 75
    *set porter "best friend"
*if (love_porter = true)
    *set porter "lover"

You want that *set command before the *if commands so the game will properly display the increase in value.

nvm, only happens when I copy and paste, just needed to type it over and now it does say lover and not enemy