Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Variables Equaling Zero on Global Scripts

4 years ago

Alright, I'm here out of desperation. 

Here's my problem. I have a HEALTH variable that starts at 100 but can go down to 0. Now, I have a 'Game Over' page, and I set the HEALTH variable page so that when it goes below 1 it automatically travels to the Game Over page. Only it doesn't work.

Next, I try to run the following script as a global link on the Scripting 'tab':
IF %HEALTH := 0
THEN $DEST := @P163

There's nothing reportedly wrong with the script, but it still doesn't work. When previewing, I never transport to the Game Over page when my health is zero, no matter how many links I click.

I've read comments about this happening in people's storygames, so it's possible that it's a bug - but I doubt something so basic could be bugged like this: at least, I really hope so. 

Is there a way to script this? Am I doing something wrong? I'm just searching for any answer besides me pasting the same exact script into over 200 different links.

Variables Equaling Zero on Global Scripts

4 years ago
tried adding begin/end?

IF %HEALTH := 0 THEN
BEGIN
  $DEST := @P163
END

Also not sure := is the right operator here. Boolean operators have been known to have some inconsistencies but nothing in this script seems like it would trigger any I know about.

Variables Equaling Zero on Global Scripts

4 years ago

IF %HEALTH = 0

:= is only for assignment.

Variables Equaling Zero on Global Scripts

4 years ago

Sorry, the := between %HEALTH and 0 was a mistake on my part. In the actual script, I did only use =.
As for BEGIN/END, I tried it out and strangely it still doesn't work.

My script was:
IF %HEALTH = 0
THEN $DEST := @P163

Variables Equaling Zero on Global Scripts

4 years ago
If Health goes below zero then it doesn't equal zero.

Try something like IF %HEALTH < 1

And remember that depending on how you have it set up, if they're being knocked below zero AFTER the script checks Health, there will have to be another click for it to run again and evaluate the new total.

Variables Equaling Zero on Global Scripts

4 years ago

It seems that no matter what value I compare the variable to, it just doesn't register. 
The exact same code, however, works fine if I put it in a specific link script. It's just when I try to put it as a global link it somehow stops. 
It's possible for me to brute-force this by copying and pasting the same lines of code, but I'd like to avoid that if necessary.

Variables Equaling Zero on Global Scripts

4 years ago
I'm guessing its because the global link script executes before the link script, and you're setting this variable to 0 in the link script.

Variables Equaling Zero on Global Scripts

4 years ago

Does the variable being 0 have an adverse affect sometimes?

Variables Equaling Zero on Global Scripts

4 years ago
That's an incredibly vague thing to say but no, there's been no complaint before about 0.

Variables Equaling Zero on Global Scripts

4 years ago
This has to be it. I tested it with a global page script and just setting the effect on the actual variable page, same results. Health gets knocked to -2 in my test and then the next click sends it to the death page I set. Nagito, if you just tell us the name of the game we can look at it. But if you're accounting for the need for the extra click and the variable possibly not being exactly zero, I suppose you could try clearing your cache or refreshing the storygame pop up or something to, in case whatever edits you made just aren't registering while you play. Do you have %HEALTH set to show up on every page so you can make sure it really is at the number you think it is? Could be something in another script setting it incorrectly.

Variables Equaling Zero on Global Scripts

4 years ago

Is it possible that I could add you as a co-author instead, at least temporarily- so you could see the scripts instead of just the game? Looking over everything I have related to that variable, I don't see any other errors, but it might just be my incompetence.

