Hello everyone! I was wondering where I should put this subroutine so that the program would constantly refer back to it whenever the relationship of a person (such as Jordan) is changed. I’m not getting any errors where it is currently - after the *create - but I’m almost certain that it isn’t active either.
*if KnowJordan and (JordanRelationship >=47)
*set Jordan 1
*finish
*elseif KnowJordan and ((JordanRelationship >=30) and (JordanRelationship <47))
*set Jordan 2
*finish
*elseif KnowJordan and (JordanRelationship <30)
*set Jordan 3
*finish
*else
*set Jordan 0
*finish
This is an example for one of my characters. 0 means that it is hidden, 1 makes it show in my ‘Friend’ section of stats, 2 in ‘Neutrals’ and 3 in ‘Enemies’. Although the code is likely extremely over-complicated, I think it would work, I just don’t know where to put it so that it can. Thanks for the help!
Will that variable be used for other purposes? Or will it only ever be checked on the stats screen, to determine what part of the stats screen displays the relationship in question?
If that variable’s only ever used on the stats screen, you might as well put this code there. Then you won’t need any extra code. Just put the code that sets it high enough up in the choicescript_stats.txt file that it runs before the variable is checked.
If you might use the variable elsewhere in the game, then it would be helpful to run the subroutine with a *gosub or *gosub_scene command.
Create a file for this, such as something called relationships.txt.
Then use a *gosub_scene relationships command whenever you alter the JordanRelationship variable.
There are ways to improve on it, such as calling just the gosub and the amount you wanna change on the same command and then it will do all that check for the 0, 1, 2 and 3 automatically.
If you’re interested, let me know and I’ll explain.
You can put it wherever you need it! Since these are subroutines to set relationship variables, I imagine you’ll be calling them across scenes, which means you’ll probably want to use *gosub_scene. That function allows you to call a routine across scenes. I personally would make a scene specifically for your subroutines.
For example, if you have a subroutine scene named “relationships” and have Jordan’s function under the label “jordan”, you could call it from anywhere like:
*gosub_scene relationships jordan
Although, you will need to call the routine when you want it to run. It won’t be constantly running in the background. More information on the ChoiceScript Wiki:
This can be changed by choices later on. Where would I put *gosub? Would I have to put it after every change in relationship? (I’d completely forgotten about gosub’s by the way thanks for reminding me!)
Minnow was asking if this status will ever be used or displayed somewhere else, because otherwise you can just leave all of this code inside choicescript_stats.txt since that will be the only place where it would be used and as such the only place where you would need to update the status.
I’d like to do a relationship matrix but I’d have to figure out how to do that as I go as I have no clue how it would be coded. I think I’ll try one gosub_scene file first. How is making separate files easier?
Here is a simple way to change stat and do this check in one go. I added it for Jordan and added a second character called Jenny (just to show how you can do this for another character, just change Jennys variables to whatever is the character variables.
Create a relationships.txt file and put the code inside it.
The value you want to change the relationship is received as a parameter when the *gosub is called, it will then modify the relationship stat by that amount and set the friendship status accordingly.
*comment ========================|JORDAN|========================
*label jordan_relationship
*params change_amount
*set JordanRelationship + change_amount
*if KnowJordan and (JordanRelationship >= 47)
*set Jordan 1
*elseif KnowJordan and ((JordanRelationship >= 30) and (JordanRelationship < 47))
*set Jordan 2
*elseif KnowJordan and (JordanRelationship < 30)
*set Jordan 3
*else
*set Jordan 0
*return
*comment ========================|JENNY|========================
*label jenny_relationship
*params change_amount
*set JennyRelationship + change_amount
*if KnowJenny and (JennyRelationship >= 47)
*set Jenny 1
*elseif KnowJenny and ((JennyRelationship >= 30) and (JennyRelationship < 47))
*set Jenny 2
*elseif KnowJenny and (JennyRelationship < 30)
*set Jenny 3
*else
*set Jenny 0
*return
To utilize this gosub, simply use this whenever you want to change someones relationship:
This amount should be passed as string (between quotes) so that it works with negative numbers if you want to decrease relationship (as in “-10”).
There is a way to simplify that to work for all characters, but it would require you to make the *gosub call a little longer everytime you used it, I can do that one if you want.
It would be amazing for it to work for all characters, so yes please! That’s really smart for the code by the way ^
Sorry to bother you for something else as well, but I was trying out the separate *gosub_scene, and for some reason it no longer sees my first scene (prologue), saying that it no longer exists although I didn’t change it…
*gosub_scene relationships change Jordan KnowJordan JordanRelationship "10"
Some testing might be needed as I haven’t tested things out right now, just basing all of this on some stuff I did a while ago for a friend.
What exactly did you change? And is the error when you’re calling the *gosub_scene? Is the error not for the relationships.txt file instead of the prologue?
That’s great thanks so much! I’ll try it out right away! Well when I can.
The error comes up the moment I click run. It stays blank and just says my first scene doesn’t exist.
The only changes I’ve made was deleting the useless if statements I had in the startup and creating the new relationship.txt with a *gosub_scene link to it later in the prologue scene.