## [Linux]Getting any background value from the computer?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Aprilo
Prole
Posts: 1
Joined: Wed Apr 29, 2015 2:57 pm

### [Linux]Getting any background value from the computer?

What function in lua allows to get specific value from the memory address?

Nixola
Inner party member
Posts: 1940
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

### Re: [Linux]Getting any background value from the computer?

I don't think there's a way to do that... What do you want to achieve exactly? Why do you need such a possibly generic value?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
li = love.image
lg = love.graphics

I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

### Re: [Linux]Getting any background value from the computer?

Long rant incoming.

<rant length="long">

Yeah you should never need that... but if you REALLY need it... you could make a c library. I think you are trying to access a value across separately run binaries/applications. If this is what you are trying to do it will never work. The x86 and x86_64 processors are built so that this isn't really possible. (The OS can do some cool stuff to make it work anyway though like windows did to allow 16bit programs to run even in windows vista.)

But keep in mind that a pointer in one application NOT pointing to the same value in another application. This is intentional in Linux. For every single memory call Linux internally redirects the processor to where the memory actually is. So the pointer 0x12345678 doesn't actually point to that location. The location that this pointer will point to it unique to the application running and will actually represent memory somewhere else (such as at 0x87654321).

In a nutshell, applications are sandboxed. This is for a good reason because now it is theoretically possible to make an OS that cannot crash. (that doesn't happen in practice though of course) Now a misbehaving application doesn't cause a blue screen of death (or a kernel panic).

Lastly, even if it is possible. It is a REALLY, REALLY, REALLY bad idea. There are solid standards for sharing memory between applications that have been around for a long time now.

</rant>
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610

konacake
Prole
Posts: 11
Joined: Mon Mar 03, 2014 4:35 am

### Re: [Linux]Getting any background value from the computer?

I'm assuming he's asking for an environment variable, since getting a memory address would be the most useless thing in the world. For that you'd want to learn about os.execute and shell scripting (probably BASH).

Nixola
Inner party member
Posts: 1940
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

### Re: [Linux]Getting any background value from the computer?

You can get an environment variable using os.getenv I think
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
li = love.image
lg = love.graphics

I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

### Re: [Linux]Getting any background value from the computer?

That might be it but he is asking "value from the memory address"... I am not sure how that is an environment variable...
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610

s-ol
Party member
Posts: 1076
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

### Re: [Linux]Getting any background value from the computer?

I~=Spam wrote:That might be it but he is asking "value from the memory address"... I am not sure how that is an environment variable...
Environment variables are stored in a specific memory position, in C getenv (?) returns a pointer. I'd guess he thinks it's the same in Lua.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
baby:hurt(me)
end

I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

### Re: [Linux]Getting any background value from the computer?

S0lll0s wrote:
I~=Spam wrote:That might be it but he is asking "value from the memory address"... I am not sure how that is an environment variable...
Environment variables are stored in a specific memory position, in C getenv (?) returns a pointer. I'd guess he thinks it's the same in Lua.
Yes the variables must be stored somewhere... and strings are arrays of characters which is accessed by a pointer. In lua strings are not pointers because the interface is abstracted away. If he wanted the string I think he would have asked for a string not a value at an address. Why would he ask for the value at an address unless he already had an address in mind? No lua function returns a raw address. So he must have been trying to do something he shouldn't.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610

s-ol
Party member
Posts: 1076
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

### Re: [Linux]Getting any background value from the computer?

I~=Spam wrote:
S0lll0s wrote:
I~=Spam wrote:That might be it but he is asking "value from the memory address"... I am not sure how that is an environment variable...
Environment variables are stored in a specific memory position, in C getenv (?) returns a pointer. I'd guess he thinks it's the same in Lua.
Yes the variables must be stored somewhere... and strings are arrays of characters which is accessed by a pointer. In lua strings are not pointers because the interface is abstracted away. If he wanted the string I think he would have asked for a string not a value at an address. Why would he ask for the value at an address unless he already had an address in mind? No lua function returns a raw address. So he must have been trying to do something he shouldn't.
We both know all that, but I'm guessing he barely knows Lua, heard specifically about pointers with getenv and doesn't know how to translate that into Lua, which I bet he is also relatively new too.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
baby:hurt(me)
end

I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

### Re: [Linux]Getting any background value from the computer?

S0lll0s wrote:We both know all that, but I'm guessing he barely knows Lua, heard specifically about pointers with getenv and doesn't know how to translate that into Lua, which I bet he is also relatively new too.
Maybe.... It would be nice if he posted and clarified.... :\
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610

### Who is online

Users browsing this forum: No registered users and 5 guests