Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Requesting Script Assistance - Read Help & Info

9 years ago

Thanks to Sethaniel and the other posters that helped me, I've managed to set up the Variables in my game and correct my links.  The problem I'm having now is that I want to use those Variables to limit or enable a player's next move by combining them in a script... and I have no idea how to do that.  The closest I get are some hints that I can do this from the Beginner's Section for Scripting and that it could be possible with pre-page load scripting (courtesy of the Intermediate Scripting guide), but actual implementation is eluding me.

The goal is to somehow get it so that when the page shows a CHALLENGE SCORE the following is run:

 


Result = (CHALLENGE SCORE - AWARENESS - 1d(TENSION))

If Result >= 0:


     Disable bad link (the link to the "YOU FAILED" section)
 

elif Result < 0:


     Disable good link (the link to the "SUCCESS" section)

 


The problem is that I have no understanding of how to do that in this format or even know if it can be done at all.  Any assistance I could get with this would be greatly appreciated :)  Thanks again CYS community!

Requesting Script Assistance - Read Help & Info

9 years ago
Disabling links would be done in link restrictions.

You should see a stop sign beside all of your links. Click it, then go to variable restrictions. You can then decide what variables restrict the link, and what the value needs to be for it to work.

Keep in mind that, although it's called link RESTRICTIONS, what you're doing is saying "this link can only be clicked if this variable equals this", so it's sort of reversed.

Requesting Script Assistance - Read Help & Info

9 years ago

The problem with this method is that my variables are named AWARENESS and TENSION.  As such, they're too long for me to set them into SCORE >= AWARENESS + 1d(TENSION) format >< I'll check back in later and look into the scripting side to see if there's something I could do on that front.

Thanks again though!  Any additional assistance would be greatly appreciated.

Requesting Script Assistance - Read Help & Info

9 years ago
I don't understand.

Set the value of a variable equal to AWARENESS + 1dTENSION, then check that variable. If you need to make another variable to do so then so be it.

You shouldn't be doing an entire check like that inside the link restriction.

Requesting Script Assistance - Read Help & Info

9 years ago

I went into Scripts to try and create the following to get around the character limitation inside the variable checks, but I'm still reaching an error:

%SCORE := %AWARENESS + 1D%TENSION

When I click "Validate" it gives an error saying it doesn't understand 'D' (Col 25 Error).  If I can manage to make THIS work I can just set link restrictions based on the value of SCORE.  Anybody able to tell me what's wrong with the above?

Thanks again all ^^
 

Requesting Script Assistance - Read Help & Info

9 years ago

(I think, but I might be wrong, killa's saying it's got nothing to do with the character length of the variable being too long, it's that the restriction box isn't expecting you to try and do an entire operation in there- it's just supposed to be one variable. ) 

You're trying to make it really complicated, aren't you? XD

So, you want a script for setting a variable to "AWARENESS minus the result of a random die roll, with the die value set to the value of TENSION?

Requesting Script Assistance - Read Help & Info

9 years ago

Yeah, it's a little more complicated than I thought it would be to implement ><

I'm trying to check if a variable called CHALLENGE SCORE (might name it something shorter) is greater than or equal to the variable AWARENESS plus the result of the random die roll that has the value of TENSION, where TENSION and AWARENESS are variables that increase throughout the game but I will be setting CHALLENGE SCORE manually (depending on the page and challenge).  The goal is something like this:

 

Let's use AWARENESS = 3 and TENSION = 5 on a page where there is a challenge with a CHALLENGE SCORE of 6. 

 

IF 6 >= 3 + 1d5:                           # Then this is a SUCCESS, so...


Disable YOU FAILED link.

 

ELIF 6 < 3 + 1d5                          # Then this is a FAILURE, so...

 

Disable SUCCESS! link.

Requesting Script Assistance - Read Help & Info

9 years ago

The problem is it's expecting an integer after 'D'. It won't work with a variable. So you can instead use a constant dice roll of 1D100, multiply the %TENSION variable to it, divide by 100, and add 1.

%SCORE := %AWARENESS + (((1D100)*%TENSION)/100) + 1

It's not strictly accurate due to flooring, so the "dice roll" has a small chance of generating a number one too large, but it should work otherwise.

Requesting Script Assistance - Read Help & Info

9 years ago
Yeah, Bradin is right. It has nothing to do with the length of anything.

You can't set a dice roll to have a max value of a variable, but you can do it in the round-about way he mentioned.

Requesting Script Assistance - Read Help & Info

9 years ago

Oh okay, I'm beginning to understand now.  What is and what's the issue with flooring?  If I take out the "+1" at the end, will this still work?

Sorry for the response delay, I had to fly to Japan ^^ Thanks again though!

Requesting Script Assistance - Read Help & Info

9 years ago

The scripts don't accept decimal values, so any operation that would create a decimal isn't rounded, but floored (everything after the decimal point is discarded). It wasn't accurate because I actually missed a step; really, 1 should also be subtracted from 1D100.

%SCORE := %AWARENESS + (((1D100 - 1)*%TENSION)/100) + 1

The 1D100-1 and the +1 are needed to correct the range of values, because flooring would make them one too low.

Requesting Script Assistance - Read Help & Info

9 years ago
Why do you want to take out the +1 anyway?

Requesting Script Assistance - Read Help & Info

9 years ago

I wasn't aware that flooring existed and thought these numbers existed in their decimal format.  However, I'm now finished and publishing the storygame "Era of Shadows: The Concealed Dagger", which is my first storygame and is making use of all the help I've been given.

Thank you so much, and I look forward to your brutal honesty!