| View previous topic :: View next topic |
| Author |
Message |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Thu Jun 15, 2006 11:06 am Post subject: LUA Version/ Platform Information |
|
|
Hi Folks,
I am coding using windows Lua Player. I want to display battery/memory information. The following works on my PSP but not on windows:
| Code: | screen:print (10,10,"battery: " .. System.powerGetBatteryLifePercent(),Color.new(255,255,255))
screen:print (10,30,"Free Mem: " .. System.getFreeMemory(),Color.new(255,255,255))
screen.flip()
screen.waitVblankStart()
pad = Controls.read()
while not pad:start() do
pad = Controls.read()
end |
When I run this with the windows Lua player I get the following error:
error: sysinfo.lua:4: attempt to call field `getFreeMemory' (a nil value)
So it looks like the getFreeMemory function is not support under windows. Fair enough I don't really need it supported under windows. That said I would like to be able to run this code under windows. Is it possible to tell what version/platform the lua player is so I could do something like
| Code: |
if System.Platform() == "windows" then
FreeMem = 0
else
FreeMem = System.getFreeMemory()
end
screen:print (10,30,"Free Mem: " .. FreeMem ,Color.new(255,255,255)) |
Thanks,
JC |
|
| Back to top |
|
 |
Altair
Joined: 20 May 2006 Posts: 76 Location: The Netherlands
|
Posted: Thu Jun 15, 2006 11:25 am Post subject: |
|
|
| I dont know if you can check what platform its on, but I know "_VERSION" holds the interpreters version. You could check it anyways to make sure :) |
|
| Back to top |
|
 |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Mon Jun 19, 2006 10:39 am Post subject: |
|
|
_VERSION returns LUA 5.0.2 on both windows and PSP.
Another thought I had was maybe I could suppress the error message, is that possible ? |
|
| Back to top |
|
 |
romero126
Joined: 24 Dec 2005 Posts: 200
|
Posted: Mon Jun 19, 2006 12:25 pm Post subject: |
|
|
perhaps since LUA checks for commands first
Check if they exist! as variables
if (System.powerGetBatteryLifePercent) then
do it here!
end |
|
| Back to top |
|
 |
be2003
Joined: 20 Apr 2006 Posts: 144
|
Posted: Mon Jun 19, 2006 2:38 pm Post subject: |
|
|
or change it up a bit, make a quick check at the beginning of the app to see what os it is on
currentos = ""
if System.powerGetBatteryLifePercent() then
currentos = "psp"
else
currentos = "pc"
end
and use the current os in all processes
function getPercent()
if currentos == "psp" then
return System.getBatteryLifePercent()
else
return "100"
end
end _________________ - be2003
blog |
|
| Back to top |
|
 |
JC
Joined: 02 Jun 2006 Posts: 16
|
Posted: Fri Jun 23, 2006 3:31 pm Post subject: |
|
|
Thanks guys,
Both your suggestions will enable me to acheive what I want. |
|
| Back to top |
|
 |
|