This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
SuicidalSTDz's profile picture

[Project Idea]Matrix Code/Digital Rain

Started by SuicidalSTDz, 09 March 2013 - 11:09 AM
SuicidalSTDz #1
Posted 09 March 2013 - 12:09 PM
Is anyone up to the challenge (Not so much a challenge)? I would love to see this, as well as GravityScore most likely. Make it look like the real thing.
Pharap #2
Posted 09 March 2013 - 12:10 PM
Are we talking about Matrix: a film or Matrix: a mathematical concept commonly used in 3D render engines for vertex translations?
SuicidalSTDz #3
Posted 09 March 2013 - 12:30 PM
Are we talking about Matrix: a film or Matrix: a mathematical concept commonly used in 3D render engines for vertex translations?
Not the film; the Matrix Code scrolling continuously on an Advanced Computer.
Pharap #4
Posted 09 March 2013 - 12:57 PM
You mean the digital rain? http://en.wikipedia.org/wiki/Matrix_digital_rain
SuicidalSTDz #5
Posted 09 March 2013 - 01:03 PM
You mean the digital rain? http://en.wikipedia....ix_digital_rain
Precisely! Forgot what the buggart was called.
Pharap #6
Posted 09 March 2013 - 01:14 PM
Right, glad that clears that up, best edit the first post so as to not to confuse others lol
SuicidalSTDz #7
Posted 09 March 2013 - 01:17 PM
Right, glad that clears that up, best edit the first post so as to not to confuse others lol
I shall edit the main title
AnthonyD98™ #8
Posted 09 March 2013 - 01:20 PM
term.clear()
term.setCursorPos(1,1)
while true do
term.setTextColor(32)
print (math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999))
sleep(0.2)
end

Something a bit like this?
Pharap #9
Posted 09 March 2013 - 01:24 PM
term.clear()
term.setCursorPos(1,1)
while true do
term.setTextColor(32)
print (math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999))
sleep(0.2)
end

Something a bit like this?

A bit more advanced than that I should think.
If the aim is an effect like this: http://www.youtube.com/watch?v=DLyPvuSx7qA
SuicidalSTDz #10
Posted 09 March 2013 - 01:25 PM
term.clear()
term.setCursorPos(1,1)
while true do
term.setTextColor(32)
print (math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999), " ", math.random(1000000,9999999))
sleep(0.2)
end

Something a bit like this?

A bit more advanced than that I should think.
If the aim is an effect like this: [media]http://www.youtube.com/watch?v=DLyPvuSx7qA[/media]
That is the aim, yes. Needs to be colored; white for the last char in the line and green for the rest.
Pharap #11
Posted 09 March 2013 - 01:41 PM
That is the aim, yes. Needs to be colored; white for the last char in the line and green for the rest.

Could probably be done with a table of strings.
There would probably be a generate function to initialise the strings. For example get a random number between 1 and screen height, that will be the length of the string. Then assign to the string by looping that many times and each time appending the string with a string.char of a random number between 33 and 126 (all visible ascii characters). Normally you wouldn't concat strings in a loop, but that's not something to worry about for the moment. Then add that string to the main table.
Most of the logic would be done in the draw section.

It might be done better as a table of tables, really there would have to be some experimentation. Generally though you're going to want to be shifting data on a timer tick.
erronjason #12
Posted 09 March 2013 - 06:24 PM

local size={term.getSize()}
local tPixels={}
for x=1,size[1]-1 do
tPixels[x]={}
for y=1,size[2] do
tPixels[x][y]=' '
end
end
local function render()
term.clear()
term.setCursorPos(1,1)
for y=1,#tPixels[1] do
if y~=1 then
print('')
end
for x=1,#tPixels do
write(tPixels[x][y])
end
end
end
local function cycle()
for x=1,#tPixels do
for y=#tPixels[x],2,-1 do
tPixels[x][y]=(tPixels[x][y-1]==' ' and ' ') or ((tPixels[x][y]~=' ' and tPixels[x][y]) or string.char(math.random(32,126)))
end
--[[for x=1,#tPixels do
local intC=nil
for y=2,5 do
if tPixels[x][y]==' ' then
intC=true
end
end
if not intC then
tPixels[x][1]=' '
end
end]]
end
end
local function create()
tPixels[math.random(1,#tPixels)][1]=string.char(math.random(32,126))
tPixels[math.random(1,#tPixels)][1]=' '
tPixels[math.random(1,#tPixels)][1]=' '
end
local bRunning=true
while bRunning do
cycle()
create()
render()
	local timer=os.startTimer(.1)
while true do
local sEvent, param = os.pullEvent()
if (sEvent=='timer' and param==timer) then
break
end
end
end
SuicidalSTDz #13
Posted 09 March 2013 - 06:29 PM

local size={term.getSize()}
local tPixels={}
for x=1,size[1]-1 do
tPixels[x]={}
for y=1,size[2] do
tPixels[x][y]=' '
end
end
local function render()
term.clear()
term.setCursorPos(1,1)
for y=1,#tPixels[1] do
if y~=1 then
print('')
end
for x=1,#tPixels do
write(tPixels[x][y])
end
end
end
local function cycle()
for x=1,#tPixels do
for y=#tPixels[x],2,-1 do
tPixels[x][y]=(tPixels[x][y-1]==' ' and ' ') or ((tPixels[x][y]~=' ' and tPixels[x][y]) or string.char(math.random(32,126)))
end
--[[for x=1,#tPixels do
local intC=nil
for y=2,5 do
if tPixels[x][y]==' ' then
intC=true
end
end
if not intC then
tPixels[x][1]=' '
end
end]]
end
end
local function create()
tPixels[math.random(1,#tPixels)][1]=string.char(math.random(32,126))
tPixels[math.random(1,#tPixels)][1]=' '
tPixels[math.random(1,#tPixels)][1]=' '
end
local bRunning=true
while bRunning do
cycle()
create()
render()
	local timer=os.startTimer(.1)
while true do
local sEvent, param = os.pullEvent()
if (sEvent=='timer' and param==timer) then
break
end
end
end
Well, I guess the project is done… Bravo on completing this. ;)/>
Azhf #14
Posted 09 March 2013 - 06:41 PM

local size={term.getSize()}
local tPixels={}
for x=1,size[1]-1 do
tPixels[x]={}
for y=1,size[2] do
tPixels[x][y]=' '
end
end
local function render()
term.clear()
term.setCursorPos(1,1)
for y=1,#tPixels[1] do
if y~=1 then
print('')
end
for x=1,#tPixels do
write(tPixels[x][y])
end
end
end
local function cycle()
for x=1,#tPixels do
for y=#tPixels[x],2,-1 do
tPixels[x][y]=(tPixels[x][y-1]==' ' and ' ') or ((tPixels[x][y]~=' ' and tPixels[x][y]) or string.char(math.random(32,126)))
end
--[[for x=1,#tPixels do
local intC=nil
for y=2,5 do
if tPixels[x][y]==' ' then
intC=true
end
end
if not intC then
tPixels[x][1]=' '
end
end]]
end
end
local function create()
tPixels[math.random(1,#tPixels)][1]=string.char(math.random(32,126))
tPixels[math.random(1,#tPixels)][1]=' '
tPixels[math.random(1,#tPixels)][1]=' '
end
local bRunning=true
while bRunning do
cycle()
create()
render()
	local timer=os.startTimer(.1)
while true do
local sEvent, param = os.pullEvent()
if (sEvent=='timer' and param==timer) then
break
end
end
end
Pastebin pl0x?
SuicidalSTDz #15
Posted 10 March 2013 - 04:50 AM
Bam!
AnthonyD98™ #16
Posted 10 March 2013 - 10:54 AM
There is flickering in that code :(/>
tesla1889 #17
Posted 10 March 2013 - 10:59 AM
There is flickering in that code :(/>

its a pretty high-demand request, as every pixel needs to be redrawn every cycle, and Lua isn't a great graphics platform, so thats just how it is
AnthonyD98™ #18
Posted 10 March 2013 - 11:01 AM
There is flickering in that code :(/>

its a pretty high-demand request, as every pixel needs to be redrawn every cycle, and Lua isn't a great graphics platform, so thats just how it is

Yeah I know, Its pretty amazing that its in lua.
SuicidalSTDz #19
Posted 10 March 2013 - 11:06 AM
Like tesla said, Lua is not best for graphics. Hence why WoW looks.. Let me just stop right there ^_^/>
Pharap #20
Posted 10 March 2013 - 11:23 AM
It's not lua's fault, it's how the graphics are handled.
Not saying CC handled graphics badly, just saying that how graphics are handled is more important than the scripting language used.
SuicidalSTDz #21
Posted 10 March 2013 - 11:27 AM
It's not lua's fault, it's how the graphics are handled.
Not saying CC handled graphics badly, just saying that how graphics are handled is more important than the scripting language used.
True, Lua outside of CC is generally more "Graphic Freindly", however, there are other languages that handle graphics better. Not saying I don't like Lua ^_^/>
Pharap #22
Posted 10 March 2013 - 11:36 AM
True, Lua outside of CC is generally more "Graphic Freindly", however, there are other languages that handle graphics better. Not saying I don't like Lua ^_^/>

How do the other languages handle it 'better' and which languages?
SuicidalSTDz #23
Posted 10 March 2013 - 11:38 AM
On my phone so I can't go into much detail but anything really, C#, C++, etc
Pharap #24
Posted 10 March 2013 - 11:43 AM
On my phone so I can't go into much detail but anything really, C#, C++, etc
Those are compiled languages, not scripting languages.
Lua runs on a VM implemented in languages like C# and C++, meaning lua is constrained to the graphical functions passed to it/set up by the lower languages (like C# and C++).
SuicidalSTDz #25
Posted 10 March 2013 - 11:56 AM
On my phone so I can't go into much detail but anything really, C#, C++, etc
Those are compiled languages, not scripting languages.
Lua runs on a VM implemented in languages like C# and C++, meaning lua is constrained to the graphical functions passed to it/set up by the lower languages (like C# and C++).
I always keep forgeting Lua isn't compiled. I guess that makes Lua preferrably superior than the other scripting languages. FORTH is one of the worst (Possibly others that may be worse)
AfterLifeLochie #26
Posted 10 March 2013 - 12:00 PM
On my phone so I can't go into much detail but anything really, C#, C++, etc
Those are compiled languages, not scripting languages.
Lua runs on a VM implemented in languages like C# and C++, meaning lua is constrained to the graphical functions passed to it/set up by the lower languages (like C# and C++).
I always keep forgeting Lua isn't compiled. I guess that makes Lua preferrably superior than the other scripting languages. FORTH is one of the worst (Possibly others that may be worse)

Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.
SuicidalSTDz #27
Posted 10 March 2013 - 12:02 PM
On my phone so I can't go into much detail but anything really, C#, C++, etc
Those are compiled languages, not scripting languages.
Lua runs on a VM implemented in languages like C# and C++, meaning lua is constrained to the graphical functions passed to it/set up by the lower languages (like C# and C++).
I always keep forgeting Lua isn't compiled. I guess that makes Lua preferrably superior than the other scripting languages. FORTH is one of the worst (Possibly others that may be worse)

Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.
This is why I get confused so much. One person says one thing then another says another thing ^_^/> So, let's get this straight, Lua is a Compiled language, correct?
AfterLifeLochie #28
Posted 10 March 2013 - 12:04 PM
I always keep forgeting Lua isn't compiled. I guess that makes Lua preferrably superior than the other scripting languages. FORTH is one of the worst (Possibly others that may be worse)

Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.
This is why I get confused so much. One person says one thing then another says another thing ^_^/>/>/> So, let's get this straight, Lua is a Compiled language, correct?

Lua programs are not interpreted directly from the textual Lua file, but are compiled into bytecode which is then run on the Lua virtual machine. The compilation process is typically transparent to the user and is performed during run-time, but it can be done offline in order to increase loading performance or reduce the memory footprint of the host environment by leaving out the compiler.

Lua is compiled. :P/>
SuicidalSTDz #29
Posted 10 March 2013 - 12:15 PM
I always keep forgeting Lua isn't compiled. I guess that makes Lua preferrably superior than the other scripting languages. FORTH is one of the worst (Possibly others that may be worse)

Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.
This is why I get confused so much. One person says one thing then another says another thing ^_^/>/>/> So, let's get this straight, Lua is a Compiled language, correct?

Lua programs are not interpreted directly from the textual Lua file, but are compiled into bytecode which is then run on the Lua virtual machine. The compilation process is typically transparent to the user and is performed during run-time, but it can be done offline in order to increase loading performance or reduce the memory footprint of the host environment by leaving out the compiler.

Lua is compiled. :P/>
Well thank you for clearing that up ^_^/>
Pharap #30
Posted 10 March 2013 - 12:19 PM
Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.

Bytecode, but not machine code.
It still has to run on a VM.
The point being it doesn't have direct hardware access, it has to be given access to a rendering system by the system managing the VM.
The graphical code is entirely dependant on the implementing platform, therefore it's not lua that causes graphical manipulation to be easy or hard, it's the implementing platform.
AfterLifeLochie #31
Posted 10 March 2013 - 12:20 PM
Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.

Bytecode, but not machine code.
It still has to run on a VM.
The point being it doesn't have direct hardware access, it has to be given access to a rendering system by the system managing the VM.
The graphical code is entirely dependant on the implementing platform, therefore it's not lua that causes graphical manipulation to be easy or hard, it's the implementing platform.

Of course, that's not what I'm saying. What I'm saying is that Lua *is* a compiled language - as someone told SuicidalSTDz otherwise.
Shnupbups #32
Posted 10 March 2013 - 12:23 PM
I am SO going to make this one of the screensavers in my next version of CCScreensaver…
Pharap #33
Posted 10 March 2013 - 12:24 PM
Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.

Bytecode, but not machine code.
It still has to run on a VM.
The point being it doesn't have direct hardware access, it has to be given access to a rendering system by the system managing the VM.
The graphical code is entirely dependant on the implementing platform, therefore it's not lua that causes graphical manipulation to be easy or hard, it's the implementing platform.

Of course, that's not what I'm saying. What I'm saying is that Lua *is* a compiled language - as someone told SuicidalSTDz otherwise.

Ok then, let's put it this way, it's not low level, it's high level and must be implemented in a lower level language.
When the programmers I usually work with talk about compilation, it's almost always to machine code.
As new languages arise with their own rules and systems, the classification of language becomes ever more difficult.
SuicidalSTDz #34
Posted 10 March 2013 - 12:24 PM
I am SO going to make this one of the screensavers in my next version of CCScreensaver…
I was thinking about using it in EnderOS, however, it is WAY too demanding for my likings. Not much you can do about it though.

Demanding as in, it will eventually throw an error; too long without yielding which would be BAD for any OS.

As new languages arise with their own rules and systems
Time for a LOLCode reference B)/>/>
AfterLifeLochie #35
Posted 10 March 2013 - 12:54 PM
Lua is, in fact, a compiled language - at runtime, unlike Java, which is pre-compiled. Invoking string.dump yields a Lua bytecode "chunk" which is invoke-able using loadstring(chunk) later on.

Bytecode, but not machine code.
It still has to run on a VM.
The point being it doesn't have direct hardware access, it has to be given access to a rendering system by the system managing the VM.
The graphical code is entirely dependant on the implementing platform, therefore it's not lua that causes graphical manipulation to be easy or hard, it's the implementing platform.

Of course, that's not what I'm saying. What I'm saying is that Lua *is* a compiled language - as someone told SuicidalSTDz otherwise.

Ok then, let's put it this way, it's not low level, it's high level and must be implemented in a lower level language.
When the programmers I usually work with talk about compilation, it's almost always to machine code.
As new languages arise with their own rules and systems, the classification of language becomes ever more difficult.

It's always to machine code. Java uses the JVM and it's own bytecode, C#, VB.NET, J#, Lua, Perl, Python and a long list of others use their own internal VM and bytecode formats. Bytecode *is* machine code - it's just interpreted by a unique VM. All these VMs are reliant on a low level execution platform.

Lua is dynamically typed, so of course it's higher-level than bytecode. It still requires a VM because it's not pure ASM.
Kingdaro #36
Posted 10 March 2013 - 01:20 PM
Here's my overly complicated attempt. (advanced computers only)
SuicidalSTDz #37
Posted 10 March 2013 - 01:25 PM
I'll say. You should make it so the first character in the line is white ^_^/>
Pharap #38
Posted 10 March 2013 - 01:27 PM
Ok then, let's put it this way, it's not low level, it's high level and must be implemented in a lower level language.
When the programmers I usually work with talk about compilation, it's almost always to machine code.
As new languages arise with their own rules and systems, the classification of language becomes ever more difficult.

It's always to machine code. Java uses the JVM and it's own bytecode, C#, VB.NET, J#, Lua, Perl, Python and a long list of others use their own internal VM and bytecode formats. Bytecode *is* machine code - it's just interpreted by a unique VM. All these VMs are reliant on a low level execution platform.

Lua is dynamically typed, so of course it's higher-level than bytecode. It still requires a VM because it's not pure ASM.

The fact the LVM is running on the JVM means it's not direct to machine code.
With things like the JVM it's much closer to the hardware so it can go near enough straight to native machine code, but if you're running a VM on top of a VM its unlikely to convert straight to native machine code.


Now enough of all this, it's off topic.
The point at the heart is that it's not lua's fault, it's the system managing the VM that decides lua's access to graphics.
In the current context of a matrix digital rain system for the computercraft computers: the graphics are what matters.
SuicidalSTDz #39
Posted 10 March 2013 - 01:36 PM
Ok then, let's put it this way, it's not low level, it's high level and must be implemented in a lower level language.
When the programmers I usually work with talk about compilation, it's almost always to machine code.
As new languages arise with their own rules and systems, the classification of language becomes ever more difficult.

It's always to machine code. Java uses the JVM and it's own bytecode, C#, VB.NET, J#, Lua, Perl, Python and a long list of others use their own internal VM and bytecode formats. Bytecode *is* machine code - it's just interpreted by a unique VM. All these VMs are reliant on a low level execution platform.

Lua is dynamically typed, so of course it's higher-level than bytecode. It still requires a VM because it's not pure ASM.

The fact the LVM is running on the JVM means it's not direct to machine code.
With things like the JVM it's much closer to the hardware so it can go near enough straight to native machine code, but if you're running a VM on top of a VM its unlikely to convert straight to native machine code.


Now enough of all this, it's off topic.
The point at the heart is that it's not lua's fault, it's the system managing the VM that decides lua's access to graphics.
In the current context of a matrix digital rain system for the computercraft computers: the graphics are what matters.
I don't think it's off topic. -_-/> We are talking about digital rain and the matter arose of how it was "lagging". We then started a new discussion whilst still pertaining to the digital rain graphics. We talked a bit and now we are at the conclusion of our "sub discussion" still relating to the matter at hand. Now yes, it was not directly relevant to the main discussion, however, it was informational and I like that. If a new member joined and wanted to ask about something like this, he would type the matter into the search bar and voilà, it returns this thread thus preventing a new post in Ask A Pro. Sometimes being off-topic is a good thing (Sometimes because when I go off-topic, it doesn't end well for the most part <_</>)