[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
Before you make a thread asking for help, read this.
Post Reply
Aprilo
Prole
Posts: 1
Joined: Wed Apr 29, 2015 2:57 pm

[Linux]Getting any background value from the computer?

Post by Aprilo » Wed Apr 29, 2015 3:21 pm

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

User avatar
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?

Post by Nixola » Wed Apr 29, 2015 3:41 pm

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
lt = love.thread
li = love.image
lg = love.graphics

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

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

Post by I~=Spam » Wed Apr 29, 2015 5:16 pm

Long rant incoming. :P

<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

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

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

Post by konacake » Wed Apr 29, 2015 5:25 pm

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).

User avatar
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?

Post by Nixola » Wed Apr 29, 2015 5:28 pm

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

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

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

Post by I~=Spam » Wed Apr 29, 2015 5:57 pm

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

User avatar
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?

Post by s-ol » Wed Apr 29, 2015 7:00 pm

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

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

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

Post by I~=Spam » Wed Apr 29, 2015 7:32 pm

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

User avatar
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?

Post by s-ol » Thu Apr 30, 2015 11:50 am

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

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

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

Post by I~=Spam » Thu Apr 30, 2015 5:59 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests