yes you can have scales that run through multiple shapes, different octaves, etc
for instance this:
D-------------4-5-7-
A------4-5-7-------
E--5-7---------------
is the same as this:
G--------------1-2---
D----------2-4-------
A----2-4-5-----------
E--5-----------------
and i see why i didnt get what you were talking about, i think you're talking about key signatures? there are things called modes, so it threw me off
if so, its all based on the scales and the naturally occuring half steps
like i said before halfsteps naturally occure between E and F, and B and C
and for a major scale the halfsteps are between the 3rd and 4th, and the 7th and 1st(or 8th, i call them a first because its an octave above, and is the same tone as the first note)
so it would look like this:
1 2 3^4 5 6 7^1
C is the natural major scale, so when you see something in C major it will have nothing, no flats or sharps in its key signature, which is located before the first measure
It matches up like this:
1 2 3^4 5 6 7^1
C D E^F G A B^C
notice the e and half, and b and c halfsteps match up
but however what if we did this, lets take D major for example, which has two sharps, and try to match it up
so:
1 2 3^4 5 6 7^1
D E^F G A B^C D
they dont match, so you have to raise, or sharp some notes
so it becomes:
1 2 3 ^4 5 6 7 ^1
D E F# G A B C# D
thats a short summary of keys, google the circle of fifths, memorizing the circle of fifths can definitely help
however the stuff ive mentioned is really only for reading music, so if you just wanna play guitar, and not read music, you really dont have to know it, but it'd be nice
so to answer your question, you know what notes to use by what key you're in
a quick way, and a good exercise to figure it out, is say you're in A minor
run through all the octave shapes, and get familiar, here's what you'd get if you took an octave and ran it up and down a fourth, keep in mind the interval between G and B is different then the rest of the strings
E-------5---------
B-----5----------
G---4---2--------
D-4---2-------------
A---2------------
E-2--------------
Then there's the other slant to, and you can connect the octave shapes like this:
E-5---------------
B----10--10----------
G----------------
D-7--7--------------
A--------12-------
E-5---------------
thats just an idea of the different things you can run through to get familiar with octave shapes, theres a lot to it once you dig deep
if you want more info pm or something, im sure i can dig out some good sites/articles for you