(Also, I went to sleep for 8 hours which is why I'm so late in responding)

Variables Equaling Zero on Global Scripts

4 years ago
Killa and I are admins, so if we just have the title we can look at it in edit mode to see whatever you're doing with the scripting.

Variables Equaling Zero on Global Scripts

4 years ago

Ah, I didn't realize. Sorry for the misunderstanding.

The title is 'Discretion of a Sleuth': cringey, I know.

Variables Equaling Zero on Global Scripts

4 years ago
I think Killa may have it here, I remember this happening to me before. If it doesn't take you to the desire page immediately, follow another link -- does it take you to the desired page one link later?

Or are there any scripts or directions on the page you're directing it to that would redirect it away from the destination page?

Variables Equaling Zero on Global Scripts

4 years ago
Have you set the range of the health variable to allow it to reach zero?

Variables Equaling Zero on Global Scripts

4 years ago

The minimum value for the variable is 0: I tried setting it lower but it doesn't help.

Variables Equaling Zero on Global Scripts

4 years ago
The fact that you had scripting disabled might have something to do with it.

Try it now with scripting enabled.

Variables Equaling Zero on Global Scripts

4 years ago

Still doesn't work, oddly. 
The 'Editor Features' on the 'Story Properties' tab lists Scripting as Advanced, but there's still no sign of change.

I think I'll probably just copy and paste the same script into each link script. I won't need to put it into every single link, and although the task will be boring it won't be painful.

I'm very thankful that a lot of people tried to help, though. If you have any other suggestions, I'll certainly try them out, but I don't have high hopes. 

Variables Equaling Zero on Global Scripts

4 years ago
Mizal noticed this issue before. It's just us looking at the story, he already had scripts enabled (otherwise he wouldn't have been able to make any scripts to begin with).

Variables Equaling Zero on Global Scripts

4 years ago
Not sure how games are setting back to scripting disabled though. This is not the first one I've seen like this.

Also, the global link script in in question works fine in my test game, which leads me to believe 1. It's broke in his game alone, or 2. He hasn't tried Mizal's suggestion of changing it to >

Variables Equaling Zero on Global Scripts

4 years ago
I changed it to > from =

Variables Equaling Zero on Global Scripts

4 years ago

I have tried changing = to <. For example:

IF %HEALTH < 1
THEN $DEST := @P163

I've also tried having it be less than 0 (when I changed the variable so that it could go below 0) and I also tried having it being less than 5 (since in my game you can only lose 5 or 10 health at a time), and neither of them work.

Variables Equaling Zero on Global Scripts

4 years ago
It's not. It's just because we're looking at it through admins means and for some reason it's just doing storygame defaults rather than the actually settings.

Variables Equaling Zero on Global Scripts

4 years ago

Oh yeah, since you guys are viewing my game right now, I should point out that the variable is %INFLUENCE, not %HEALTH (although you probably figured that out already). They serve the same purpose, however- it functions exactly like a health meter. 

The problem might be that I didn't add these variable specifications in the beginning: I created the variable and wrote all the pages in the game, but added the 'Game Over' page last and only made the variable go to that page when it goes under a certain value afterwards. Meaning I wrote the whole story first before adding the global link.

Variables Equaling Zero on Global Scripts

4 years ago

The weirdest part for me, though, is that it's only a problem with the global link script: I tried putting it in a single link script and it worked fine providing I clicked on that specific link.

Variables Equaling Zero on Global Scripts

4 years ago
The weirdest part for me is you keep asking for help yet not actually answering our questions and are instead just strangely obsessed with the number 0.

There's a very easy way to troubleshoot this. It comes down to the following:

1) Tell us what you are trying to do
2) Tell us how you are doing it

You've still not answered 2 completely, because while you continually say "When x is 0 I want to go here but it doesn't work", you still have yet to actually say what is making x equal to 0. This is despite the fact that x actually equaling 0 is LITERALLY the condition we are checking for, and thus making sure it's actually 0 is the very first thing we would want to verify.

And we can't verify that, until you actually tell us, where x is being set to 0.

Variables Equaling Zero on Global Scripts

4 years ago

Alright, I'll explain it more thoroughly. I realize now I glossed over a lot of the stuff I thought was self-explanatory when it really wasn't. Sorry about that.

In the game, you play as a Detective. During the bulk of the game you are part of a large debate, in which you are trying to guide a bunch of people to the correct conclusion in a case. At a lot of points in the debate, you'll be asked to choose a person who meets certain criteria, select a piece of evidence you gathered, etc, which is done through links. Choosing the wrong option takes away some of your %INFLUENCE, which functions like a health bar. Influence starts at 100 and can go down to 0 by getting enough things incorrect. Links that lead the Detective to the incorrect conclusion have variable commands assigned to them to subtract a certain amount of Influence. After I created the Influence variable and assigned these variable commands to the links after writing out the debate, I created the "Game Over" page. Then, I added the parameter to %INFLUENCE stating that if the value went below 1, it would take the player to this "Game Over" page. 

However, this did not work after I play-tested it. I got my Influence down to 0, the minimum value, after selecting enough links that subtracted my Influence. However, the value stayed at 0 without ever taking me to the Game Over page. Thinking this was strange, I then tried to put that command into the Global Link Script. However, that also did not work. I played around with the variable and script a little but nothing yielded a proper result- I was never taken to the "Game Over" page. 

I thought the basic content of my storygame was necessary to understand this. Sorry if this made things a little confusing, and if there's anything needing clarification just ask.

Variables Equaling Zero on Global Scripts

4 years ago

Sorry if everything before this was really confusing. I'm just an idiot.

Variables Equaling Zero on Global Scripts

4 years ago
I play tested a bit and the influence variable never changed from 100. I presented wrong evidence a bunch of times (I'm assuming thats the part where its supposed to go down). Which links are supposed to change the value?

Variables Equaling Zero on Global Scripts

4 years ago
That's related to what I was going to suggest next: are you displaying the variable on every page so you can see when it really does reach zero?

Variables Equaling Zero on Global Scripts

4 years ago

Don't worry, the Influence variable is displayed on every page.

Variables Equaling Zero on Global Scripts

4 years ago

The "debate" section only starts with the Trial section.

Here are the first few points where you can lose influence:

  • Clicking "poison wasn't the cause of death" will lose make you lose 5 Influence (but only when you admit that you're wrong)- using an item after clicking that link will make you lose 10 Influence (again, though, you only lose it when you admit that you're wrong). Don't worry, that feature is done on purpose, and is only done in that section.
  • When you get to the first minigame (that isn't an example) - "Counter-Argument 1" - clicking any of the links and using any of the items will reduce influence: however, the variable deduction is in the "Go Back" link when you fail, so it won't show up immediately. There is only one correct combination to advance the game forward, so clicking any link and then using any item will most likely decrease your influence (it decreases by 5). Just so you know, the correct combination is the link 'Counter Statement 8' and then using 'Secretary's Account.'
  • After that, there are several multiple choice questions, of which only one is correct. Clicking the wrong link will reduce your influence by 10.

I'll stop here b/c there's a lot more but it'll take forever to spell out. 

Variables Equaling Zero on Global Scripts

4 years ago

I'm probably just  going to brute-force this.

Variables Equaling Zero on Global Scripts

4 years ago
@NagitoKomaeda The problem is that you have, in the link scripts--which evaluate before the global script--a different $DEST script that takes them to a different page. You have these in every link script I checked in that section, so the global one never has a chance to trigger.

Variables Equaling Zero on Global Scripts

4 years ago

Ah, those I actually added recently. By 'brute-forcing' the problem, I just put the proper link script in every link you click after taking damage to check if you've reached zero. Those weren't there when I originally posted this.

Speaking of which, I should probably just straight up announce that the problem here is 'solved'. While I'd gladly take suggestions for a way to properly fix this problem, I've successfully brute-forced it and the game should be publishing in a day or two. 

Sorry, I really should have updated this the moment I added everything.

Variables Equaling Zero on Global Scripts

4 years ago
Every example I tried of the same script worked for me as long as I accounted for needing to click another link after the variable went below 1. So I still don't get where the issue was...kind of frustrating, but I guess as long as the game it's working somehow now. And it looks like a big and ambitious one, so looking forward to it.

Variables Equaling Zero on Global Scripts

4 years ago
@Nagitokomaeda

I don't like to mess with someone else's scripting, but if there are typos or something minor like that that need to be fixed, just tell me where they are and I can go in and fix them without the story needing to be unpublished. I see you've republished it four times in the last hour. (Actually, everyone in the discord can see this just fyi....)

Variables Equaling Zero on Global Scripts

4 years ago


Well, that's embarrassing. I didn't realize everyone could see when I unpublished something ...

Sorry about that. I won't do that so often.

 

Variables Equaling Zero on Global Scripts

4 years ago
Oh wait, you can't message me about edits anyway because it's all still broken. Welp. And it's not a big deal, Brad's bot just lets us know when a story is published, but you're not exactly the first to do the frantic last minute edit thing lol.