Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Are global item effects possible?

5 years ago
What I mean is, I would like an item that works on every page without having to specify an effect for each and every page in the game. Can this be done?

When you create an item, and choose to add an item effect, you have to specify which page you use it on, and where it leads you. Well, the item I want to create is one that always leads to one place, and always takes you back to the page you used it on (with a simple "go back" link on the item page). I don't want to have to make 80 different item effects (one for its use on each and every page).

Is that what "Default effect" is?

So can this be done, and if so, how would I go about doing it? Thanks!

EDIT- Yes, after reading the Using Items help page, that is what "Default effect" is (should have started there, lol).

But... now that I have A solution, I'd like a better one. I would much rather not have to use an item. Is there another way? Is there a way to create a link that shows up on every single page without manually putting it in every time?

EDIT 2: What I'm considering doing is basically putting in a "game mode" that the reader may switch between on any page. I am not sure I'll put it in, because aesthetics are pretty important to me (the "default effect" with an item has already solved the problem, but I'm looking for a neater way; specifically, just a link at the bottom that is on every page without having to do it 80 times)

Could this be done in Global Script- without using an Item and nasty Item box that shows up? Thanks again!

EDIT3: I will be looking into making the item box invisible, too. Since Ogre helped me learn how to make the page title invisible, perhaps that is possible as well?

Are global item effects possible?

5 years ago

The only way I can think of automatically adding a link to every page is through JavaScript. You'd have to first create the one real link and hide it behind a restriction or inaccessible page. Then you plug it into this script, replacing any double quotes with \42 and single quotes with \'. If there are no other links on a page, the "No links" text will still display.

$PAGETEXT := "<!--<-->script<!-->-->
document.addEventListener('DOMContentLoaded', function() {
  var ul = document.querySelector('.dark1border + div > ul'),
      html =  '<!--<-->li<!-->--><!--<-->a onclick=\42PostBack(\'FollowLink\',\'1\');return false;\42 href=\42#\42<!-->-->The Next Page<!--<-->/a<!-->--><!--<-->/li<!-->-->';
  ul.insertAdjacentHTML('beforeend', html);
});
<!--<-->/script<!-->-->" + $PAGETEXT

Are global item effects possible?

5 years ago
Could you do something like this:

$PAGETEXT:= $PAGETEXT + "<a onclick='PostBack(&#39;FollowLink&#39;,&#39;52&#39;);return false;' href='#'>Game mode... ACTIVATE!!! *SFX here*</a>"

Once you've created the link on some random page, gone into the source, and taken the link ID to swap in for that number bolded in purple? It doesn't line up with the other links, especially with an item system, but maybe there's some way to make them line up?

Are global item effects possible?

5 years ago

You could, and I'm sure you could find a way to position them together, but that likely would mess with any other absolute positioning you tried to do. I think if you're trying to create an element that looks and acts like it's part of a set, it's better to just inject it into that set than go crazy with CSS trickery.

Are global item effects possible?

5 years ago
I looked around, but I wasn't able to quickly find the code to hide just the inventory section. Instead of trying to use that and hide it, I'd suggest it may be MUCH easier to use script to handle the items. In other words, you can add a variable named HASGUN, for example, and when it is 1, the user has the gun and you can react to that, but when it is 0, the user doesn't have it. Then you can use that conditional to include links or adjust text. Then you don't have to deal with items or the inventory box at all.

Are global item effects possible?

5 years ago

There won't be an icon with that method though, right?

But my major concern here is this, if you'll forget the item thing for the moment: how can you put a link on every page using script, without having to manually put it in every single time? My problem would be solved if I can have a global link.

The post above yours by BradinDvorak may be what I need, so I'll have to investigate that script. I do know that with less than one month left in this contest I may just say f it to this entire idea, if I can't get it working in a day. But if I could just have a the same link appear on every page, then I'd have what I'm after.

Are global item effects possible?

5 years ago
The correct answer is yes.

Just put a script in the global link script box that check s to see if the player has an item (by it's $itemstate) and if so do XYZ

Are global item effects possible?

5 years ago
If you can't find the global link script box, then you need to set the story properties to use advanced scripting.

Are global item effects possible?

5 years ago
Thanks. I actually did find the global script page when digging through the forums to find out how to have colored links. But to be honest the “Item” thing was just the best idea for having a permanent “options” link on every page I could think of. What Killa Robot posted below, however, would very much solve my problem in the most elegant way I can imagine.

Are global item effects possible?

5 years ago

Being accessible from anywhere is kind of the point of an item.

Though I have several links in the top bar of a storygame I've made:

Capture

Looks decent I think.

Are global item effects possible?

5 years ago
THAT is AWESOME and would be absolutely PERFECT for what I need. What I need is an "Options" tab. But I imagine the scripting for that is graduate level, lol.

Are global item effects possible?

5 years ago
Hmm, not really. All I'm doing is this:

$PAGETEXT := $PAGETEXT + [div style='position:absolute;top:3px;left:355px;background-color:#D65C5C'][a color='#FFFFDD' onclick='PostBack('FollowLink','2');return false;' href='#'][font size='1' color='#FFFFDD']FORFEIT MATCH[/font][/a][/div]

In the global page script. Basically just adding a div to put in a link at a fixed position, then did some trial and error to get positions/colours right. All you would need to do is change the square brackets to <> ones, the 2 within postback to the actual link number, and FORFEIT MATCH to OPTIONS.

And the apostrophes within postback are actually in their code form: & # 3 9 ; (with no spaces between the code)

Are global item effects possible?

5 years ago
Wow I appreciate you sharing that. I just have two little questions (and I'll be testing this anyway):

I already have something in global PAGE script to help color my links and hide the title at the top of the page, thanks to help from Ogre11 (I have never used global link, and I don't even know what it does). It's this:

And on every single page in the top left script icon, in order to have the parallax effect I want, I have this (Ogre11 again, and BradinDvorak helped a ton with this one):

Would putting your script in, do you think, cause issues with those? If I'm honest, I can barely follow any of my own script, because a lot of it came from other people, and the rest was from trial and error without really understanding what I was doing.

I'm not expecting you to do the testing for me; I'll do it myself in a test game. But I'm just asking if off of the top of your head if you think it might present problems.

Thanks again for being so helpful and not hoarding epic scripting! All of you guys are so helpful here. It's awesome.

Are global item effects possible?

5 years ago
First might change the colour of the link. Second one just looks like it adds a background, which wouldn't affect it.

Are global item effects possible?

5 years ago
Yeah the second one just adds a background that fits the entire page, but it also limits the height at which the text can scroll over it. And the very last line colors the links. The first script I posted, I believe deals with the color of when you click or hover over links, and erases the red lines of the title at the top (and in fact erases the title altogether).

Are global item effects possible?

5 years ago
Hopefully this is the last two questions I have.

(1) What do I do with the href='#' part? I ask because I changed the number in PostBack('FollowLink','2') to PostBack('FollowLink','27'), because 27 is the page number, and switched the square brackets to <>, but I'm still getting a validation error.

(2) I'm not sure I understand what you mean with the & # 3 9 ; parts. Where would I put that?

Are global item effects possible?

5 years ago
Oh, wait. You mean the code that creates an apostrophe. So I need to replace all those apostrophe's with & # 3 9 ;'s? Yes, I know I'm coming off as a super noob. 'Tis what I am.

Are global item effects possible?

5 years ago
Here is what I have on my test game. It's two pages long, and the second page is obviously #2. I copied your code, replaced the []'s with <>'s, and replaced the number with 2.

Alas, no results. :(

Unless... is the page it goes to supposed to be an item? Or something like that? Sorry to keep pestering, but I'm probably going to be diving into this for a couple of days and then if I can't figure it out by then, it's back to writing.

Are global item effects possible?

5 years ago
Nevermind about href='#'. Found that out with google. It just takes you back to the same page, according to: What does href=”#” mean?

Are global item effects possible?

5 years ago

More specifically, "#" is used to jump to an element on a given webpage if you provide the element's id after the "#". For instance, #804457 jumps to this post right here. A "#" by itself takes you to the top of the page.

In this case, it doesn't matter what its href is as long as there's something there, since some browsers might treat it strangely without one. The important part is the onclick function, and as long as it returns false, the href is ignored.

Are global item effects possible?

5 years ago
EUREKA! PROGRESS! Instead of doing $PAGETEXT := $PAGETEXT + I just put $PAGETEXT := "[div ... etc and then ended with + $PAGETEXT.

This put the link at the top of my page. So at least I've gotten that far. Still more work to do, as it actually didn't take me to page 2 (but again, I think that might have something to do with href='#') but thanks again!

When clicking on it it actually does nothing but add a # to the end of the url in preview. It doesn't actually take me anywhere but to the same page.

Here is exactly what I have now, and it doesn't produce an error. However, again, clicking it doesn't take me to page 2, it just keeps me on the same page but adds a # to the end of the url.

Doing exactly the same thing but with $PAGETEXT := $PAGETEXT + style instead was producing errors preventing validation of the script.

Are global item effects possible?

5 years ago
Putting quotations around [div [stuff] [/div] (with <> replacing []) allowed me to use the $PAGETEXT := $PAGETEXT + "[Stuff]".

Still have a link that appears at the top but which leads to nowhere, though. Will keep grinding. (updating in case you see something or in three years some other poor sap needs to see how to do this)

Are global item effects possible?

5 years ago
How long ago was that game made? Because now I have the exact code you posted except I had to put " marks around the div, and it still takes me nowhere. Did someone with the power to do so disable FollowLink or something?

Are global item effects possible?

5 years ago
You need to have the ' code around the follow link part too.

You also need to actually have a link. Its not a page number you're putting inside, its the link number of a link you already made.

Make a link to the page somewhere, start the story and look at the page source code. Get the number. Then go back to the edit mode ande make the link only show up under an impossible condition, so it never shows up.

Are global item effects possible?

5 years ago
Got it working finally!

Okay prepare to laugh your ass off at me.

THIS is why it wasn't working: There needs to be a space between the ' on either side of the page number. The number 2 WAS the correct page number, I just didn't have spaces between the ' and the number on either side. When I did that... POOF! It works now. Thanks a lot for helping. Really all of you guys. So willing to help a code noob. It's very appreciated.

Next on the agenda is to see if this scripting causes irreparable damage to my actual storygame. Need to make sure it's compatible.

Are global item effects possible?

5 years ago
Unfortunately, while this works in my test game, it's not working in my main game. The page number is a different chapter. I wonder if that causes the problem? Or it could just be all my other scripting which depends upon the same variable, and each page has it's own div as well (wouldn't surprise me if two divs aren't allowed, but then I know little of this topic). Anyway Thanks for all your in put. I'll spend another day messing with it, otherwise it will be used in another game.

Are global item effects possible?

5 years ago
That said, using an item to do it works perfectly fine. Worst case scenario, that's what I'll do.

Are global item effects possible?

5 years ago
Killa's right- that number ('2' in your case) is the link number, not the page number. It's literally the second link you've made, and so the script is saying

"COMPUTER- FOLLOW EVERYTHING IN THAT LINK SCRIPT AND TAKE US WHERE IT LEADS".

In your storygame you'd follow a similar process to making 'use item' links in Zikara/my article- you can do Killa's method or make a page linked from the first page (for convenience- so you can go into preview and get to the page's source quickly) and put all the links there. If you're going to do this a lot, probably want your a page for all these links.

So I've pulled this from my LINKS page on my current WIP:

<a onclick='PostBack(&#39;FollowLink&#39;,&#39;709&#39;);return false;' href='#'><b>[COMBINE!]</b></a>

The purple number will be different for you and you'd need to change the " to ' as I've done if you copy and paste from the source.

Are global item effects possible?

5 years ago
I did actually get that part to work for my test game, which has no other scripting other than a variable which you change when you click the link. Unfortunately, for my script heavy game, which has it's own div on every page, whenever I click on it I get an error. BUT, it could be I'm putting the wrong number in, as you guys are saying. I'll look carefully, but in the case of my test story, the link number apparently coincids with the actual page number. Specifically, this number here, when put in my script in the test game, works exceptionally well:

But in my other game, I use the same number found at that location for that particular page, and unfortunately it creates an error every time. EDIT- I did mention that it jumps to another chapter. I doubt that could be the issue, but who knows? (certainly not me lol). But I'll test it by putting it in the same chapter to see.

Are global item effects possible?

5 years ago
YEP. If I put the link of the "Options" page in the same chapter, it works. So THAT is the issue. Now... how do I go about solving that... Odd, however, is that using an item doesn't have the same problem.

EDIT-SCRATCH THAT. It works ONE TIME if I do that, and sends me back to the beginning. Man...

Hmmm... Make a link in each chapter, then add an if/then condition to the script? That's scary sounding...

That or just write the entire game in a single chapter (ugh...)

There is one other issue: My script that changes text and font for the rest of the game actually screws with the link at the top's color. Not really too concerned about it though.

Are global item effects possible?

5 years ago
Noep nope nope. You guys were right all along and I just didn't quite understand it (not that I ever doubted you, but being new to this I wasn't quite understanding what you were saying).

90% certain it's solved now. This is what I did:

(1)Entered the script in global page.

(2)Started the game.

(3) Actually put the link to my options page at the bottom so I could have it on the page during gameplay.

(4) Went to the page that had the link

(5) Viewed page source

(6) Used control+F to find all the locations of the name of the link. Found one that had the LINK NUMBER, which was INDEED different from the PAGE number. There were two cases; one where the number was 30, which is what I entered in the Global Page Script, and another one, which had a different number. I changed the script to a different number, and it worked.

Final test: See if it works between chapters now that I know how to find the LINK number.

Are global item effects possible?

5 years ago

Again, that number is the PAGE number, not the LINK number. The two numbers hold no relation at all. Odds are the 2nd link you made just happens to be the one to that page.

This is how you get the link number:

Capture2

Are global item effects possible?

5 years ago
I would like to point out how far the community has pushed the editor in the last seven years.

This would have been considered unthinkable when I first started coming here. I read through all the scripting
articles and talked with 3j about what was possible. In those days OMS was one of the most impressive
advanced editor pieces we had. SindriV pushed the editor a little further in my opinion.

You and a few others like Berka started making huge strides probably 5 or 6 years back.

Are global item effects possible?

5 years ago
Thanks Killa Robot. I did actually finally get that part sorted out (when I found the same text in the source, but with two different numbers- because one was what I wrote and the other was the actual link. My first clue should have been LINKS spelled out in bright green, haha), but again thanks a lot.

It's finally working, with only one minor issue with the font (most likely due to the scripting I have on other pages). But I can totally live with that. So, again, you and all the others, thanks for the help. Finally working. I am quite excited about that.

Are global item effects possible?

5 years ago
Just for shits and giggles, I replaced 'PostBack('FollowLink','2') with history.go(-1), and created my own Go Back button (which actually works exactly like the default Go Back button). Then, for even more shits and giggles, I replaced THAT with history.go(+1), and it does nothing on page one, but if you go to page two, then use the default Go Back button, and THEN click the new custom "Go Forward in History" button, it brings you back to page 2.

Obviously this is hardly relevant. But it is making me wonder if FollowLink is still a valid parameter on this website (you know, maybe some Glorious Leader Super Admin changed it so that it isn't allowed anymore?).

Back to grinding!

Are global item effects possible?

5 years ago
It’s a very panickety thing, but you can find the font, size, colour etc. In the source code of any page in the ‘preview’ mode to get the exact same text as ‘go back’ and ‘restart’- yours is very slightly different with the background filling and no trial and error.

Also you don’t need the apostrophe in code form as long as they’re single quotes, works exactly the same as long as the only doubles define the beginning and end of the script

Are global item effects possible?

5 years ago
My main problem isn't making the link look like that. The problem is that, while you can click on the link, it takes you nowhere. You stay on the same page. I'm thinking my problem is here (in Killa Robot's script): ('FollowLink','2'). I'm trying to go to page 2 when you click the custom made link at the top of the page. So I put 2 in there, because that is the page number. It looks like that isn't what I'm supposed to actually put there, if I understand Killa Robot's last post. But when I look at the source code when playing the game, it looks exactly the same regardless of what page I'm on, and I'm not sure where I can find what is supposed to actually go there.

As I said before, I'm quite the virgin at this sort of thing, so sorry for the elementary questions/misunderstandings.

EDIT- Mission accomplished! The problem was that & # 3 9 ; and the page number need to be separated by a space. Or at least, when I did that, suddenly it started working.

Are global item effects possible?

5 years ago

So, here is where I stand now.

It DOES work between chapters. So that part is solved. Only one problem remains:

Getting the link to look right up top. I'm thinking since I already have a global script for my link hover colors, that it's messing with it. The blue just doesn't work with my aesthetics in the game for normal links. I'll see if there is something I can figure out on that, but at this point the important part is now people can switch between which visual mode they want to use, which I think is pretty important since I don't want to annoy readers.

Fingers crossed, but it looks like all your help has solved the main problem. And thanks a million to all of you.

One weird problem remains... If I delete the link to that options page on the first page of my chapter 1 (the page I put it on so that I could see the page source and find the link number), I then get the error when I click on the link. Does deleting the link from that page, perhaps, change the link number?

Are global item effects possible?

5 years ago

Don't delete the original link. Think of the links injected into every page via the global page script as references to that one. You can hide it with an impossible link restriction, you can put it on an inaccessible page, but don't delete it or none of them will work.

Are global item effects possible?

5 years ago
I didn't delete the actual page. What I did is, on the first page of chapter one, I linked to the Options page at the bottom, just like any regular link (I did this originally just to test to see if the page itself worked to swap modes). In addition, in my global script I have the link there, which puts a link at the top of every page that goes there. Now, if I remove the link (at the bottom of page one), I get an error when I click the link at the top. So now I'm stuck with putting that extra link in page one.

I'm okay with that if I can make it invisible, WHICH I CAN by changing it's color black (since that's the color of the page at the bottom). Unfortunately, the bullet remains (orange) and the hover color remains orange, and I can't get rid of THAT without getting rid of my link hover color adjustment (and blue just does NOT work for me).

Are global item effects possible?

5 years ago

Just like every page has an ID, every link you create in the editor has an ID. Now, for example the function PostBack('FollowLink', '5'), of course refers to the link with the ID of 5, but all it does it direct the site to follow that specific link; where it leads is dependent on the link itself. If you remove the "real" link, then there's no defined destination and you'll get an error if you try to access it with a copied "FollowLink".

I'm saying you need the link, but it's possible to hide it. You could create a variable that's always zero and then put a link restriction that hides the link unless it isn't zero (or any similarly impossible condition), or you could place the link on a page that the player will never be able to access. As long as the link "exists" on a page somewhere.

Are global item effects possible?

5 years ago
Lol wow I'm dumb. The variable should do it. LMAO why didn't I think of that. Thanks.

EDIT- Yep, that did it. Also it works across chapters, so it looks like every base is covered.

Well you guys, all that's left is making the link at the top look right, which is nothing but font, color and spacing. Thanks again! I honestly can't believe how helpful you guys are. Over at a physics forum I frequented for homework help often times some of those assholes responded with "use the search function." (which, btw, I have done extensively, but there is only so much you can find)

Are global item effects possible?

5 years ago
Only one weird thing is happening, and I think it has to do with the script of each particular page.

On the Title page of the story game, and on the page that the link goes to (which allows you to toggle the options), the top of the page looks like this:

But on every other page it looks like this:

Obviously there is some sort of bolding going on with the font. Is it because of the previous link's or page's bold? What could it be? I don't know. I'll investigate later tonight.

The title page and the options page lack the div script all the other pages have, and they also lack some of the on page font scripting. I'm not sure exactly what is causing this, but other than that, everything looks and works great.

Of course, I can live with that. ;)

Are global item effects possible?

5 years ago

You might have an unclosed bold tag somewhere or it’s being bolded by some more general CSS selector. You can always slap a "font-weight: normal" in its CSS to force it not to be bold.

Are global item effects possible?

5 years ago
It's always the simplest things. That was it.