Posted 21 September 2012 - 02:43 PM
Currently working on a Modular Lightup TV that has realtime frame editing and eventually colour screen suipport … BUT!
I have already "finished" it but wish to improve as much as possible before i am satisfied.
NOTE : I am using an idea based on binary to define what pixels lights up in the frames.
EGs :
The pixels are actual computers with lightblocks attached to the front, when they recieve a broadcasted message containing the BINARY it will look at the nth digit thats equal to its pixel number.
IE if the computer is pixel 3 it will look at the 3rd digit, if 0 its off / if 1 its on.
to set frames and pixels i currently use :
px = 0
FRAME = {px}
FRAME[px] = "001"
print(FRAME[0])
–
in here the px stands for the frame number, set as 0 in EG
next FRAME[0] is set as "001"
this way if FRAME[0] is broadcasted then the computers posing as pixels will recieve "001"
–
BUT!
My problem is to edit that string("001") if a player decides to change the last digit to 0 using the string.gsub() won't work afaik since I can not provide it what nth character to replace.
Perhaps if there was a way to do it like so :
string.gsubN(string,with[,i][,,j]) – not sure if thats how layout would look…
where :
string | is the input string (in my case its "001")
with | is the repalce with (in my case its "0")
i | is the from indicator (in my case its 3 as its 3 characters forward | or -1 as its 1 character from the back)
j | is the end-to indicator (n my case its 3 as we want only 3 to change | or -1 as we just need the last character to change")
in full my case would be :
string.gsubN("001" , "0", 3, 3)
OR
string.gsubN("001" , "0", -1, -1)
—–
IF the code im using is required for more detail or help ill provide it, although its pretty messy and i have not used tabs or spaces yet.
I have already "finished" it but wish to improve as much as possible before i am satisfied.
NOTE : I am using an idea based on binary to define what pixels lights up in the frames.
EGs :
The pixels are actual computers with lightblocks attached to the front, when they recieve a broadcasted message containing the BINARY it will look at the nth digit thats equal to its pixel number.
IE if the computer is pixel 3 it will look at the 3rd digit, if 0 its off / if 1 its on.
to set frames and pixels i currently use :
px = 0
FRAME = {px}
FRAME[px] = "001"
print(FRAME[0])
–
in here the px stands for the frame number, set as 0 in EG
next FRAME[0] is set as "001"
this way if FRAME[0] is broadcasted then the computers posing as pixels will recieve "001"
–
BUT!
My problem is to edit that string("001") if a player decides to change the last digit to 0 using the string.gsub() won't work afaik since I can not provide it what nth character to replace.
Perhaps if there was a way to do it like so :
string.gsubN(string,with[,i][,,j]) – not sure if thats how layout would look…
where :
string | is the input string (in my case its "001")
with | is the repalce with (in my case its "0")
i | is the from indicator (in my case its 3 as its 3 characters forward | or -1 as its 1 character from the back)
j | is the end-to indicator (n my case its 3 as we want only 3 to change | or -1 as we just need the last character to change")
in full my case would be :
string.gsubN("001" , "0", 3, 3)
OR
string.gsubN("001" , "0", -1, -1)
—–
IF the code im using is required for more detail or help ill provide it, although its pretty messy and i have not used tabs or spaces yet.