Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

HTML Variable Help

12 years ago

Hey guys I need help with adding pictures to a certain page. I have this script "%%YEAR%=%-3000%<img alt="1-1.jpg" src="http://chooseyourstory.com/resources/images/user/19807" />%%" and it works no problem but I also want to make it so that if a certain variable is a certain number then it becomes another picture. So how do I insert this secret variable along with the year? I do not know anything about HTML.

HTML Variable Help

12 years ago

So you need multiple variables controlling the images? I'd suggest switching to a page script (click the := symbol next to the page title to bring it up). Then you can use 'BEGIN' and "END' to nest some IF statements. I'd also add indentation to help you keep track of where you're at:

$PAGETEXT := "<p>Text you want before images.</p><p>"

IF %YEAR = -3000 THEN

BEGIN

    IF %SECRET = 1 THEN

        $PAGETEXT := $PAGETEXT + "<img alt="1-1.jpg" src="http://chooseyourstory.com/resources/images/user/19807" />"

    ELSE IF %SECRET = 2 THEN

        $PAGETEXT := $PAGETEXT + "<img alt="1-2.jpg" src="http://chooseyourstory.com/resources/images/user/19808" />"

END

$PAGETEXT := $PAGETEXT + "</p><p>Text you want after images.</p>"

 

Untested code, so it may contain errors! Just something to give you the general idea.

HTML Variable Help

12 years ago

I have been thinking about switching to page scripts a couple of times but no matter what I do I can't get the $PAGETEXT command to work! I have tried everything including copy and pasting the same command that the advanced scripting tutorial had. But when I go to test it nothing changes.

HTML Variable Help

12 years ago

I thought you weren't go to use negative values for variables anymore? You could just store it as a positive variable (YEAR -3000, would be YEAR 0), and then just subtract 3000 when you show it to the player.

If you want more control over you're scripting, you need to use page scripting, like the script I showed you when you first ask the question. There, you can use the AND function, and change the script to:

IF %YEAR = -3000 AND %SECRET = 1 THEN

        $PAGETEXT := $PAGETEXT + "<img alt="1-1.jpg" src="http://chooseyourstory.com/resources/images/user/19807" />"

ELSE IF %YEAR = -3000 AND %SECRET = 2 THEN

        $PAGETEXT := $PAGETEXT + "<img alt="1-2.jpg" src="http://chooseyourstory.com/resources/images/user/19808" />"

HTML Variable Help

12 years ago

The problem is that when I put in "<img alt="1-1.jpg" src="http://chooseyourstory.com/resources/images/user/19807" />" it tells me that the 1 next to the alt= is not valid nor is the h in http. Also the $PAGETEXT command just doesnt work for me no matter what I do.

HTML Variable Help

12 years ago

Oh yeah, quotes. Quotes are a problem. Try replacing them with single quotes instead:

"<img alt='1-1.jpg' src='http://chooseyourstory.com/resources/images/user/19807' />"

HTML Variable Help

12 years ago

I feel pretty stupid. I wrote about 150+ pages 50% of them with pretty advanced scripting. I thought I had discovered pretty much everything. And then I notice a ":=" next to the page name. Before that all my scripts were link scripts. Now the $PAGETEXT works... -epic facepalm-

HTML Variable Help

12 years ago

Oh wow....