Ultimate Noob Coding

I have another question, but this one’s optional for implementation for me. If you got the reader to type something how would you prevent the reader from typing the exact same thing for the next option? you don’t know what they’d type so how would you prevent it?

Edit 1: for example if the reader typed “Plate of Dicks” for their first breakfast item how would you prevent them from typing it again?

Edit 2: also sorry, someone mentioned plate of dicks yesterday and it got stuck on my mind XD

I would recommend you just let them and if it doesn’t make sense that’s the reader’s problem, but what you’d do is save the inputs, then after the second one check if they’re equal and if they are display “you can’t pick the same item twice” or some equivalent and then use *goto to send them back to the text box.

Also I would recommend against using text input for anything except just displaying the input in appropriate locations; it is exceedingly difficult to ensure you can correctly interpret anything the reader types in, especially if they use different spacing or hyphens from what you’re expecting.

1 Like

Yeah… that has a completely different meaning here :laughing: (Guessing you’re from the UK?)

If it doesn’t affect the story, agree with @James_Marsh and just let them go for it.

If you really don’t want them to, I think you can do something like

*if (break1 = break2)
  You can't eat the same thing twice! Choose something else.
  *goto chooseagain

(If that doesn’t work may need to check with someone else, but I think that’s the code for it.)

1 Like

@James_Marsh @Jacic Thank you two for all your help! You’re awesome!

2 Likes

That’s the code for a straight equality test, yes. If the strings are precisely identical it will function. If there’s any variation, even if the meaning is identical, it won’t. Capitalization might be an exception, couldn’t find out on the wiki, but it’s safer to assume “a” = “A” is false unless you know otherwise.

Hence my recommendation against relying on text inputs for anything except redisplaying them.

3 Likes

Yep you’re right, if you had break1 = “toast” and break2 = “Toast” it would think they’re different.
If you really want to, you can set a testing variable for each one to all capitals to avoid that. Won’t help if there’s any spacing, spelling or punctuation differences though.
@Classified if you’re going to be using a lot of free text entry that you want to check, probably worth reading the thread on riddles that had some info on that sort of thing. Will see if I can find it.

Here you go (not quite the same as what you’re doing but can be adapted. It’ll give you the gist of the idea):

1 Like

Okay I have a new question and this one involves math. I want a Variable like Morale display as the average of the relationship status of 4 people. For example, each person has 50% relationship, I want to multiply that number by 4 because there are 4 people and then divide it by four to show the average. How would I do that? And display it in the stats chart as morale.

I feel stupid :sob: i’m the only one asking questions here

@Jacic Help meeeee!

*set morale ((var1 + var2 + var3 + var4) /4)

I think

hmm. okay let me test that out.

Nope that doesn’t work

Do I have to physically set it or will it work as a variable?

how do you mean?
and it might be that my thing there’s missing a paranthesis or they are in the wrong place

I think you’re going to have to set it every time the components are updated. Try:

*set morale 0
*set morale + ((var1 + var2 + var3 + var4) /4)

I think that should work; might be a less clunky way of going about it though.

Tried that didn’t work so I tried adding parantheses now it says open parenthesis

Maybe this is shorter:
*set morale (((var1 + var2) + (var3 + var4)) /4)

1 Like

YES, that works that’s good

MAkes the game load laggy as hell tho for some reason

No, if you want the average of four values you don’t need to add the new average to the old one.

like
(50 + 25 + 60 + 55) / 4 would be 47.5 average
while let’s say 47.5 + ((45 + 35 + 65 + 50) /4) would be (rounded) 104.4 or something

edit: @Classified try

*set morale round(((var1+ var2) + (var3 + var4)) /4)

without round the game might run into infinite numbers i think

Yes this is what I used *set Morale (((Brett + Linda) + (Herby + Samirah)) /4) and it worked

I set the stat for morale to be in percentages

Do I still need the round if it’s set in %?

Never feel bad about being the only one asking questions here. I was the only one for like the first 70 posts or so. And I left it open specifically because it could be a good spot for people to ask questions with no judgment, as the title sorta shows you’re needing help with the basics.

Also would *create Morale (((Brett + Linda) + (Herby + Samirah)) /4)

Work?

Only once. You can use create to set the starting value but not for updates.