ChoiceScript Problems

OK, I have another problem. Now, this isn’t an error or something, but I was wondering how to use fair math to find a percentage. I know how to do it if the number is, like, fifty, but I was wondering how you’d do it if the number was between 1 and 34.

if 1 is the minimum value you can just use

*if (variable < 34)

(The brackets aren’t necessary in this case, they just look nice :wink:)

if you want to figure out if a variable is somewhere between two numbers, like for example between 28 and 57, you can use

*if ((variable > 28) and (variable < 57))

(Don’t forget the brackets. In this case they’re actually important.)

Alright guys I have a problem. YAY!

So I’m trying to get a save function working in my game and my save feature is as follows:

93:*label save
94:*page_break
95:This is a checkpoint. What would you like to do?
96:*fake_choice
97: #Save my progress. This will only save for this scenario.
98:  *set save_scene current_scene
99: *if (not(save_scene ="error")) #Load a previous save
00:  *goto_scene {save_scene}
01: #Continue
02:*return

When I select “Save my progress…” I get an error;

stats line 99: Non-existent variable ‘load’

Yes, “stats” is the name of my text file. Looking back it might have been less confusing for myself if I had named it “extras” or something. Hind-sight is 20-20.

Maybe try

*if (save_scene !="error") #Load a previous save

1 Like

@Cecilia_Rosewood yes, that would make sense. I will try later. Thank you

@Cecilia_Rosewood Still got the same result. I will try changing “load” to another word?

[EDIT]- Changed it to “Return to a previous chapter”

so now it is:

93:*label save
94:*page_break
95:This is a checkpoint. What would you like to do?
96:*fake_choice
97: #Save my progress. This will only save for this scenario.
98:  *set save_scene current_scene
99: *if (save_scene !="error") #Return to a previous save
00:  *goto_scene {save_scene}
01: #Continue
02:*return

and got this:

stats line 99: Non-existent variable ‘return’

Have you tried moving the choice to another line? Below the *if?

1 Like

@Malebranche Will try that.

Otherwise for the moment I have changed my code to this, although I would like to figure it out:

*label save
*page_break
This is a checkpoint. What would you like to do? 
*fake_choice
 #Save my progress. This will only save for this scenario.
  *set save_scene current_scene
 #Return to a previous save
  *if save_scene ="error"
   It looks as if you haven't created a save yet.
   *page_break
   *goto save
  *goto_scene {save_scene}
 #Continue
*return

@Malebranche you are a genius.

Current working code:

*label save
*page_break
This is a checkpoint. What would you like to do? 
*fake_choice
 #Save my progress. This will only save for this scenario.
  *set save_scene current_scene
 *if (save_scene !="error") 
  #Return to a previous save
   *goto_scene {save_scene}
 #Continue
*return

Thanks to @Cecilia_Rosewood as well!

1 Like

Hey guys I have a strange error

I create the variable SlaveName in the settings file

But when I try to set the variable I get an error can not create token “New Slave Name”

Any ideas?
I’ll have to wait till I’m home to post the exact code

@Nimbian
You cannot have spaces in variable names. Try New_Slave_Name

Sorry there was no spaces my phone exchange added them.

Also that was an example the name I have “Juanus”

@Nimbian you don’t mean for them to be the same variable right?

Correct

In startup.text I have

*create SlaveName “Name”
*create SlaveHeShe “he”
*create SlaveHisHer “his”

In a diffrent scene file prologue.text I have as part of a choice between two options

#A boy named Joanus
*set SlaveName “Joanus”
*set SlaveHeShe “he”
*set SlaveHisHer “his”
#A girl named Joanahanna
*set SlaveName “Joanahnna”
*set SlaveHeShe “she”
*set SlaveHisHer “her”

The error code I get. Invalid expression, couldn’t extract another token: “Joanus”

@Nimbian So I’m testing this on my end and this works:

*create SlaveName "Name"
*create SlaveHeShe "he"
*create SlaveHisHer "his"

*scene_list
 startup
 test1

Start

Switch to .txt file “test1”

Which is your slave's name?
*fake_choice
 #Joanus
  *set SlaveName "Joanus"
  *set SlaveHeShe "he"
  *set SlaveHisHer "his"
 #Joanahanna
  *set SlaveName "Joanahnna"
  *set SlaveHeShe "she"
  *set SlaveHisHer "her"

Your slave's name is ${SlaveName}.

This works. I do not know what is different between our two sides. Do you have most recent version of choicescript? Is

Which is your slave's name?
*fake_choice
 #Joanus
  *set SlaveName "Joanus"
  *set SlaveHeShe "he"
  *set SlaveHisHer "his"
 #Joanahanna
  *set SlaveName "Joanahnna"
  *set SlaveHeShe "she"
  *set SlaveHisHer "her"

In another choice like this?

*fake_choice (or *choice)
 #Response 1
  Which is your slave's name?
  *fake_choice
   #Joanus
    *set SlaveName "Joanus"
    *set SlaveHeShe "he"
    *set SlaveHisHer "his"
   #Joanahanna
    *set SlaveName "Joanahnna"
    *set SlaveHeShe "she"
    *set SlaveHisHer "her"
 #Response 2

I’m not sure what version I’m running but I downloaded the pack from github about 3 weeks ago.

@Nimbian you are running a updated version then, maybe not the most recent (I have no idea when the last one was) but a very recent version. Could you send me more of the text file? You can personal message me if you do not wish to post it in here.

Actually I get my Internet fixed tomarrow afternoon (hopefully) and I’ll set up a drop box with what I have and will PM you a link

Thanks for the help in advance

1 Like

@Nimbian
Message me here or pm me as I check my email sporadically and may not see it for a couple days or more.