Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

[SCRIPT] Variables Changing Other Variables

6 years ago

I was just wondering about a few things in regards to the script box for links:
1. Is there a limit to the amount of things you can put in one before it doesn't work or anything like that? Asking because apparently 'AND' doesn't work, so slightly worried that other things might not, too.
2. To follow up, if it runs a line and doesn't get to the end, it doesn't do anything, right?
3. Empty gaps in the lines, just enters, do nothing right?
4. AND finally, and the main reason for this post, I clicked the validate script button and nothing popped up, so assuming what I wrote in makes sense. But I'm pretty worried about it and was wondering if anyone could just glance over it and tell me if there is some major mistake the validate button doesn't pick up.

NOTE - I changed variable names for this post, so don't worry, the actual names are all within the proper character limit.

SCRIPT MESS is below, in a reply so I don't need to do the formatting (since I have the fancy text editor turned off).

Thanks!

[SCRIPT] Variables Changing Other Variables

6 years ago

IF %CHARACTERONE = 1 THEN %CHARACTERONE := 1
IF %CHARACTERONE = 20 THEN %CHARACTERONE := 1
IF %CHARACTERONE = 10 THEN %CHARACTERONE := 1
IF %CHARACTERONE = 11 THEN %CHARACTERONE := 2
IF %CHARACTERONE = 21 THEN %CHARACTERONE := 2

IF %EVENTAEND = 2 THEN IF %STATEOFLIFE < 2 THEN %CHARACTERTWO := -1

IF %SPECIALCHOICE < 3 THEN IF %EVENTAEND = 1 THEN IF %STATEOFLIFE > 1 THEN IF %EVENTBEND = 1 THEN %CHARACTERTWO := 1
IF %SPECIALCHOICE < 3 THEN IF %EVENTAEND = 1 THEN IF %STATEOFLIFE > 1 THEN IF %EVENTBEND = 1 THEN IF %GOLDCHOICE = 1 THEN %CHARACTERTWO := 2

IF %MAJORCHOICE = 1 THEN %CHARACTERTHREE := -1
IF %STATEOFLIFE < 2 THEN %CHARACTERTHREE := -1
IF %EVENTAEND = 2 THEN %CHARACTERTHREE := -1

IF %MAJORCHOICE = 2 THEN IF %EVENTAEND = 1 THEN IF %STATEOFLIFE > 1 THEN %CHARACTERTHREE := 1
IF %MAJORCHOICE = 2 THEN IF %EVENTAEND = 1 THEN IF %STATEOFLIFE > 1 THEN IF %SHALLDIE = 1 THEN %CHARACTERTHREE := 2

IF %EVENTBEND = 1 THEN %CHARACTERFOUR := 1
IF %EVENTBEND = 1 THEN IF %LIBRARYARA = 1 THEN IF %LIBRARYARB = 1 THEN IF %LIBRARYARC = 1 THEN IF %LIBRARYARD = 1 THEN %CHARACTERFOUR := 2

IF %STATEOFLIFE < 2 THEN IF %EVENTAEND = 2 THEN %CHARACTERFIVE := -1

IF %SPECIALCHOICE > 1 THEN IF %STATEOFLIFE > 1 THEN IF %EVENTAEND = 1 THEN %CHARACTERFIVE := 1
IF %SPECIALCHOICE > 1 THEN IF %STATEOFLIFE > 1 THEN IF %EVENTAEND = 1 THEN IF %EVENTBEND = 1 THEN %CHARACTERFIVE := 2

IF %SPECIALCHOICE = 1 THEN %CHARACTERSIX := -1

IF %SPECIALCHOICE > 1 THEN %CHARACTERSIX := 1
IF %SPECIALCHOICE > 1 THEN IF %EVENTBEND = 1 THEN %CHARACTERSIX := 2

IF %MAJORCHOICE = 1 THEN %CHARACTERSEVEN := -1

IF %MAJORCHOICE = 2 THEN %CHARACTERSEVEN := 1
IF %MAJORCHOICE = 2 THEN IF %GOLDCHOICE > 1 THEN %CHARACTERSEVEN := 2

IF %MAJORCHOICE = 2 THEN %CHARACTEREIGHT := -1

IF %MAJORCHOICE = 1 THEN %CHARACTEREIGHT := 1
IF %MAJORCHOICE = 1 THEN IF %EVENTBEND = -1 THEN %CHARACTEREIGHT := 2

[SCRIPT] Variables Changing Other Variables

6 years ago
Some notes:

Line Returns are treated the same as Spaces. You can run your code together without paragraphs, but it it easier to organize if you do.

Variable length is limited to 9 or 10 characters.

AND works for a single comparison.

If you nest statements off a single IF, you must BEGIN and END

Example:

IF %SPECIALCHOICE > 1 THEN
BEGIN
IF %STATEOFLIFE > 1 THEN
BEGIN
IF %EVENTAEND = 1 THEN
BEGIN
IF %EVENTBEND = 1 THEN %CHARACTERFIVE := 2
END END END



[SCRIPT] Variables Changing Other Variables

6 years ago
Huh. I thought AND was completely broken. Even if it works just once that's going to make something I was trying a couple weeks ago a lot easier.

[SCRIPT] Variables Changing Other Variables

6 years ago

Ah thanks a heap.

Just to check, the first line doesn't have a BEGIN because it starts the whole chain, right?
(So BEGIN/END is only used afterwards).

[SCRIPT] Variables Changing Other Variables

6 years ago
"the first line doesn't have a BEGIN"

The first line does have a begin.

[SCRIPT] Variables Changing Other Variables

6 years ago

Example:

IF %SPECIALCHOICE > 1 THEN
BEGIN
IF %STATEOFLIFE > 1 THEN
BEGIN
IF %EVENTAEND = 1 THEN
BEGIN
IF %EVENTBEND = 1 THEN %CHARACTERFIVE := 2
END END END
"

I meant in this example, the first line starts with an 'IF', not a 'BEGIN'. So I guess I should have phrased it as "the first line doesn't start with a BEGIN" (EDIT - or "the first line has an IF, but no BEGIN before it").
Anyways, does that mean the example should be:

BEGIN IF %SPECIALCHOICE > 1 THEN
BEGIN
IF %STATEOFLIFE > 1 THEN
BEGIN
IF %EVENTAEND = 1 THEN
BEGIN
IF %EVENTBEND = 1 THEN %CHARACTERFIVE := 2
END END END
"

Or am I just misunderstanding again...

[SCRIPT] Variables Changing Other Variables

6 years ago
The first one is correct. (So is Killa).

IF something THEN BEGIN something something something END

Next Line...

---

So a simple IF statement does not need BEGIN/END
IF %VARIABLE = 100 THEN %OUTCOME := 500

A complex IF statement (that does more than 1 thing) does
IF %VARIABLE = 100 THEN
BEGIN
%OUTCOMEA := 500
%OUTCOMEB := %OUTCOMEA * 100
%EXPLOSION := 0
IF %OUTCOMEB > 5000 THEN %EXPLOSION := 1
IF %OUTCOMEB < 5001 THEN
BEGIN
%OUTCOMEA := 0
END
END

The above is all 1 IF statement, read by the computer simply as
IF %VARIABLE = 100 THEN BEGIN %OUTCOMEA := 500 %OUTCOMEB := %OUTCOMEA * 100 %EXPLOSION := 0 IF %OUTCOMEB > 5000 THEN %EXPLOSION := 1 IF %OUTCOMEB < 5001 THEN BEGIN %OUTCOMEA := 0 END END