Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Vaanishing Scripting Text

12 years ago

I have a problem. I set up the local page code to where if a variable item is 1 (reader has the item) then some text will be displayed. somehow the script isn't reading in multiple text blocks. Say you have two items it will only show one. Here is the code I use for the page...

------------------------------------------------------------------CODE STARTS UNDER HERE---------------------------------------------------------

IF $PAGEID = 99 THEN
BEGIN

%POPULATION := %POPULATION * 99/100

IF %RESEARCHPT = 0 THEN
BEGIN
$PAGETEXT := $PAGETEXT + " You have not gained any technology yet."
END

IF %COMMERCE = 1 THEN
BEGIN
$PAGETEXT := $PAGETEXT + " You have invested in commerce. This means that you are no longer a bartering system market. Instead you swap smaller goods to replace the bulky goods. You can use paper, metal, seashells, or anything else that is readily handy and in great quantities."
END

IF %STONETOOLS = 1 THEN
BEGIN
$PAGETEXT := $PAGETEXT + " Stone tools are used to make other more useful items. From animal skin pelts to the mining of ore stone tools are what gets the ball rolling to make the higher end items."
END

IF %CLOTHING = 1 THEN
BEGIN
$PAGETEXT := $PAGETEXT + " Clothing shields the wearer from the elements."
END

END

-------------------------------------------------------------------CODE STOPS HERE-------------------------------------------------------------

A few things you should know the page its used on is the right one, and yes i know that the first line is awfully redundant and pointless it is there due to personal preference. Secondly Yes there is a variable in there and yes that part DOES work and doesn't affect the rest of it (that I know of).

Am I using the $PAGETEXT wrong? or it is something simple that I had overlooked? someone help me :(

Vaanishing Scripting Text

12 years ago

I removed all the IF checks (didn't want to make a bunch of variables), and it works fine. I mean, it ends up just becoming one big paragraph, but all the text is there.

Which means that the error lies somewhere in your logic.

Should also point out that you don't need BEGIN and END statements for every IF. Just the ones that go for multiple lines/have multiple commands within them.

It's also possible that the section you set the variables (based on the items), is somehow wrong.

Vaanishing Scripting Text

12 years ago

I suggest setting all involved Variables to Show on the pages, then go to that page and compare the variable values to what you are expecting. You may have something altering them before they get to the page.

Vaanishing Scripting Text

12 years ago

Also something to keep in mind :

Variables update immediately with Link & Item Scripts.

On a Page Script however, System Variables ($) update going into the page, while Variables (%) update going OUT of the page.

Vaanishing Scripting Text

12 years ago

Okay I cleaned the code out and it still didn't work. I checked the variables and it isn't them.

-----NEW CODE-----

%POPULATION := %POPULATION * 99/100

IF %RESEARCHPT = 0 THEN
$PAGETEXT := " You have not gained any technology yet."

BEGIN

$PAGETEXT := ""

IF %COMMERCE = 1 THEN
$PAGETEXT := " You have invested in commerce. This means that you are no longer a bartering system market. Instead you swap smaller goods to replace the bulky goods. You can use paper, metal, seashells, or anything else that is readily handy and in great quantities."

IF %STONETOOLS = 1 THEN
$PAGETEXT := " Stone tools are used to make other more useful items. From animal skin pelts to the mining of ore stone tools are what gets the ball rolling to make the higher end items."

IF %CLOTHING = 1 THEN
$PAGETEXT := " Clothing shields the wearer from the elements."
END

-----END OF CODE-----

I put the line of code after begin because I have an idea. What if I made the page blank and then added in the text that I want? What I want to know is how can I make the text that have passed the IF statements add into the "blank" page? I kept the pagetext in the beginning of the if statements so it would validate. I need the pagetext of the if statements to be replaced by the addition  code piece(es). Is this "addition to a blank" a valid solution?

Vaanishing Scripting Text

12 years ago

Show us your variable setting code and we'll decide if it's right or not lol.

Vaanishing Scripting Text

12 years ago

Yeah, it might help if we can see the entire Page Script (here or via PM if you like)

Vaanishing Scripting Text

12 years ago

GLOBAL  LINK------------------------------------------------

 

IF $PAGEID > 90 THEN
BEGIN
%TIME2 := %TIME
%TIME := %TIME + 1
%POP2 := %POPULATION
%POPULATION := %POPULATION * 101/100
 
IF %TIME = %TIME THEN
BEGIN
IF %TIME2 = %TIME THEN
%POPULATION := %POP2
END
 
IF $PAGEID = 91 THEN
BEGIN
IF %TIME > 4 THEN
$DEST := @P92
END
 
END
 
GLOBAL PAGE--------------------------------------------------------------
IF $PAGEID > 90 THEN
BEGIN
 
$PAGETEXT := $PAGETEXT + "<br><br><center>Current Population: <br>" + %POPULATION + "</center>" + "<br><br><center>Current Generation: <br>" + %TIME + "</center>"
 
IF %COMMERCE = 1 AND %STONETOOLS = 1 AND %CLOTHING = 1 THEN
%TECKTOG1 := 1
 
END
 
IF $PAGEID = 92 THEN
BEGIN
 
$PAGETEXT := "<br><br><center>Current Population: <br>" + "0" + "</center>" + "<br><br><center>Current Generation: <br>" + %TIME + "</center>"
 
END

 You already know the page script that i put up, and An item is used to get to the page with a previous page link. The variables used are time (gains 1 per link click), population (gains 1% per click), and the variables representing technology which are either 1 or 0 and gain 1 point when chosen on the research page. Everything works out except that one page where i cant make more than 1 entry appear.

Vaanishing Scripting Text

12 years ago

Well, I don't see any of the variables used in the checks, so I'm guessing those are in the global script?

But, I do see that you set "TIME := TIME + 1", which means your "IF TIME := TIME" statement will never be true.

I failed there lol.

Vaanishing Scripting Text

12 years ago

The Logic is a bit odd in the red part. Basically, you are setting %TIME above and then asking if %TIME = %TIME. Any Variable will always = itself. Then in the next part you have again set %TIME2 to = %TIME above, then changed %TIME by +1 (so this section will never be true).

 

IF $PAGEID > 90 THEN

BEGIN

%TIME2 := %TIME

%TIME := %TIME + 1

%POP2 := %POPULATION

%POPULATION := %POPULATION * 101/100

 

IF %TIME = %TIME THEN

BEGIN

IF %TIME2 = %TIME THEN

%POPULATION := %POP2

END

 

In your Global Page, you can’t use AND/OR statements due to a system wide bug. You’ll have to use a workaround for that logic…

 

IF %COMMERCE = 1 AND %STONETOOLS = 1 AND %CLOTHING = 1 THEN

 %TECKTOG1 := 1

 

Vaanishing Scripting Text

12 years ago

 

 

PS – Here’s the workaround, if you didn’t already know:

 

FOR THIS:

IF %COMMERCE = 1 AND %STONETOOLS = 1 AND %CLOTHING = 1 THEN

 %TECKTOG1 := 1

 

USE THIS:

IF %COMMERCE = 1 THEN

BEGIN

IF %STONETOOLS = 1 THEN

BEGIN

IF %CLOTHING = 1 THEN

 %TECKTOG1 := 1

END

END

 

Vaanishing Scripting Text

12 years ago

I knew the workaround. I just hoped that I wouldn't have to use it :(. I used the whole time and population 1 and 2 because in some cases a bug showed up where time would be the same but population would still increase. It would only work if the time "stood still". Thanks for the help fellas I'll check out the revised code soon.