forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LUA Version/ Platform Information

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
JC



Joined: 02 Jun 2006
Posts: 16

PostPosted: Thu Jun 15, 2006 11:06 am    Post subject: LUA Version/ Platform Information Reply with quote

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
View user's profile Send private message
Altair



Joined: 20 May 2006
Posts: 76
Location: The Netherlands

PostPosted: Thu Jun 15, 2006 11:25 am    Post subject: Reply with quote

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
View user's profile Send private message
JC



Joined: 02 Jun 2006
Posts: 16

PostPosted: Mon Jun 19, 2006 10:39 am    Post subject: Reply with quote

_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
View user's profile Send private message
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Mon Jun 19, 2006 12:25 pm    Post subject: Reply with quote

perhaps since LUA checks for commands first

Check if they exist! as variables

if (System.powerGetBatteryLifePercent) then
do it here!

end
Back to top
View user's profile Send private message
be2003



Joined: 20 Apr 2006
Posts: 144

PostPosted: Mon Jun 19, 2006 2:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
JC



Joined: 02 Jun 2006
Posts: 16

PostPosted: Fri Jun 23, 2006 3:31 pm    Post subject: Reply with quote

Thanks guys,

Both your suggestions will enable me to acheive what I want.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group