Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

frustration with Random Variables

9 years ago

Argh.

I've run face first into a brick wall over what was supposed to be one of the simplest and most fundamental aspects of my story.

Can someone explain to me why the following won't work as a script in a link?

%RAND := 1D8

IF %RAND = 1
$PAGETEXT := $PAGETEXT + "blah blah blah"
%EFFECT% := %EFFECT + 1

IF %RAND = 2
THEN
$PAGETEXT := $PAGETEXT + "blah blah blah"
%EFFECT := %EFFECT - 1

...and so on to cover 1 through 8.

I click the link and the page is just blank.

I'm praying it's just something really simple I've overlooked because damn, I'll have to scrap the entire story at this point if this isn't doable.  And I'm raging just a teensy weensy bit here because this really did look so straightforward. :/

 

Hmm.

Okay so further testing reveals that %EFFECT is processing...all eight times at once. Not exactly what I had in mind. Various strategic placements of BEGIN and END had no effect, and the text is still not showing at all.

frustration with Random Variables

9 years ago

Unless there's some other script messing with it, I can confirm this works:

%RAND := 1D8

IF %RAND = 1
THEN BEGIN
$PAGETEXT := $PAGETEXT + "blah blah blah"
%EFFECT := %EFFECT + 1
END

frustration with Random Variables

9 years ago

I have exactly that, and %EFFECT is being tracked like it should now but I'm still not getting any text at all. frown

There aren't any other scripts right now but a global one tracking time, so nothing should be interfering.

frustration with Random Variables

9 years ago

Oh, wait. You're using a link script? In that case, I believe the issue is that $PAGETEXT is only usable in a page script.

frustration with Random Variables

9 years ago

FFS. That seems a little arbitrary.

Well. All right, I doubt I'll be able to write this one at all then, but eh, at least I was able to realize that before I got too deep into it, so thanks.

I'll think on it a bit longer to see if it might be salvageable minus all the advanced stuff, but I've got stories with more involved plots I should probably be working on instead.

frustration with Random Variables

9 years ago

Just create another variable called SETPGTEXT, use the link script to set it, then use the SETPGTEXT variable to set PAGETEXT in the page script.

frustration with Random Variables

9 years ago

...maybe?

I'm exhausted right now I'll need a few moments for my brain to process this.

frustration with Random Variables

9 years ago
How is that arbitrary at all? A link does not have page text, hence it can't use the $pagetext variable.

You could easily just have all this in the page script of the destination, so it's not like it's not doable.

frustration with Random Variables

9 years ago

A link knows exactly what page it's taking you too, though. Altering the text on it doesn't seem like it should be so impossible when it processes before the page is displayed.

I'm working on James' method right now. I wish we really could put regular scripts right on the page, it's a little convoluted having the dice roll and the variable changes in the link script and having to stick the actual text in a separate place, but if I can just get it working I'll put up with that. 

edit: whew! working now! James, you're a lifesaver. So immeasurable my gratitude, it entirely outweighs my slight lingering resentment at being indebted to a furry. :)

Hit a slight hitch with the last bit of text just hanging around after the player left and came back, but I went to all the other links and told it to switch %SETPGTEXT to a number that wasn't covered when they left so it's all good now.

And now I must sleep.

frustration with Random Variables

9 years ago
"I wish we really could put regular scripts right on the page,"

You can, assuming "right on the page" means the page script. The page itself loads, then the script goes off. So long as there's nothing on the page itself that relies on the page script, there's no issue.

frustration with Random Variables

9 years ago

I meant as in using IF THEN ELSE and manipulating variables all together in the same place.

It wouldn't matter so much under normal circumstances, but I'm having to write out events like this for over a dozen different spots and then make sure to clear $SETPGTEXT for every link out, and it adds up after awhile. Being able to just dump a template that handles everything on one page and then edit as needed would be just lovely right now.

Eh, don't mind me, I've just been fooling around with the idea making a parser IF in Quest and some of the possibilities there are making me giddy. heart 

frustration with Random Variables

9 years ago
"I meant as in using IF THEN ELSE and manipulating variables all together in the same place."

Yep, still can do that. Unless "Variables" is only meaning $PAGETEXT.

frustration with Random Variables

9 years ago

Unless I'm misunderstanding here, afaik variables and IF statements have to be in the link script, and $PAGETEXT on the page itself. If you can do both on the page then I'd like to know how, because I haven't run across anything in the articles about it, and I'm going with what James posted about using %RAND to set another variable with the link script to spit out specific text on the actual page.

Which is doable, but becomes a little tedious when you're doing it x100.

frustration with Random Variables

9 years ago
Then you're misunderstanding, because the only thing specific to links and pages is that $PAGETEXT can only be manipulated in a pagescript.

Normal variables can be manipulated in the pagescript just fine. However, since the page itself loads BEFORE the page script goes off, anything in-line on the page (so like %%VARIABLE%%), won't work properly if you edited it in the page script. So unless you're dealing with that specific scenario, you're fine.

frustration with Random Variables

9 years ago

Would you be able to explain how, then, because I'm still not quite able to figure it out. All I've got to go by here is the On Page Variable Tricks article. It shows how to display variables, or text based on variables (which I'm already doing) but nothing about actually altering them on the page. I thought it was only the links, and most specifically actually clicking the links that could trigger that.

I'm not sure if it'd be usable in this specific scenario anyway since I do need specific text to show up based on %RAND, but it'd be good to know for future reference.

frustration with Random Variables

9 years ago
Pages have a page script. If you look at the left side of the title (when you open a page to edit it) you should see an icon that looks like this:

:=

Click that and you'll be able to put this into the page script (which works the same way the link scripts do).

If you're doing something like this on the page script:

%RAND := 1D6

IF %RAND = 5 THEN $PAGETEXT := $PAGETEXT + "The number is 5."

It will work fine. The only time it won't work properly is if you have the variables displayed on the page itself. So if you do this:

%%RAND%%

It won't show that the value of RAND is 5, because of the way the system works.


frustration with Random Variables

9 years ago

Just keep in mind next time that PAGE text only works on PAGE scripts, and link scripts are only use to manage variables.

frustration with Random Variables

9 years ago

Sorry. I was under the impression that page scripts could only be used to set PAGETEXT and a few other system variables, not user-created variables. So, you really are better off putting all of your stuff in the page script.

frustration with Random Variables

9 years ago

"Pages have a page script. If you look at the left side of the title (when you open a page to edit it) you should see an icon that looks like this: "

FML, how did I never even realize this? surprise

But in this case though, it turns out I actually do need to stick with the %SETPGTEXT method, because after a little more work, there's four ways to get to this page and I only want one to show the changed text. So that one has to rely on the link after all.

The page script is still really useful though since I can reset %RAND to clear everything for when the player returns without having to worry about sticking it in every exit link, and I can think of a couple of other things I'll be able to use it for later. This really does open up a lot of possibilities...