Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; sigh, my code was perfect for what you wanted, if you set the directionFlag to 0 in my code then ...
-
08-12-2009, 04:42 AM #10171Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
sigh, my code was perfect for what you wanted, if you set the directionFlag to 0 in my code then it stops moving, to fade in and out pictures you would have to use transparency and set the alpha value, i suggest you use pge luaplayer
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
08-12-2009, 07:14 AM #10172QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
08-12-2009, 11:56 PM #10173
Achievements:
- Registriert seit
- Jul 2009
- Beiträge
- 26
- Points
- 1.768
- Level
- 24
- Downloads
- 0
- Uploads
- 0
en,,,i dont konw what you mean,could speak some easy English???Past any number for MType expect for 1-4.
even change the speed to 1 i think it is still too fast^_^Change the speed.
could we slow it a little more?
-
08-13-2009, 12:16 AM #10174Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
08-14-2009, 05:51 AM #10175
Achievements:
- Registriert seit
- Jul 2009
- Beiträge
- 26
- Points
- 1.768
- Level
- 24
- Downloads
- 0
- Uploads
- 0
get clear of it...
another problem appears
the lua skipped the command " Message("嘿~跑得了和尚跑不了庙,你们能往 哪里逃?","LiXiaoYao","001"," 李逍遥",false)"
the following is the code of "message":Code:--┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑ --│Windows XP For PSP │ --│制作人:胡鹏伟 │ --│联系我:QQ:315362463 E—mail:[email protected] │ --┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━┙ --########################################################### --■ 0000002.lua ------------------------------------------------------------- -- 本部分主要用于储存地图0000002的内容。(罗刹洞口) --########################################################### --背景图片 MapBack = Image.load("Pictures/Maps/0000002/Stage0000002.png") --背景音乐 --可行动区域 --事件位置与内容 event={} event[1]={x=1,y=1,runtype=true,move=false} event[2]={x=1,y=1,runtype=false,move=false} event[3]={x=1,y=1,runtype=false,move=false} event[4]={x=1,y=1,runtype=false,move=false} function Event(num) if num == 1 then img1 = Image.load("Pictures/Maps/0000002/Event1.png") x=480 y = 270 while y>130 do screen:blit(0,0,MapBack) screen:blit(x,y,img1) x=x-2 y=y-1 screen.flip() screen.waitVblankStart() end Message("嘿~跑得了和尚跑不了庙,你们能往哪里逃?","LiXiaoYao","001","李逍遥",false) screen:clear() screen:blit(0,0,MapBack) screen:blit(x,y,img1) while y>100 do screen:blit(0,0,MapBack) screen:blit(x,y,img1) x=x-2 y=y-1 screen.flip() screen.waitVblankStart() end end end
Code:--┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑ --│Windows XP For PSP │ --│制作人:胡鹏伟 │ --│联系我:QQ:315362463 E—mail:[email protected] │ --┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━┙ --########################################################### --■ Function_Message ------------------------------------------------------------- -- 本部分主要用于显示对话框。 --########################################################### function Message(text,person,number,name,l_side) SaveScreen(0,0,480,272,scr) Mback=Image.load("Pictures/System/Message.png") Mperson=Image.load("Pictures/Heads/"..person.."/"..number..".png") Mname=Image.load("Pictures/System/ShowName.png") --定位图片,定位 local mx =1 local my =1 local sx =1 local sy =1 if l_side==1 then mx=0 my=152 sx=97 sy=210 nx=97 else mx=480-Mperson:width() my=152 sx=10 sy=210 nx=264 end --处理文字信息 local lines={} lines[1]=string.sub(text,1,46) lines[2]=string.sub(text,47,92) lines[3]=string.sub(text,93,138) while true do if pad:circle() then break end screen:clear() screen:blit(0,0,scr) screen:blit(0,192,Mback) screen:blit(mx,my,Mperson) screen:blit(nx,160,Mname) GbkPrint(nx+30,168,name,yellow) GbkPrint(sx,sy,lines[1],white) GbkPrint(sx,sy+16,lines[2],white) GbkPrint(sx,sy+32,lines[3],white) screen.flip() screen.waitVblankStart() end end function SaveScreen(left,top,width,height,scr) scr = scr or screen if scr ~= screen then tmp_canvas = Image.createEmpty(width,height) tmp_canvas:blit(0,0,scr,left,top,width,height) else screen.flip() tmp_canvas = Image.createEmpty(width,height) tmp_canvas:blit(0,0,scr,left,top,width,height) screen.flip() end end
-
08-14-2009, 06:29 AM #10176
Achievements:
- Registriert seit
- Jul 2009
- Beiträge
- 26
- Points
- 1.768
- Level
- 24
- Downloads
- 0
- Uploads
- 0
figured it out myself
-
08-15-2009, 07:24 PM #10177
Achievements:
- Registriert seit
- Jul 2009
- Beiträge
- 26
- Points
- 1.768
- Level
- 24
- Downloads
- 0
- Uploads
- 0
a question :
i konw that if i input
then when i want to use the data 25,i could simply inputCode:h={} h[x]={y=125,z=25}
but what should i do to get the value of x if i know that"y=125,z=25" ??Code:a=h[x][z]
-
08-15-2009, 08:41 PM #10178
I don't think I understand your question. Could you please rephrase that?
-
08-15-2009, 10:48 PM #10179
Achievements:
- Registriert seit
- Jul 2009
- Beiträge
- 26
- Points
- 1.768
- Level
- 24
- Downloads
- 0
- Uploads
- 0
i want a function that can output a number x,which makes h[x].y=125,h[x].z=25.
-
08-16-2009, 12:19 AM #10180QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
It sounds like you're doing something retarded, but hey.
Code:function youFail(t) for k, v in ipairs(t) do if v.y == 125 and v.z == 25 then return k end end end
-
08-16-2009, 03:04 AM #10181Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
08-16-2009, 05:11 PM #10182
Achievements:
- Registriert seit
- Jul 2009
- Beiträge
- 26
- Points
- 1.768
- Level
- 24
- Downloads
- 0
- Uploads
- 0
writing codes is a really confusing thing......
problem happened again!
When i used the comand"ShowStage(4,12,9)" ,i get an message:
can't compare nil with a number
i don`t know why.
i put the following between "local dxmax=MapBack:width()/16
local dymax=MapBack:height()/16" and" if dx<dxmax+1 and dx>0 then
if dy<dymax+1 and dy>0 then".To my surprise ,dx and dy is nil???
writing codes is a really confusing thing......
the following is the codes for ShowStage(direction,px,py )Code:while true do screen:clear() GbkPrint(0,0,Moveable[9][11],white) GbkPrint(0,16,dx..dy,white) GbkPrint(0,32,px..py,white) screen.flip() screen.waitVblankStart() end
Code:function JudgeMove(direction,px,py) if dircetion==4 then dx=px-1 dy=py end if direction==6 then dx=px+1 dy=py end if direction==8 then dx=px dy=py-1 end if direction==2 then dx=px dy=py+1 end local dxmax=MapBack:width()/16 local dymax=MapBack:height()/16 --出界判定 if dx<dxmax+1 and dx>0 then if dy<dymax+1 and dy>0 then --不可行动区域判定 if Moveable[dy][dx]==1 then --事件阻挡判定 if MapEvent[dx][dy]~=1 then return true end end end end end
-
08-17-2009, 01:22 AM #10183QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Your error is caused by this line. It should be really obvious why if you look carefully and consider the possible reasons for a variable to be nil.Code:if dircetion==4 then
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
08-24-2009, 05:59 PM #10184Lua Coder

- Registriert seit
- Jan 2008
- Ort
- Iowa
- Beiträge
- 834
- Points
- 18.915
- Level
- 87
- My Mood
-
- Downloads
- 2
- Uploads
- 0
can i put a table with in a table? ie
image = {
x = 10,
y = 20,
buffer = {x = 2, y = 3},
}...
-
08-24-2009, 09:58 PM #10185QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Why don't you try?
Lua code - 9 lines - codepad
-
08-31-2009, 07:00 PM #10186Lua Coder

- Registriert seit
- Jan 2008
- Ort
- Iowa
- Beiträge
- 834
- Points
- 18.915
- Level
- 87
- My Mood
-
- Downloads
- 2
- Uploads
- 0
3d in luaplayer
im trying to figure out how the 3d functions in lua player work, so i modifyed the cube demo:
i want to make a line of cubes so i have the for i=0,3 do thing. I want it so whatever i is you add/subtract it to the x of the cube:Code:System.usbDiskModeActivate() -- Colors red = Color.new(255, 0, 0) orange = Color.new(255, 140, 0) yellow= Color.new(255, 255, 0) green = Color.new(0, 255, 0) blue = Color.new(0, 0, 255) blue2 = Color.new(30, 144, 255) blue3 = Color.new(16, 78, 139) blue4 = Color.new(25, 25, 112) purple = Color.new(153, 50, 204) pink = Color.new(255, 110, 199) black = Color.new(0, 0, 0) brown = Color.new(107, 66, 38) white = Color.new(255, 255, 255) grey = Color.new(84, 84, 84) light_grey = Color.new(211, 211, 211) silver = Color.new(230, 232, 250) -- Move Values movX = 0 movY = 0 movZ = -10 extra = 0 -- Rotate Values rotX = 0 rotY = 0 rotZ = 0 -- Loads Seamless Image To Tile On Cube logo = Image.createEmpty(64, 64) logo:clear(silver) logo:print(5, 8, "Lua", black) logo:print(10, 17, "3D", black) require("System\\analog") require("System\\cube") while true do pad = Controls.read() screen:clear(white) analogSet(1,1) Gu.start3d() -- clear screen Gu.clearDepth(0); Gu.clear(Gu.COLOR_BUFFER_BIT|Gu.DEPTH_BUFFER_BIT) -- setup projection and view matrices Gum.matrixMode(Gu.PROJECTION) Gum.loadIdentity() -- perspective length, ratio(15/8.5 is psp screen), how close to screen you can get to object before break point Gum.perspective(25, 15/8.5, .5, 10000) Gum.matrixMode(Gu.VIEW) Gum.loadIdentity() -- setup texture Gu.enable(Gu.BLEND) Gu.enable(Gu.TEXTURE_2D); Gu.texImage(logo) -- Colors/Textures Object Gu.texFunc(Gu.TFX_MODULATE, Gu.TCC_RGBA) -- Makes Smooth Gu.texEnvColor(white) Gu.texFilter(Gu.LINEAR, Gu.LINEAR) -- Scale of Texture, large number small texture is, slower fps Gu.texScale(.25, .25) -- setup matrix for cube Gum.matrixMode(Gu.MODEL) Gum.loadIdentity() Gum.translate(movX, movY, movZ) Gum.rotateXYZ(rotX, rotY, rotZ) -- draw cube Gum.drawArray(Gu.TRIANGLES, Gu.TEXTURE_32BITF|Gu.COLOR_8888|Gu.VERTEX_32BITF|Gu.TRANSFORM_3D, cube[0]) Gu.end3d() if pad:start() then break end screen.waitVblankStart() screen.flip() end
there is no error code, is there anything that i am doing wrongCode:for i=0,3 do cube[i] = { -- Each 3 part section create a triagnle -- unknown,unknown, color, x, y, z {0, 0, red, -1+i, -1, 1}, -- 0 {2, 0, red, -1+i, 1, 1}, -- 4 {2, 2, red, 1+i, 1, 1}, -- 5 {0, 0, red, -1+i, -1, 1}, -- 0 {2, 2, red, 1+i, 1, 1}, -- 5 {0, 2, red, 1+i, -1, 1}, -- 1 {0, 0, orange, -1+i, -1, -1}, -- 3 {2, 0, orange, 1+i, -1, -1}, -- 2 {2, 2, orange, 1+i, 1, -1}, -- 6 {0, 0, orange, -1+i, -1, -1}, -- 3 {2, 2, orange, 1+i, 1, -1}, -- 6 {0, 2, orange, -1+i, 1, -1}, -- 7 {0, 0, yellow, 1+i, -1, -1}, -- 0 {2, 0, yellow, 1+i, -1, 1}, -- 3 {2, 2, yellow, 1+i, 1, 1}, -- 7 {0, 0, yellow, 1+i, -1, -1}, -- 0 {2, 2, yellow, 1+i, 1, 1}, -- 7 {0, 2, yellow, 1+i, 1, -1}, -- 4 {0, 0, green, -1+i, -1, -1}, -- 0 {2, 0, green, -1+i, 1, -1}, -- 3 {2, 2, green, -1+i, 1, 1}, -- 7 {0, 0, green, -1+i, -1, -1}, -- 0 {2, 2, green, -1+i, 1, 1}, -- 7 {0, 2, green, -1+i, -1, 1}, -- 4 {0, 0, blue, -1+i, 1, -1}, -- 0 {2, 0, blue, 1+i, 1, -1}, -- 1 {2, 2, blue, 1+i, 1, 1}, -- 2 {0, 0, blue, -1+i, 1, -1}, -- 0 {2, 2, blue, 1+i, 1, 1}, -- 2 {0, 2, blue, -1+i, 1, 1}, -- 3 {0, 0, purple, -1+i, -1, -1}, -- 4 {2, 0, purple, -1+i, -1, 1}, -- 7 {2, 2, purple, 1+i, -1, 1}, -- 6 {0, 0, purple, -1+i, -1, -1}, -- 4 {2, 2, purple, 1+i, -1, 1}, -- 6 {0, 2, purple, 1+i, -1, -1}, -- 5 } end...
-
08-31-2009, 07:08 PM #10187Lua Coder

- Registriert seit
- Jan 2008
- Ort
- Iowa
- Beiträge
- 834
- Points
- 18.915
- Level
- 87
- My Mood
-
- Downloads
- 2
- Uploads
- 0
what i meam by no error code is that all i get is
Code:Error: No script file found press start to restart
...
-
09-08-2009, 02:19 AM #10188QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
09-20-2009, 09:47 AM #10189QJ Gamer Blue

Achievements:
- Registriert seit
- Sep 2009
- Ort
- Some where
- Beiträge
- 61
- Points
- 1.900
- Level
- 25
- Downloads
- 1
- Uploads
- 1
Hey guys, I need some help..
i need to figure out how to download files from a URL Using lua Player, Is there any function of that sort in LuaPlayer?
-Manaxed
-
09-20-2009, 10:21 AM #10190Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
which version by which author?
PGE has a pge.net.getfile() function------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
09-21-2009, 04:09 PM #10191QJ Gamer Blue

Achievements:
- Registriert seit
- Sep 2009
- Ort
- Some where
- Beiträge
- 61
- Points
- 1.900
- Level
- 25
- Downloads
- 1
- Uploads
- 1
Hey guys what's wrong with this code?
myfile = pge.file.open(”info.txt”, PGE_FILE_RDONLY)
i get error message unexpected symbol near 'Ö'.
The rest of my program is...
Spoiler for OPEN:
-Manaxed.Enter Signature Here.
-
09-21-2009, 10:54 PM #10192Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Try:
myfile = pge.file.open(”info.txt”, PGE_FILE_RDONLY+PGE_FILE_ CREATE)
-
09-22-2009, 01:40 AM #10193QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Probably something wrong with the speech marks. ” is not the same as ".
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
09-22-2009, 01:51 AM #10194QJ Gamer Blue

Achievements:
- Registriert seit
- Sep 2009
- Ort
- Some where
- Beiträge
- 61
- Points
- 1.900
- Level
- 25
- Downloads
- 1
- Uploads
- 1
na i got it to work had to retype but now im havin a hard time reading from a text file...
-manaxedEnter Signature Here.
-
10-17-2009, 09:55 AM #10195The German Guy

- Registriert seit
- Apr 2009
- Ort
- germany
- Beiträge
- 163
- Points
- 3.797
- Level
- 38
- My Mood
-
- Downloads
- 5
- Uploads
- 1
Can somebody tell me how to write something into a file by using SystemOSK?
I tried this:
but it does not write...Code:nickname = System.startOSK("","Enter your name") name = io.open("name.txt","w") name:write(nickname) name:close()
-
12-22-2009, 05:47 AM #10196QJ Gamer Blue
Achievements:
- Registriert seit
- Sep 2009
- Ort
- Mantis Coder Home.
- Beiträge
- 19
- Points
- 1.689
- Level
- 23
- Downloads
- 0
- Uploads
- 0
How do I copy a file then paste it in another directory?
-
12-22-2009, 07:26 AM #10197Lua Coder

- Registriert seit
- Jan 2008
- Ort
- Iowa
- Beiträge
- 834
- Points
- 18.915
- Level
- 87
- My Mood
-
- Downloads
- 2
- Uploads
- 0
try this, it "fakes" copying a file
Code:-- Sets locations of oringial file and place to copy it orignialFile = "ms0:/psp/common/file.txt" copyFile = "ms0:/psp/game/luaplayer/file.txt" -- Opens files to read and write file = io.open(oringinalFile,"r") copy = io.open(copyFile,"w") -- writes entire "oringinal file" to the new copy copy:write(file) -- Closes the files file:close() copy:close() -- removes the oringial file (optional) os.remove(orignialFile)
-
12-23-2009, 08:30 AM #10198QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- Czech Republic
- Beiträge
- 41
- Points
- 2.617
- Level
- 31
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Please help me...
here IS LINK:
I need a help ! (LUA code sample)
I really need this...its urgent for my next project
i need it until 25-12-2009
Plss,I donate 10-15 dollars for help..thanks ![CENTER][B][COLOR="DarkOrange"]PSP Slim/Lite (4.01M33)[/COLOR] | [COLOR="Sienna"]Asus Jupiter (WM 6.1) [/COLOR]| X[COLOR="DarkRed"]box1(EvoX+linux)[/COLOR] | [COLOR="Red"]Asus EEE 901[/COLOR][/B][/CENTER]
[B][CENTER]Sorry about my weak english[/CENTER][/B]
[CENTER][COLOR="SandyBrown"]PSP Developer from czech[/COLOR][/CENTER]
-
12-31-2009, 03:50 PM #10199
Achievements:
- Registriert seit
- Dec 2009
- Ort
- east brunswick
- Beiträge
- 7
- Points
- 1.369
- Level
- 20
- Downloads
- 0
- Uploads
- 0
I apologize for asking something nooby in advance. >_<
Alright, so i'm working on an rts, however, i have no idea how to make the cursor move.
I've been looking through some peoples code, and have not been able to find a way to get this done
This is what i have so far. (-.-), also, how would i go about making the cursor go faster the farther you push along the analog pad?
Code:if pge.controls.analogx() < -50 then end if pge.controls.analogx() > 50 then end if pge.controls.analogy() < -50 then end if pge.controls.analogy() > 50 then end
-
12-31-2009, 05:24 PM #10200QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been


LinkBack URL
About LinkBacks
Mit Zitat antworten
.

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum