Help with the code


#1

Hey guys, although i’m not new to writing CYOA I am new to the choicescript code. The basics are easy enough to pick up and as far as writing the actual game I have no trouble. My problems actually stem from more advanced features in the choicescript language.

First i’d like to know if someone can explain how to place a first and last name on the same line in the stat screen. I know it is probably very simple and i’m just mistyping something or over looking it.

Second is the hidden stats in the stat screen. The game i’m currently working on will be fairly large with a multitude of different paths to the endgame, so adding a relationship stat for every important character that you COULD meet will just confuse the player in the long run.

Last is the save feature. Like I said the game is going to be large, so i’d like to add the save feature after important scenes in the game. I’ve heard that CoG doesn’t allow every game access to their servers for saving purposes so if anyone can shed some light on it, or offer an alternative I would be grateful.


#2

First, Just combine stats o.o there is a billion ways to do it but ive always tried to keep my coding as simple as possible even though I could be lazier on this example im about to give.

*create firstname
*create lastname
*create fullname

*set fullname “{firstname} {lastname}”

Second, the way I do it may be unorthodox but I just put a stat for each person the stat I put names them as either “Unknown” or their name so it would be like…

*create randomperson1 “Randomperson1”
*create randomperson2 “Randomperson2”
*create randomperson3 “Randomperson3”
*create randomperson4 “Unknown”
*create randomperson5 “Unknown”
(I would place the above part in the place where you write the story of course, though it’s example text and you should change everything acoordingly and the part before in your choicescript_stats)


*stat_chart
  percent randomperson1
  percent randomperson2
  percent randomperson3
  percent randomperson4
  percent randomperson5

And lastly, the save system is kinda complicated I cant really show you because I think id most likely go into a huge rant that would confuse you but I would suggest looking up the save systems by @CJW he is a Genius.


#3

re: “hidden stats,” the stat chart only shows what you want it to show. If you *create a hundred variables but only mention two of those variables in your *stat_chart, the other 98 variables will be hidden.

That’s a frequently asked question, so I’ve updated the ChoiceScript documentation to explain it better. http://www.choiceofgames.com/make-your-own-games/customizing-the-choicescript-stats-screen/


#4

Thanks for all the help, but I think I should elaborate a little more with the hidden stats.

My game is already thirty pages deep and has multiple paths. There are parts in the game where the player makes a major choice that effects the rest of the game. Because of this there are people that are major roles in one story line, but in others you never meet them. I was trying to find a way to hide the stat until the player meets them, if they ever do.

Once again thanks for the help.


#5

Hiding stats in stat_chart from what I seen isnt doable unless you do this


*if (bob = true)
  *stat_chart
    percent relationshipwithbob

*if (susie = true)
  *stat_chart
    percent relationshipwithsusie

*if (rick = true)
  *stat_chart
    percent relationshipwithrick

*if (randomguy = true)
  *stat_chart
    percent relationshipwithrandomguy


but it might look a bit ugly


#6

Thanks, im gonna give it a try.


#7

As mentioned, hiding stats is only really possible one way, and its ugly. But, we can avoid the issue.
If characters differ depending on the choices, then it would be better to have a stat for the specific character and then a general one, and just set the general one equal to the character that the pc has met. It’s difficult to explain in just words. Minus the obvious *creates and whatnot, it’d be something like this:

Which one?
*choice
-#Guy
–*set guy true
–*set relationshipguy 50
-#Gal
–*set gal true
–*set relationshipgal 50

Then in statchart
*if guy true
-*set relationship relationshipguy
*if gal true
-*set relationship relationshipgal
*stat_chart
-percent relationship

At least, that’s the basic idea. You could do it the other way^, too, but it’d get tough with even just a few character combinations, and then there’s all the additional stats you want to show, and if one of those is conditional - yikes. This way, you could make relationship slots and simply have the characters fill the slots for the stat chart. It’d get more complicated when you could meet both or neither, but those are doable too. Something like this:
*if guy true
-*if relationship1 = “none”
–*set relationship relationshipguy
-*if (relationship1 != “none”) and (relationship2 “none”)
–*set relationship2 relationshipguy
and so on.
If neither is possible:
*if guy true
-*set peoplemet +1
*if gal true
-*set peoplemet +1
and then:
*if peoplemet 0
-*stat_chart
–percent strength(orwhatever)
*if peoplemet 1
-*stat_chart
–percent relationship1
*if peoplemet 2
-*stat_chart
–percent relationship1
–percent relationship2
and so on for how ever many characters.
I’m even sure there’s a better way than this - with multiple combinations it still gets pretty long. I’ll look again later and see if I can’t find one.


#8

Guys, is it cumpolsory to have stat screen?


#9

yeaah


#10

i think yes, you have. but you dont have to write nothing inside the file. so people dont see anything but game stills playable


#11

It’s not compulsory. As Mara says, you could leave your choicescript_stats.txt file empty, so the button takes people to a blank screen, or write

No stats here.

as the only thing in your choicescript_stats file.

Much more elegantly, you could get rid of the button entirely by editing one or more of the js files in the web folder. I don’t know if it would be as simple as cutting out the ShowStats function from ui.js? Anyway, if I wanted to do it, I’d just play around a bit and see what I could do without breaking the game. Or you may be able to get actual advice from one of the people on the forum with some .js coding knowledge.


#12

I just edit the Html and remove the entire line that has ‘Show Stats’ in it, that should be effective.