jumping to an offset..

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
xmOD
Posts: 10
Joined: Sat Apr 29, 2006 12:11 am
Contact:

jumping to an offset..

Post by xmOD »

Hey,

i am new to LUA and dont know much indepth about it..

My question is.. Say for example i have a file containing many lines of text/code... Now what i want to do is when i press the button 'x' then the screen should show the text which is on the offset 0x0002DE0 , how can i do this?

this is the kind of code i am using at the moment..

Code: Select all

somecolor = Color.new(0, 150, 150)

while true do
screen:clear()

y = 10
file = io.open("Filename.txt","r")
for line in file:lines() do
y = y + 10
screen:print(100,y,line,somecolor)
end

pad = Controls.read()
if pad:cross() then
<insert the jump code here>
end

if pad&#58;triangle&#40;&#41; then
Break
end

screen.waitVblankStart&#40;&#41;
screen.flip&#40;&#41;
end
Roland35007
Posts: 7
Joined: Sun Jan 07, 2007 11:54 pm

Offset

Post by Roland35007 »

What you are trying to do sounds like walking through a file in Binary Random mode. Perhaps when you open a file, you should use the binary switch (b)
like

file = io.open("Filename.txt","rb")

According to the lua 5 manual you should be able to jump to your offset with the instruction file:seek

Good luck!
Post Reply