Porter's Coding Problems thread

Good, good!

Chyeah, copy paste can sometimes mess with the indents, I think. :smile:

Edit: Oh snap, I think I know the problem.
I’m using the tab key for indents, you’re using the spacebar for indents.

I will adjust my indenting to match yours.
That should resolve those errors. :grin:

only thing that still doesn’t work now is when I do something like this

*choice
  #yay
    *set love_porter true
    *goto abc
  #hi
    *set porter_rel +50
    *goto abc

With the first choice, nothing happens.
With the second choice porter_rel will be 70 but it will still be displayed as enemy

Sorry to keep you waiting!

Let’s see, it looks like you’re going to be using those *if statements a lot, so let’s go ahead and create a *gosub routine so you can quickly access the code when you need it.

Place this code at the bottom of your scene:

*label porter_status
*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"
*return

I have taken your code and labeled it “porter_status.”

Now, when you need to use this particular area of code, you can simply use the command

*gosub porter_status

as opposed to typing all of that code over and over.

Details here: *Gosub






As for your choices, insert *gosub porter_status in these places:

*choice
  #yay
    *set love_porter true
    *gosub porter_status
    *goto abc
  #hi
    *set porter_rel +50
    *gosub porter_status
    *goto abc





This is my test code:

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

${porter}

*choice
  #yay
    *set love_porter true
    *gosub porter_status
    *goto abc
  #hi
    *set porter_rel +50
    *gosub porter_status
    *goto abc
	
*label abc
${porter}

*finish

*label porter_status
*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"
*return

This test should give you the desired results.

Thank you, it works :blush:

so much coding just to tell if one person likes you, guess I will need a lot of coding the more characters I make.

For the record, the reason the status wasn’t changing when you used this code:

*choice
  #yay
    *set love_porter true
    *goto abc
  #hi
    *set porter_rel +50
    *goto abc

is because your *if statements weren’t checking the conditions and applying the changes.

To make it work, you’d have to insert your *if statements like this:

*choice
  #yay
    *set 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"
    *goto abc
  #hi
    *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"
    *goto abc

With those lines of code inserted in those particular places, the game now knows to check the conditions of Porter’s relationship and apply changes as needed.

However…




Do you see how constantly using that particular line of code could become tedious?

Since you’re gonna be using that code over and over again, it’s better to create a *gosub routine that will execute the scripting in the labeled lines of coding.

That way, you won’t have to duplicate those *if statements over and over, and it’s easier to edit the code should you ever want to add/remove/adjust anything in that particular section of code.

This is how your code would look with a *gosub:

*choice
  #yay
    *set love_porter true
    *gosub porter_status
    *goto abc
  #hi
    *set porter_rel +50
    *gosub porter_status
    *goto abc

Much, much simpler, is it not?

You’re very welcome. :smile:

And yes, typically, the more complex your game is/more characters your game has = More Coding.

Much More Coding. :stuck_out_tongue_closed_eyes:

1 Like

Now that I have the label does it mean I don’t need all the ifs under the created variables? Because right now I have two times the same relationship codes

No, you shouldn’t need the *if statements located near the top of your scene file.

The *gosub routine located near the bottom of the scene file should suffice.

For the most part, the only commands that need to be specifically placed near the top of the scene file are:

*title
*author
*scene_list
*create

You can place *if statements anywhere in the scene file.
(Except above the other aforementioned commands, of course.)
It is not mandatory to place *if statements near the top of the scene file.

Here’s a gosub routine I use:

*label RelationshipConvert

*if hold_stat >= 80
  Best Friend
  *return
*elseif hold_stat >= 60
  Friend
  *return
*elseif hold_stat >= 40
  Associate
  *return
*else
  Hated
  *return

And each time I want to send a person to it:

Jaime:
*set hold_stat jaime_faction
*gosub RelationshipConvert
(${jaime_faction})
1 Like

I know I probably asked this before, but what if I want to use for example this,

As the background for my game. I’m guessing that I have to make changes in the style.ccs file.
But well, is it possible?

You can use more than one elseif in a row? Wow, this would have made some of my conditional statements a lot easier. I thought three categories was the max (an if, an elseif, and an else.)

@P0RT3R Yes it’s possible.

http://choicescriptdev.wikia.com/wiki/Style.css has stuff on the style.css stuff and http://www.w3schools.com/cssref/pr_background-image.asp looks like it explains how. Since I only ever did web page creation in the dark ages before all that style css stuff,

I’d likely just edit the index.html file to insert a background image. I’ve no idea if that’s the correct way though and suspect it likely isn’t.

@Sashira Yes. You can use lots of them. You only get to use one *else of course but *elseifs and *ifs you can use how many you please in a row.

It’s far from perfect and never entirely up to date, but the Wiki does at least reasonably explain most commands and has some useful articles worth perusing when you have the time. One feature you may find useful is a ‘Next Command:’ link on each *command page, enabling you to cycle through them all alphabetically without having to return to the Index itself - useful for occasionally refreshing your memory on syntax, handy tips and some of the less common / least familiar commands.

/plug :wink:

Am I the only one who finds it hilarious that Porter is trying to script relationships for theirself? XD

Anyway, that first question, the intelligence… did you remember to
*create intelligence X
and pay attention to the capitalization?

Sashira, you can use any number of *elseif

You can also just use *if again and again, and it will nest the way fake choices do. Which is often even easier than *elseif because it doesn’t require a *goto at the end.

If you read trough then you might have seen that I al using myself for testing purposes, and that the first problems already have been solved.

Alright, hey, so I hav-
Porter, why are you posting here again? Are you writing again?
What? no! That would be silly… Perhaps… We will see.

So, as I was saying, I have a small problem, or more of a question really.
If I were to use genders then that means every time in a conversation the word “he” for example needs to be changed to “she” if you happen to be a girl.

Now, if I were to use this code

*create he "he
*create him "him"
*create his "his"

*if (gender = female)
    *set he "she"
    *set him "her"
    *set his "her"

Would everything be correct because I feel like I’m still missing out on some things.

Basically yea its also

*create he
*set he "her"
then when you want to use it type ${he} and it will show up as "her"

But why “her”?
For example

You try to hide but the doors give in sooner than expected.
"Hey, there ${he} is!" one of the intruders shouts.

Oh I’m sorry the parenthesis wont show up so it would appear as

You try to hide but the doors give in sooner than expected.
"Hey, there she is!" etc