Why doesn’t this work?
"Test":javascript:(function(){%20var%20output=%20"";%20var%20blobheading%20=%20[["heading"]];%20var%20paragraph%20=%20"\n";%20var%20blob%20=%20[["rock","paper","scissors"]];%20var%20bloblink%20=%20"\n\n\n----\nCreated%20With\nCHOOSE%20YOUR%20OWN%20GENERATOR\n----\nhttps://www.lastgaspgrimoire.com/generators/choose-your-own-generator/\n----"; for(var%20i=0;%20i<blob.length;%20i++){var%20heading%20=%20blobheading[i];%20var%20table%20=%20blob[i];%20output%20+=%20(paragraph)+(heading[Math.floor(Math.random()*heading.length)])+(paragraph)+(table[Math.floor(Math.random()*table.length)])+(paragraph);%20};%20alert(output+(paragraph)+bloblink);%20})();
I’ve saved other generator scripts this way and they work fine (albeit with a semicolon visible after the visible text)
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Obsidian Portal doesn't allow scripts of any kind. The word "script" will cause the whole thing to fail - it even goes so far as to screw things up when people use the word "description" because of that rule.
There are others who can explain it better than me, but that's the gist of it.
Ptolus, City by the Spire - 2016 Campaign of the Year
"Please pay attention very carefully, because this is the truest thing a stranger will ever say to you: In the face of such hopelessness as our eventual, unavoidable death, there is little sense in not at least TRYING to accomplish all your wildest dreams in life." - - Kevin Smith
Here’s one that works though. Shortest one I could find:
"20 Random Things Your Characters Experience":javascript:(function()%7B%20var%20output=%20%22%22;%20var%20blob%20=%20%5B%5B%22The%20scrape%20of%20metal%20on%20stone%20echoes.%22,%22You%20catch%20a%20whiff%20of%20wet%20hair.%22,%22The%20tinkle%20of%20coins%20hitting%20the%20stone%20floor%20beckons.%22,%22A%20growl%20reverberates%20around%20you.%22,%22The%20solid%20click%20of%20a%20door%20lock%20pierces%20the%20silence.%22,%22A%20creaky%20door%20hinge%20squeals.%22,%22You%20feel%20a%20rumble%20as%20something%20clatters%20to%20the%20floor.%22,%22A%20sudden%20rush%20of%20wind%20makes%20your%20torches%20dance.%22,%22The%20gurgle%20of%20water%20adds%20to%20the%20noises%20surrounding%20you.%22,%22You%20are%20overwhelmed%20by%20the%20sweet%20scent%20of%20decay.%22,%22A%20door%20slams.%22,%22A%20sudden%20chill%20sweeps%20through%20you.%22,%22You%20note%20the%20rising%20temperature%20of%20the%20air%20around%20you.%22,%22A%20dampness%20in%20the%20air%20threatens%20to%20snuff%20your%20torches.%22,%22The%20clink%20of%20chains%20rattles%20down%20the%20hall.%22,%22A%20stomp%20of%20feet%20not%20your%20own%20echoes%20in%20the%20darkness.%22,%22A%20wet%20smacking%20of%20lips%20punctuates%20the%20silence.%22,%22A%20thick,%20cold%20mist%20rolls%20from%20nowhere%20around%20your%20feet.%22,%22Low,%20muffled%20whispers%20echo%20from%20the%20distance.%22,%22The%20scent%20of%20smoke%20grows%20heavy%20in%20the%20air.%22,%22%22%5D%5D;%20var%20bloblink%20=%20%22%5Cn%5Cn%5Cn----%5CnCreated%20With%5CnCHOOSE%20YOUR%20OWN%20GENERATOR%5Cn----%5Cnhttp://www.lastgaspgrimoire.com/generators/choose-your-own-generator/\n----"; for(var%20i=0;%20i%3Cblob.length;%20i++)%7Bvar%20table%20=%20blob%5Bi%5D;%20var%20alertlinkback%20=%20alertlinkback;%20output%20+=%20%22%20%22+(table%5BMath.floor(Math.random()*table.length)%5D);%20%7D;%20alert(output%20+%20bloblink);%20%7D)();
I can say I've experienced the "description" failure first hand! If you've managed to get a JS to function, more power to you as I've never been able to except with DSTs.
Johnprime
Where the west is really wild!
The Valley of Life
If I managed anything, it was dumb luck. I’m a novice. Hoping someone who knows what they’re doing can explain. It makes no sense to me that it would work sometimes and not others.
If you post a link to the page that has the working code and a link to the page with the non-working one then I can probably help out. It is easier if I see the actual webpage since I can look at the source code for the script but also anything before or after the script that might cause issues.
They are among us!
XCom: Defiance - Campaign of the Month November 2016
https://mark-1.obsidianportal.com/wikis/random-generators
There’s a section at the bottom separated by a line of underscores...beginning with a link called “The Cameron Method”. Those links are each followed by a semicolon. If you click on any of them, it brings up a pop up window giving you the random result. At the bottom is the new one I’m trying called “test”.
I’m very hopeful I can get this to work. Sketched out locations or NPCs in my campaign could have several of these each to provide details on the fly
That campaign is currently private, so I can't see it.
They are among us!
XCom: Defiance - Campaign of the Month November 2016
Interesting
- Kallak
Ok. I copied it to an unused campaign that is public.
https://markiii.obsidianportal.com/
Okay, so the test script still has quotes inside the javascript that haven't been converted to %22 and there is a space before the for that hasn't been converted to a %20
That should fix most of the issues.
For example [["rock","paper","scissors"]] should be [[%22rock%22,%22paper%22,%22scissors%22]]
basically every quote and space caused a break in the script.
They are among us!
XCom: Defiance - Campaign of the Month November 2016
I see a “%20” before “for”. I’m not sure what you mean by there being a space before it.
Look at the code you posted in the first post. There is no %20 in front of for just
;; for
instead of
;;%20for
if your code is different in your hidden page and it has a %20 in front of it then all you need to do is replace all the “ with %22
They are among us!
XCom: Defiance - Campaign of the Month November 2016
My code was the same on the hidden page, it’s just when I post it here, it displays differently. When I say I see a %20 before “for”, I’m talking about when I’m on an Obsidian Portal page editing.
On the public campaign I shared, I copied and pasted the code to the GM Only window to edit it. I replaced every quote with a %22 and made sure there was a %20 in front of “for”. Upon saving, it showed the word “Test” as a yellow link with a semicolon just afterward like the working examples. However, when I click on it, it brings nothing up. I then cut and pasted it to the top of the regular/non-gm only page. Now it’s showing code that spills a mile off to the right of the regular area of the page. I can’t see any of the other links either.
I thought this might be something simple, but apparently it’s not. Since this likely has to do with the fact that I am a novice at this stuff (who isn’t willing to dive into the art of coding), I’m just going to say thank you for the time and effort. I’ll look for another way.
One final question. Are these spaces an error in the original code that I’m grabbing from last gasp grimoire? Or is it just a case of this being something that doesn’t function properly when saved onto an Obsidian Portal page? If it’s the latter, does anyone know of a place somewhere on the intra nets where these codes could be saved and function properly? I could make links to this place in my OP pages.It looks like the test one is missing a couple more conversions. The ones for { } [ ] / and <
try using this
I've got it working herehttps://dead-men-tell-no-tales.obsidianportal.com/wikis/jscript
They are among us!
XCom: Defiance - Campaign of the Month November 2016
Nope.
https://markiii.obsidianportal.com/wikis/home-page
Copied and pasted directly from your text block (or whatever you call it) above.
At this point I’m just responding because it bugs me. I’m going to have to find another way. I was going to use this because it was copy and paste, but it looks like I’d have to spend enough time learning which symbols to substitute where it wouldn’t be worth it.
At his point I’m more interested in knowing if there’re mistakes in the original code. If that normally works but just not in OP, it’d be more efficient for me to just find some wiki or use Wordpress to paste these tables to so that I can link to them from OP.
Thank you very much for taking the time to help