Yeah, ran into that. I was hoping to be able to set it so if it went above a certain number it reset to 1 but I can’t seem to make it happen. I had thought this might work, but it won’t-
*if daysn > 7
*set daysn 1
But nope, it won’t have it.
Yeah, ran into that. I was hoping to be able to set it so if it went above a certain number it reset to 1 but I can’t seem to make it happen. I had thought this might work, but it won’t-
*if daysn > 7
*set daysn 1
But nope, it won’t have it.
I don’t really understand what you want to do here.
What would the choices read like, for example? Would ‘choice B’ read ‘tuesday’ or as something else?
Pretty much I just want to be able to reset the variable- if it goes over 7, then the variable goes back to 1 (considering it won’t really ever +2) So as soon as it goes over 7, I want to be able to reset that same variable.
Edit: Never mind I think i figured it out (it seemed to be having it out with me trying to push it a bit further than I should have because I can’t math well.
Currently, I have it down like this-
Ignore this it was wrong
Seems to catch what I need it to.
Okay, still at least one more issue with it- if I get to 8 or 9, it doesn’t turn over until the next one (So, if it was sunday, and I daysn + 1
on it, it stays Sunday but if I +1 again it goes to Tuesday)
Edit: Got it!
*label time
*if daysn = 1
*set days "Monday"
*if daysn = 2
*set days "Tuesday"
*if daysn = 3
*set days "Wednesday"
*if daysn = 4
*set days "Thursday"
*if daysn = 5
*set days "Friday"
*if daysn = 6
*set days "Saturday"
*if daysn = 7
*set days "Sunday"
*if daysn >= 7
*set daysn 0
*if timen = 1
*set time "Morning"
*if timen = 2
*set time "Mid-Morning"
*if timen = 3
*set time "Noon"
*if timen = 4
*set time "Afternoon"
*if timen = 5
*set time "Mid-Day"
*if timen = 6
*set time "Evening"
*if timen = 7
*set time "Night"
*if timen >= 7
*set timen 0
*set daysn + 1
*return
So this is set that every +1 to timen changes time of day (morning/afternoon) and once it reaches 7 it’s “Night” but as soon as it’s +1 over that, it goes to morning and also goes up the next day.
uh. Neat. But why in your code it doesn’t work?
I did something like this and it worked well.
I think partly it was skipping over because Monday was set to 1 (so, setting it to 1, then +1, would make it go up two days instead).
Aside from that I’m not sure. For whatever reason instead of going up, it would instead stay (so it’s sunday, I +1, it remains sunday though. Doing another +1 changes it to Tuesday).
It would seem like it should work, I have no where near enough knowledge on coding that could say why not though.
Maybe the choicescript interpreter inplements the rules of increment in a way like …
Variable ++ only after some event. (or ++ Variable?)
I really couldn’t say. Just glad I got it working
Try this maybe:
*choice
#thing
*if (days !=7)
*set days +1
*goto next
*else
*set days 1
*goto next
*gosub day_increase
...
*label day_increase
*if (day < 7)
*set day +1
*return
*else
*set day 1
*return
Can’t see a reason this wouldn’t work fine.
Gave it a try to familiarise myself with *gosub
and the multi-replace.
Here you go:
*temp dayN 1
*temp timeN 1
*temp dayS ""
*temp timeS ""
*comment These variables should of course be global in your project (*create, not *temp).
*gosub updateDayAndTimeStrings
*label start
It's ${dayS} ${timeS}!
*choice
#advance day
*gosub newDay
*goto done
#advance time
*gosub newTime
*goto done
*label done
*goto start
*finish Unreachable
*label newDay
*set timeN 1
*set dayn "@{(dayN < 7) ${dayN + 1} | 1}"
*gosub updateDayAndTimeStrings
*return
*label newTime
*set timeN +1
*if timeN > 7
*gosub newDay
*return
*gosub updateDayAndTimeStrings
*return
*label updateDayAndTimeStrings
*set dayS "@{dayN Monday | Tuesday | Wednesday | Thrusday | Friday | Saturday | Sunday}"
*set timeS "@{timeN morning |mid-morning | noon | afternoon | mid-day | evening | night}"
*return