Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

[Answered] What is a Global Script?

14 years ago

How do they run in a story? I just realized that the regen idea I had would call for a global script, otherwise I'm going to have to go to every last page in my story, and implement regen. Which sucks because some decisions you make change you as a combatant, and your style of combat is what dictates your mana and health regen. I would rather have a script that could do the work for me, than me have to spend more time than I need to be spending.

[Answered] What is a Global Script?

14 years ago

The global link script runs every time you click on a link, and the global page script runs every time a page opens. Individual page and link scripts occur after the global scripts - for example if you open the page, the global page script will run, then the individual page script. So if you wanted the global page script to not happen on a certain page, simply alter that page's page script to negate the effects of the global page script.

If you want the regeneration to depend on the player's actions, make variables that change depending what a character does, and then use those variables as conditions for something to happen in your scripts.

[Answered] What is a Global Script?

14 years ago
I don't know if you saw this post in the other thread, so i'll post it here.

Just do this:

Type this into your Global Link page:


%HEALTH := %HEALTH + %HEALTHREG
%MANA := %MANA + %MANAREG

Then, whenever you want to set the regeneration amount for a character, you just put it in the link script for the choice.

So if you choose a warrior the link script for that choice would be:

%HEALTHREG := 5
%MANAREG := 1


And if you choose a mage type:

%HEALTHREG := 1
%MANAREG := 5


Then if you have a choice that ups your health regeneration by one you'd put this in the link script:

%HEALTHREG := %HEALTHREG + 1

Tada! You're done.




If you have any questions about this, let me know, and I'll try to explain better. Also, make sure to change your Editor settings on the Story game properties so that everything is advanced as possible, otherwise you won't be able to see the page for Global Scripts (or scripting stuff at all) and you'll be super confused.

[Answered] What is a Global Script?

14 years ago
This was my reply to Zikara in the other thread

Yup and Zikara's solution is perfect. I'll just go over what she's saying in more detail, just in case she moved a little quickly for you. When I first learned scripting, it all looked like gibberish.

Read everything really closely and make sure you understand each point.

1. When she said global link page, she meant global link script. The global link script is a script that activates any time a link is pressed. Therefore, anything in the global link script fires every time the reader makes any decision. This is PERFECT for what you want since you want it to regenerate on every page. If this wasn't what you wanted, you'd have to copy it into every link script or use complex restrictions.

2. Any word preceded by a % sign is a variable. You're probably already familiar with variables. So %HEALTH is a variable called health, which I'm sure you understand. %MANA is the character's mana. %HEALTHREG (variables have limited length so you can't call it %HEALTHREGENERATION) is how much health is regenerated every link. %MANAREG is how much mana is regenerated every link.

3. so, let's look at what's happening:

%HEALTH := %HEALTH + %HEALTHREG
%MANA := %MANA + %MANAREG

Keep in mind that := means that you're setting the variable before the : to whatever comes after the equal sign. So, reading it out in english.

%HEALTH := %HEALTH + %HEALTHREG
HEALTH is equal to HEALTH plus HEALTH REGENERATION

so if Health is 100 and health regeneration is 5

HEALTH is equal to 100 + 5 or HEALTH is equal to 105. And since this fires on every link, health would go up by 5 on every link. The same goes for mana.

[Answered] What is a Global Script?

14 years ago

Okay, this makes sense. Is there a certain way I could make it begin a certain page? There is a bit of prologue in the beginning, and with scripting, I don't want the regen to start until these certain decisions are made. And if my maximum is set to 100, even with this script, it won't break 100 correct?

[Answered] What is a Global Script?

14 years ago

If the variable maximum is set to 100, it will not go above 100.

As for making it begin on a certain page, simply make one of the conditions for the script to run that the page ID has to be greater than 100 (or whatever the ID is where the prologue finishes). For example:

IF $PAGEID > 100 THEN
...
...
...
END

[Answered] What is a Global Script?

14 years ago
Hahahaha... October. Who's prologue lasts 100 pages?!?! You must be long winded in your introduction :P

[Answered] What is a Global Script?

14 years ago

I think subconsciously I got a little mixed up, thus why the hypothetical prologue goes for 100 pages (as in I used that number because I used it earlier in the post). But it'd be pretty cool if somebody did make a story with a hundred-page-long introduction.

[Answered] What is a Global Script?

14 years ago
Pretty cool, or unreasonably boring.

[Answered] What is a Global Script?

14 years ago
From the other thread:

Yeah instead of

%HEALTH := %HEALTH + %HEALTHREG
%MANA := %MANA + %MANAREG

put

IF $PAGEID > 10 THEN
BEGIN
%HEALTH := %HEALTH + %HEALTHREG
%MANA := %MANA + %MANAREG
END

And replace 10 with whatever you want the starting page to be. Make sure you set scripting to advanced before trying these things.

[Answered] What is a Global Script?

14 years ago

Apologies for the belated response, but thanks to all three of you. I intend to teach myself quite a bit, but still need some clarity on the gray areas. You guys rock!

[Answered] What is a Global Script?

14 years ago
No worries. Oh, and yes, if your max is set to 100, it won't break 100.

[Answered] What is a Global Script?

14 years ago
Is there a way i can select the page myself? This >100 bit won't work the way I want it to, and I've spent a lot of time trying to make it work.

[Answered] What is a Global Script?

14 years ago
What do you mean? As in, select the page number or make it happen for select pages only, or what?

[Answered] What is a Global Script?

14 years ago
If you mean that some pages you don't want it to happen on are later in the story, then some pages you do want it to happen on, then just do the following:

Okay, create a new variable, called STATSON. STATSON should start at 0 (starting value is 0) and then just before you want the script to run, set STATSON to 1 with a link script or just with the variable button. Use this script:

IF %STATSON = 1 THEN
BEGIN
%HEALTH := %HEALTH + %HEALTHREG
%MANA := %MANA + %MANAREG
END

Anytime you want the script to stop running, set STATSON back to 0. Anytime you want the script to run, set STATSON to 1.

[Answered] What is a Global Script?

14 years ago
That's called a toggle btw.

[Answered] What is a Global Script?

14 years ago
That script should go in global link still, obviously.