Actually, the logical operator is inverted. It’s supposed to be “greater than or equal to”, it is, the “greater” sign comes first, before the equal sign.
*if (t_relationship >= 60)
Actually, the logical operator is inverted. It’s supposed to be “greater than or equal to”, it is, the “greater” sign comes first, before the equal sign.
*if (t_relationship >= 60)
First, Thanks for the help. Yeah, the upside down, >=, was a bit trickey to rap my head around, since I am used to ding = X, what ever.
Secondly.
I am running some code, but it keeps going to 1 particular place, and I can’t figure out why, even when I try to send it somewhere elce. I have gotten tired of trying to figure it out, because I have been trying for 2 hours, and it’s driveing me up the wall. It’s probably something simple. Most things are. If I put up the code, could someone point me as to how to fix it? Please?
*choice
# Comfy. T-shirt, swetter, and track pants with pockets.
*set clothes "comfy"
Comfy is king. Or. No, Queen starts with a Q, so, doesn't fit as well. Meh, same difference. Either way? Track pants with lots of pockets, T-shirt and swettters are my thing. At least in winter. Cause. What's the point of anything if you have to be all uncomfortable all the time?
Anyway. Moveing on.
*goto go_downstairs
#Smart. Um... Nice, T-shirt. Geans, and. Nice swetter?
*set clothes "smart"
Smart. Um... Nice t-shirt, nice swetter, and geans? I guess?. Hmmm, might want to ask Ivy, and or Kathi about that one. Not goan. His defenission of getting dressed tends to be leather jackets and cowboy boots.
*goto go_downstairs
#Practical. T-shirt, Geens, leather jacket.
*set pragmatic %+3
*set clothes "practical"
Practical. So. T-shirt, Geens, Leather jacket. ETC. Good for both being in an office building. Or, well. Being in Goan and Ivy's study, or being in the middle of a snowstorm.
*goto go_downstairs
#Kilt.
*set clothes "kilt"
"Well. Kilt, and. Underpants, because. Weather or not that was a dream? I would rather not, have my ass in the wind again, thankyou very much.
*goto go_downstairs
*label go_downstairs
After I get dressed, I tromp down the stairs, and into the living room. The rest of the family greets me in their own ways.
Ash squeels with delight. Ivy wishes me a good morning, and Goan grunts something. He usually reads the newspaper at this time in the morning, since today, neither of them have work. Well. Unless something troubling comes up. Then? They will both have to rush off. Ivy, into the woods. Goan? I don't actually know. Kathi doesn't know either, and Ivy and Goan won't answer if we ask.
*if(clothes)="kilt"
"What the actuall fuck? Kathi sputters.
You actually got ${mc_them}. A kilt? I thought you were just yanking my chain?
"It. I say, smirking. Is not a kilt, Kathi. It's, A tactical, kilt.
"I still have no idea what that is supposed to mean. Kathi mutters.
"It involves masks. I say, shrugging. If you can't get it from that? Well. Your loss, as far as I am concerned.
"I like masks! Ash chirps.
"I hope you have underpants, at least? Kathi mutters. I nod.
Good. Kathi grunts, before going silent.
*goto texting
*else
Kathi grunts something that could be thought of as a greating. Could also be thought of as a rude noise, but given it's Kathi? Well. She is not exactly, a mmorning person.
*goto texting
*label texting
ding
I reach into my pocket, pulling out my phone.
***
${mc_fullname}
***
*if (choose_t) =true
"As I indicated last night. Our conduct regarding the... Insadint, was less than adaquit. As such? We will text, or, at the very least. Communicate with you, before we decide things that include you.
*goto go_downstairs2
*else
"It has been poiniantly pointed out to me, that our conduct yesterday, was. Less, than adaquit. As such? It has been agreed amongst the pack, that we will ask for your opinion, when dealing with decisions that affect, or include, you directly.
*goto go_downstairs2
*label go_downstairs2
As such? We wish to inform you, that we request your presence, at your property line. At the tree, where you found. Ash.
If you do not wish to come with us? Please indicate. Otherwise? We will be wateing.
T.
*if(t_relationship)>=60
*set t_regard true
*goto t_texting
*if (l_relationship) >=60
*set l_regard true
*goto text_next
*if (d_relationship) >=60
*set d_regard true
*goto text_next
*if (n_relationship) >=60
*set n_regard true
*goto text_next
*else
*goto text_next
*label t_texting
P.S
"Give that back, ${d_name}.
"What ${t_name} ment to say, is that ${t_they} is rather hopeing you will come join us, and that we all can.
balmlshrvlrvllarv
"As I was saying. It is, your choice. We will not...
"What ${t_they} means, is that, you should really come. I mean. You don't have to? But. ${t_they} really, really, really, really really really really. Wants you to. So.
***
*goto rataleation
*label rataleation
ding*
This day is getting stranger by the moment. I mutter to myself, re-opening my messages to find another text:
"I would apretiate you ignoreing ${d_name}. ${d_they} took the phone when I was in the middle of my request. Your choice, and your decision, are still valid. My thoughts on the matter? Are, imeterial. Though. I would apretiate.
ding
ding
ding
I rub my face, return to the messages app, and find 3 texts from ${d_name}.
Text1.
"${t_name} is being a spoilsport. You really should, come. I mean. It's your decision, like ${t_they} said, but. Yeah!
***
Text 2
${t_name} really does want you to come! I mean. Your choice, but...
***
Text3
Smiley smiley smiley smiley smiley smiley smiley. Frowny ?
Smiley smiley smiley. Squee.
*goto squee?
*else
We will remaine outside your property line, till your reply. If you are not down in 1 hour after you read this? We will depart. I hope that will put you at ease, that we will not.
I believe the word you use was. Stalk? Or, was that ${l_name}. Regardless.
T.
LOL.
*goto text_next
*label l_texting
*if (choose_l) =true
"When you get this? Please inform Ash. I believe that is what her name is? That I hope she is doing well. After the... Insadint, yesterday.
Signed, ${l_name}.
*if (l_regard) =true
*goto l_texting2
*else
*goto text_next2
*label l_texting2
*if (choose_l) =true
Also?
*goto l_texting32
*else
${mc_first}? It's ${l_name}.
*goto l_texting3
*label l_texting3
I do hope that you will come and join us. Of course? It is your decision, but. Regardless. I do hope to see you. Here, you? Um...
Signed, ${l_name}.
*goto text_next2
*label squee?
*set t_regard true
"The hell. I mutter, lowering my phone. Is. A. Squee?
"It's. Kathi says. Like. Um... This?
There is a high, ear-splitting whistling noise, causeing me to clamp my ears with my hands, a blazing headache flareing up behind my eyes, jaw gritted. Then? It cuts out abruptly, along with a heavy thud, and Kathi's yellp.
"Ash. Ivy snaps. What. What did you? Why did you do that?
"Noise bad. Ash mutters. Noise bad, noise bad, noise bad. Don't like that noise. Bad, bad, bad... Noise... Bad... Noise... Noise... Bad...
"Dam it. Kathi groans. Voice. From the floor? Ugg. My face...
"Are you alright? Goan asks, while interlaced with Ivy asking. Ash?
"Yeah. Both grunt, in perfect unison, before I hear a grunt, and a shuffle from Kathi's direction, and the pat, pat, pat, of Ash's feet. I grimace, rubbing my head.
"I. I say. Please don't do that. Ever. Again?
"Ok. Kathi says. Now. Why did you want to know what a Squee, was?
I shrug, opening my phone once again, and turning off the voice to let Kathi, Ivy and Goan, have a look. After 10 seconds? I, guiltally, turn it back on, and let Ash look over the text. It's not like it's anything particularly adult, after all.
Ash, starts to cackle. Ivy chuckles. Goan rumbles a laugh, and Kathi just starts howling. I, takeing my phone back? Return it to my pocket, a bit confused.
"What? I start.
"Seems. Kathi snorts, still chortling. ${d_name}, was it? Grabbed the phone off ${t_name}. I assume they were useing. Voice to text? I shrug.
*goto text_next2
*label text_next
I lower my phone. A bit confused on the formulness? Of the request, then shrug. It's. Well.
ding
More confused now, I raise my phone once again, I had just been about to put it into my pocket, and unlocke it, to find another text. This one, from
*if ((choose_l =true) or (l_regard =true))
${l_name}.
*goto l_texting
*elseif ((choose_n =true) or (n_regard =true))
${n_name}.
*goto n_texting
*elseif ((choose_d =true) or (d_regard =true))
*goto d_texting
*label n_texting
I'm surprised? A bit? Didn't peg the ${n_person} to be the really social type, but.
Regardless of my surprise? I shrug, and continue reading listening to the message.
*if (choose_n) =true
"Tell the. Kid. Hope she is ok
*if (noose) =true
"Still say your an iddiat, for not letting me get her out of the dam tree? But. Yeah. Do that. Won't you?
*goto n_texting2
*else
Your not totally stupid, at least. Perhaps you will be useful.
*goto n_texting2
*label n_texting2
"That's all. Don't bother texting back? I won't reply.
*if (n_regard) =true
*goto n_text3
*else
*goto text_next2
*label n_text3
"Also. Your not quite, as. Annoying, as I first thought. So. You can come with us.
I guess.
"Yeah, yeah ${l_name}. If. You. Want.
*goto text_next2
*label d_texting
*if (choose_d) =true
"Hay. ${mc_first}? It's ${d_name}. Can you tell ash, I hope she is OK? Since. You know. Anyway. Yeah. That's about.
*if (d_regard) =true
*goto d_texting2
*else
*goto text_next2
*label d_texting2
Also. Yeah. I would like it, if you could come hang out with us? Please? Please? Please?
${l_name} is telling me that I shouldn't put so many exclamation points. O, not supposed to write that.
*ding*
"Hay. It's ${d_name} again. Could, you know. Just forget about that last line? Please. Also.
Signed, D.
*goto text_next2
*label text_next2
Even when I put in temp variables, I always get L’s texts, even when I spasificly set it up for N’s, or D’s. Unsure what’s going on. Again, probably something small. Any help as to fixing this, would be well apretiated.
Till then? I hope who all reeds this, has a good and safe evening.
Can you specify where the code keeps jumping to?
When I set up temp variables, it will display fine up till you get that second text, then jump to the text from L, even if I set temps designateing the other relationships and regard variables to be true. Then, it seems to go back to normal.
I couldn’t find any temp variables that would cause it to do that, and when I looked at the gotos and lables, everything seemed relativly in order.
When I say text? I mean the text you get from L, not. You know.
It’s. Not that? Big of a thing? But, still. Looks unprofessional, and I do intend on publishing this book at some point, so.
I found this arror, and am 1, not sure what it’s supposed to be, and 2, not sure how to fix it. Here is the arror, and code will below.
Arror:
“Line 1733:falce”
Code:
*choice
#I'm fine. I say, anger fadeing just that little bit, even with what I know of the ${sk_person}.
*set heart %+10
*set genuin %+10
*set genuin true
*set sk_relationship %+3
"I, I say with a sigh, anger ebbing just that little bit, am fine, ${sk_name}. I then turn, and stride away.
Lines:
1730/1736.
So, yeah. Not really sure what’s going on, or why it’s giveing me an arror on a *set, instead of a #general
I think the problem is caused by this. I don’t know what you first set this variable as, but if it’s a true/false variable and you’re trying to increase the value of that by 10% that obviously isn’t going to work.
Thank you
I guess I keep forgetting that you can‘t have the same variable, one binary, one numeric, and the same choice. For some reason I always think that it’ll work, but it doesn’t. Silly me.
Getting an arror: line non-existant variable: hug.
Code is:
*temp hug false
*set hug true
*if ((n_relationship >=65) and (hug =true))
I figured it was spelled wrong, but now I am unsure.
So. Yeah.
This is all in the same .txt file? Temp variables don’t carry over when you move from one .txt file to the next. Other than that I can’t think of anything that might be wrong with this code.
Yes, it is.
I couldn’t find anything wrong with it either, unless the fact that I had a binary and a string variable in the same sequence is messing with something.
Okay, what would be the best route to compare which one out of four variables was the highest in determining what text would display? I could also do unique text for if there was a tie for the highest one, even though that should be difficult to manage unless the player is a schizo in this particular instance.
For background, the variables are Intimidate, Inspire, Motivate and Entertain. Whichever one is highest is what I would use to describe the overall tone of the speech the MC just gave.
I’ve just copied this from my reply to another thread, I’ve just changed the variable names to match yours.
I’ve not tested my changes as I’m mean to be working, but the original worked - so just give me a shout if this doesn’t run and I’ll fix it up later.
In your startup.txt you include these lines:
*create intimidate 0
*create inspire 0
*create motivate 0
*create entertain 0
*create Highest_stat_type ""
*create Highest_stat 0
Then create a new file, let’s call it ‘high_stat_calc’ and put in this code:
*if Highest_stat = 0
*set Highest_stat_type "intimidate"
*set Highest_stat initimidate
*if intimidate > Highest_stat
*set Highest_stat_type "intimidate"
*set Highest_stat intimidate
*if Inspire > Highest_stat
*set Highest_stat_type "Inspire"
*set Highest_stat Inspire
*if Motivate > Highest_stat
*set Highest_stat_type "Motivate"
*set Highest_stat Motivate
*if Entertain> Highest_stat
*set Highest_stat_type "Entertain"
*set Highest_stat Entertain
*return
Then go about making your scenes, you get to scene 20 where you want to select the text displayed.
Something happens! What happens next?
*gosub_scene high_stat_calc
*if Highest_stat_type = "intimidate"
You are intimidating
*if Highest_stat_type = "inspire"
You are inspiring
*if Highest_stat_type = "motivate"
You are motivating
*if Highest_stat_type = "entertain"
You are Entertaining
This won’t handle ties as it is.
Probably the most elegant way to do it, is to actually change it to record not the type of stat that is the highest, but the actual value. Then you can compare each stat against the value (thus finding the 2, 3 or 4 stats that are all equal to the highest) and display the text according to whether there’s 1,2,3 or 4 highest and which ones they were.
If you’re not sure how to do it, just let me know.
I’m sorry, I think I used the wrong words. I don’t need a text variable, I will have different labels for it to goto which will each show unique text based on the highest stat (and if more than one tie, ideally that would go somewhere as well).
Sure. I just put in the ‘I am intimidating’ etc. as a placeholder for whichever logic you wanted to include. Change the scene logic above to something like this:
Something happens! What happens next?
*gosub_scene high_stat_calc
*if Highest_stat_type = "intimidate"
*goto initimidate_text
*if Highest_stat_type = "inspire"
*goto inspire_text
*if Highest_stat_type = "motivate"
*goto motivate_text
*if Highest_stat_type = "entertain"
*goto entertain_text
The text variable created in the rest of the code is for storing what the highest stat is and using it to control the decision making in the code. This design also lets you cal lthe same logic in multiple places in your code (providing you use the same stats each time).
@Sinnie’s solution should work fine but I want to throw my two cents as well .
— startup.txt —
*create high_result ""
*create high_tie ""
The variables high_result
and high_tie
are used to return the result of the function (sub-routine), supposing you’re not keeping it in the same file as the one in which you’ll be calling the function, in which case you can create the variable as *temp
in the scene itself. Feel free to rename them as you please. Having them as a global variables allows you to call the subroutine and retrieve its result from anywhere in the game.
— utils.txt —
*label check_highest_stat
*params
*if param_count <= 1
*bug Expected at least two stats for comparison, received ${param_count}
*set high_result (0-1000)
*set high_tie ""
*temp loop_count 1
*label check_highest_stat_begin_for_loop
*if ({param[loop_count]} > {high_result})
*set high_result param[loop_count]
*set high_tie ""
*goto check_highest_stat_for_loop_continue
*elseif ({param[loop_count]} = {high_result})
*set high_tie param[loop_count]
*goto check_highest_stat_for_loop_continue
*label check_highest_stat_for_loop_continue
*set loop_count +1
*if loop_count <= param_count
*goto check_highest_stat_begin_for_loop
*return
In a separate file, where you’d keep all utilitarian and supporting functions, include this sub-routine.
This function accepts an arbitrary number of arguments, so you can compare 4 stats, or 5, or 6, and so forth, without having to change the code itself, because it works procedurally. The stats to be compared must exist in the same scope as the function (if they are global variables, you are fine). The arguments must be the name of the stats passed as strings (between quotation marks " "
). If there’s a tie between three or more stats, the function only accuses two of them. That’s by design.
The command *params
loads all parameters passed to the function. The following *if
block checks if the number of parameters is equal to or less than 1, in which case it just raises an error message. After all, you need at least two stats to make a comparison.
The following code is an implementation of a loop. It’s going to repeat the same logic for as many times as there are stats to compare. The variable high_result
will keep track of the current highest stat, and loop_count
will keep track of the current loop iteration.
When there are no more parameters to compare, it will return. Then you can retrieve the result by accessing the value of the global variable high_result
.
Extra code is suppressed in the example, replaced by ellipsis.
During the game, you want to check the highest stat among four global stats in order to display flavour text. The current values of the stats are:
intimidate: 15
inspire: 85
motivate: 27
entertain: 70
— scene.txt —
*gosub_scene utils check_highest_stat "intimidate" "inspire" "motivate" "entertain"
*if (high_result = "intimidate")
*if (high_tie != "")
...
*else
...
*elif (high_result = "inspire")
...
*elif (high_result = "motivate")
...
*elif (high_result = "entertain")
...
Note how the stat names are passed into the subroutine as strings. *gosub_scene
is the command, utils
is the name of the file containing the sub-routine, check_highest_stat
is the name of the function, and everything that follows is parameters. You can include as many as you want. After that, you check the values of high_result
and high_tie
.
Is there a beginners guide for “Character Creation”? I’m at the part of my story where the player is building their character, and I’m unsure about how to code pronouns into the story.
Hi,
If I use the *gosub command, do I have to *return or can I just use a different *goto in the *label without returning? Will this gets me into trouble later on if I want to use a different *gosub?
I hope this is clear
Note that subroutines can be nested, meaning that within one subroutine you can *gosub to another, and then another, and so on, until it hits an actual *return command. By this means it’s possible to create quite intricate & complicated programming. However, a typical ChoiceScript game would probably never need to do so. For most games it should suffice to use multiple simple subroutines for entirely different, and completely unrelated, purposes.
I think you can have as many as you want, I haven’t used much of them but it seems there is no actual limit.
You can also do recursion (not for the faint of heart). Be aware that, differently from other programming languages, “gosub” doesn’t create its own environment: make sure your variables in the subroutine don’t conflict with the rest of the code.