m'kay - short scripting lesson 101
variables - they are very handy, they are basically words which you introduce to flashpoint saying "hi flashpoint, i'd like you to meet my good friend
variable_name;
variable_name is a plumber, enjoys skiing and plays the flute."
and flashpoint says "hey
variable_name, pleased to meet you."
so variables are quite powerful things. they can be numbers, or they can be words. when a variable is a word, it's called a 'string'.
so if i was to say
my_number = 10
that would store the value 10 in the variable
my_number. i could then use it like any other number, for multiplying, division, addition or subtraction. however, if i say
my_number = "ten"
that stores the string 'ten' in the variable
my_number. since it's a word, you can't do anything mathematical with it. what you can do is add it to other strings to make a sentence, thus:
my_street = "springfield terrace"
my_town = "loonsville"
my_address = my_number + my_street + my_town
so the variable
my_address would hold the value "10springfield terraceloonsville". note the lack of spaces. you need to put those in
on to your second question.
_msg = _this select 0
this is a wee bit more complex, but stay with me, as this is a fundamental that you should learn.
first of all, variables can be
global (which means they can be seen from all points in flashpoint, all the time) or
local (which means they are used only in the script where they appear, and then disappear). whenever you see an underscore ( _ ) before a variable name, that means it's a
local variable.
in other words,
_msg is a local variable, and will only be recognised within its own script. you could call a variable
_msg in another script, but the second
_msg will hold different values for the second script. the two are separate, even if they have the same name.
next comes
_this. there's a whole tutorial on
_this in which general barron explains it better than i could. find it
here.
next comes the
select 0 part, and again, this is a cornerstone of flashpoint scripting.
arrays. let's go back to the address example.
my_address holds one long string, a single address. what if you wanted a phonebook? well, you could create all those variables and do it all by hand, which is tedious.
address1 = blah blah blah
address2 = blah blah blah
address3 = boring boring boring....
you get the idea. alternatively you could create an array. this is a special kind of variable which can hold multiple variables, and indexes them numerically. arrays are defined by square brackets []. again, there's an exellent tutorial by dinger
here which will show you what's what, but in a nutshell arrays store values against an index, starting at 0. so if you say
my_array = []
my_array = my_array + [my_address]
my_array = my_array + [my_address]
then there will be two copies of the address stored in
my_array. to get at these values you use
a_value = my_array select 0
b_value = my_array select 1
now
a_value holds the first address,
b_value the second.
so to summarise:
_msg = _this select 0
creates a local variable called
_msg, and makes it hold the value found at the first position in the array
_this.
as an aside, stick with scripting. it's easier than you might think at first. it's like any other language - once you have the basic vocabulary down, you can start forming some complex sentences. and once you get more experience, you can begin to make your scripts sing