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; There's no need for they othe set of curly brackets. Theres millions of reasons why you game freezes. Post your ...
-
07-20-2009, 07:35 PM #10111Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
There's no need for they othe set of curly brackets. Theres millions of reasons why you game freezes. Post your code.
-
07-21-2009, 03:12 AM #10112QJ Gamer Bronze

- Registriert seit
- Dec 2007
- Ort
- B.F.
- Beiträge
- 328
- Points
- 7.257
- Level
- 56
- My Mood
-
- Downloads
- 1
- Uploads
- 0
PGE & LuaPlayer & LPHM are all API, they basically interpretes Lua.
Lua is a programming language.And tables are structures that occurs in many programming languages,Lua included.
The way you define and use tables is the same in PGE or LPHM or LuaPlayer or LuaPlayerEuphoria.
Just notice one thing, you put a table in another one.
Then if you want to acces to the player one X coordinate, for instance, you'll have to call it like this:Code:local player1={ {item1} }
Maybe, if you have to deal with manu players, you should have set your structure this way:Code:player1[1][1] or player1[1].x
And as Dan said, there are many reasons for what your game may freeze, just show what you did.Code:player={ {x, y, etc --these are the first player args} {x,y,etc --these are the second player args} {etc} ---- }00:00: Windows is loading...Come back tomorrow.
01:00 : Booting done.Not yet errors encountered...
01:10: Fatal error.Windows has been detected on logical drive
01:22: Keyboard Locked, try everything.
01:42 : Mouse Device Pilot not found, or uninstalled.Press Left-Bouton to continue.
01:50 : Ending User session.Do you want to play another game ?
01:59: Not enough memory.Only 508'312'583 bytes available.
02:00 : System is shutting Down.
-
07-21-2009, 08:49 AM #10113QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 96
- Points
- 3.008
- Level
- 33
- Downloads
- 0
- Uploads
- 0
-
07-21-2009, 08:38 PM #10114Lua Coder

- Registriert seit
- Jan 2008
- Ort
- Iowa
- Beiträge
- 834
- Points
- 18.915
- Level
- 87
- My Mood
-
- Downloads
- 2
- Uploads
- 0
is there any way to tuncate in lua, i have a y corrdiants that say like 39.940170, is there any way to only print the 39.94?
...
-
07-22-2009, 12:37 AM #10115QJ Gamer Bronze

- Registriert seit
- Dec 2007
- Ort
- B.F.
- Beiträge
- 328
- Points
- 7.257
- Level
- 56
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Yes there is.
You can use string.format() func.Just have a look here for more details about this func.
Basically, you can write somthing like this.
why not making a simple func that return you a truncated number with a custom number of decimals...Code:myNumber=39.940170 truncatedNumber=string.format("%.2f",myNumber) --this will return myNumber, truncated with two decimals.
Code:function float(arg,value) return string.format("%."..arg.."f",value) end00:00: Windows is loading...Come back tomorrow.
01:00 : Booting done.Not yet errors encountered...
01:10: Fatal error.Windows has been detected on logical drive
01:22: Keyboard Locked, try everything.
01:42 : Mouse Device Pilot not found, or uninstalled.Press Left-Bouton to continue.
01:50 : Ending User session.Do you want to play another game ?
01:59: Not enough memory.Only 508'312'583 bytes available.
02:00 : System is shutting Down.
-
07-22-2009, 05:28 AM #10116QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Since that's pointless, and dirty with such an ambiguous name.why not making a simple func that return you a truncated number with a custom number of decimals...
The whole point of string formatting is so that the user does not have to deal with a large set of functions.
And besides, the only time string formatting is especially useful when outputting data, not exactly a common operation.
-
07-22-2009, 05:29 AM #10117Lua Coder

- Registriert seit
- Jan 2008
- Ort
- Iowa
- Beiträge
- 834
- Points
- 18.915
- Level
- 87
- My Mood
-
- Downloads
- 2
- Uploads
- 0
thankyou very much now i understand how to make my own functions, nielkie this is for an output so i can see where to hittest on clicks, and i may use this for a timer too
Geändert von cmbeke (07-22-2009 um 06:29 AM Uhr)
...
-
07-23-2009, 11:27 AM #10118Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
The point of a function is to remove the need for repetition and/or accept a few arguments to return 1 or maybe 2 results / carry out a calculation on some data.
A function is not needed if for example you wanted to print some text to 10, 10 then it would be pointless to code a function for that as the origional code would be 1 line, using a function for it would create the function 3 lines if formatted correctly (1 possibly but dont be awkward) and the call to the function either way using a function for that makes more lines which is pointless.------ 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).
-
07-27-2009, 05:17 AM #10119
- Registriert seit
- Feb 2009
- Ort
- Duisburg, Germany
- Beiträge
- 20
- Points
- 2.089
- Level
- 27
- Downloads
- 0
- Uploads
- 0
I need some help
with these commands my program starts.Code:bgcredits = pge.texture.load("./credits.png") bgrules = pge.texture.load("./rules.png") bgwinr = pge.texture.load("./winr.png") bgdrawr = pge.texture.load("./drawr.png") bgloser = pge.texture.load("./loser.png") bgwinp = pge.texture.load("./winp.png") bgdrawp = pge.texture.load("./drawp.png") bglosep = pge.texture.load("./losep.png") bgwins = pge.texture.load("./wins.png") bgdraws = pge.texture.load("./draws.png") bgloses = pge.texture.load("./loses.png") bggame = pge.texture.load("./game.png") bgmenue = pge.texture.load("./menue.png") function credits() while pge.runnung() do pge.controls.update() pge.texture.activate(bgcredits) if pge.controls.pressed(PGE_CTRL_CIRCLE)then menue() end end end [...]
but when I start the program an error occures:
Error: SCRIPT.LUA:1: attempt to index global 'pge' ( a nil value)
-
07-27-2009, 07:22 AM #10120Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
are you using pge lua player ?
http://www.luaplayer.org/pge/downloads/pgelua_002.zip
also
Code:bgcredits = pge.texture.load("./credits.png") bgrules = pge.texture.load("./rules.png") bgwinr = pge.texture.load("./winr.png") bgdrawr = pge.texture.load("./drawr.png") bgloser = pge.texture.load("./loser.png") bgwinp = pge.texture.load("./winp.png") bgdrawp = pge.texture.load("./drawp.png") bglosep = pge.texture.load("./losep.png") bgwins = pge.texture.load("./wins.png") bgdraws = pge.texture.load("./draws.png") bgloses = pge.texture.load("./loses.png") bggame = pge.texture.load("./game.png") bgmenue = pge.texture.load("./menue.png") function credits() while pge.runnung() do pge.gfx.startdrawing() pge.gfx.clearscreen() pge.controls.update() bgcredits:activate() bgcredits:draweasy(0, 0) -- asuming 480 x 272 image if pge.controls.pressed(PGE_CTRL_CIRCLE)then menue() end pge.gfx.enddrawing() pge.gfx.swapbuffers() end endGeändert von FaT3oYCG (07-27-2009 um 07:34 AM Uhr)
------ 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).
-
07-27-2009, 08:46 AM #10121
- Registriert seit
- Feb 2009
- Ort
- Duisburg, Germany
- Beiträge
- 20
- Points
- 2.089
- Level
- 27
- Downloads
- 0
- Uploads
- 0
ok, thanks.. works for now
Edit:
now I have another problem:
I want the function to create a random number (1, 2 or 3) when it starts and if the button and the number match the next function should be start. But I can just push Cross and Triangle and the functions winp() and wins() are launched.Code:function game() while pge.running() do random = pge.math.randint(1,3) pge.gfx.startdrawing() pge.gfx.clearscreen() pge.controls.update() bggame:activate() bggame:draweasy(0, 0) if pge.controls.pressed(PGE_CTRL_SQUARE) and (random==3)then winr() end if pge.controls.pressed(PGE_CTRL_SQUARE) and (random==1)then drawr() end if pge.controls.pressed(PGE_CTRL_SQUARE) and (random==2)then loser() end if pge.controls.pressed(PGE_CTRL_CROSS) and (random==1)then winp() end if pge.controls.pressed(PGE_CTRL_CROSS) and (random==2)then drawp() end if pge.controls.pressed(PGE_CTRL_CROSS) and (random==3)then losep() end if pge.controls.pressed(PGE_CTRL_TRIANGLE) and (random==2)then wins() end if pge.controls.pressed(PGE_CTRL_TRIANGLE) and (random==1)then loses() end if pge.controls.pressed(PGE_CTRL_TRIANGLE) and (random==3)then draws() end if pge.controls.pressed(PGE_CTRL_CIRCLE)then menue() end pge.gfx.enddrawing() pge.gfx.swapbuffers() end end
What do I do wrong?
Edit: My Homebrew is finished
Geändert von Dreiundachzig (07-27-2009 um 06:08 PM Uhr)
-
07-28-2009, 06:38 AM #10122QJ Gamer Blue
Achievements:
- Registriert seit
- May 2009
- Beiträge
- 69
- Points
- 2.018
- Level
- 27
- Downloads
- 0
- Uploads
- 0
i was wondering if their was someone i could pm with a LOT of pge questions
-
07-28-2009, 06:45 AM #10123QJ Gamer Bronze

- Registriert seit
- Dec 2007
- Ort
- B.F.
- Beiträge
- 328
- Points
- 7.257
- Level
- 56
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Maybe i can help.
00:00: Windows is loading...Come back tomorrow.
01:00 : Booting done.Not yet errors encountered...
01:10: Fatal error.Windows has been detected on logical drive
01:22: Keyboard Locked, try everything.
01:42 : Mouse Device Pilot not found, or uninstalled.Press Left-Bouton to continue.
01:50 : Ending User session.Do you want to play another game ?
01:59: Not enough memory.Only 508'312'583 bytes available.
02:00 : System is shutting Down.
-
07-28-2009, 07:30 AM #10124QJ Gamer Blue
Achievements:
- Registriert seit
- May 2009
- Beiträge
- 69
- Points
- 2.018
- Level
- 27
- Downloads
- 0
- Uploads
- 0
i PMed u. =)
-
07-28-2009, 10:16 AM #10125Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
why dont you just post them all up here, you can also ask me but i would preffer to be emailed to fatboycg on my googlemail.com account.
------ 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).
-
07-28-2009, 02:07 PM #10126QJ Gamer Blue
Achievements:
- Registriert seit
- May 2009
- Beiträge
- 69
- Points
- 2.018
- Level
- 27
- Downloads
- 0
- Uploads
- 0
well i might post here once i get some bigger problems but seeing as im having beginer noob problems with pge i dont want to embarass myself.
-
07-30-2009, 07:43 PM #10127QJ Gamer Green
- Registriert seit
- Nov 2008
- Beiträge
- 35
- Points
- 2.236
- Level
- 28
- Downloads
- 0
- Uploads
- 0
could someone please help me? on my app i got intrafont working but i don't want a shadow effect, is there a way to make it so it flashes instead of shadow effect?
-
07-30-2009, 09:06 PM #10128xMod.
- Registriert seit
- Oct 2008
- Ort
- Melbourne, Australia
- Beiträge
- 675
- Points
- 4.576
- Level
- 43
- My Mood
-
- Downloads
- 0
- Uploads
- 0
use C
-
08-07-2009, 08:23 AM #10129Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
-
08-07-2009, 06:51 PM #10130words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
If you can set the color of the shadow, just make the shadow go from one desired color to another desired color using a sine wave.

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
08-07-2009, 07:10 PM #10131QJ Gamer Green
- Registriert seit
- Nov 2008
- Beiträge
- 35
- Points
- 2.236
- Level
- 28
- Downloads
- 0
- Uploads
- 0
how do i make a sine wave?
-
08-07-2009, 10:41 PM #10132QJ Gamer Blue
Achievements:
- Registriert seit
- Aug 2009
- Beiträge
- 10
- Points
- 1.880
- Level
- 25
- Downloads
- 0
- Uploads
- 0
trouble in playing a wav
can any function make that?
i want to play wav when i am pressing a button,
and stop when i release the button
Thanks!
-
08-07-2009, 11:43 PM #10133Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
08-07-2009, 11:45 PM #10134Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
08-07-2009, 11:51 PM #10135QJ Gamer Green
- Registriert seit
- Nov 2008
- Beiträge
- 35
- Points
- 2.236
- Level
- 28
- Downloads
- 0
- Uploads
- 0
yeah im using intrafont in HMv2
-
08-08-2009, 12:05 AM #10136QJ Gamer Blue
Achievements:
- Registriert seit
- Aug 2009
- Beiträge
- 10
- Points
- 1.880
- Level
- 25
- Downloads
- 0
- Uploads
- 0
i use LP HM
-
08-08-2009, 12:06 AM #10137Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Then all the 'C' guys over complicated what you are trying todo. Afaik there isn't any method built in todo what you want but there's alternatives.
You could use frame counting to print the text every 1/6 of a frame?
Example:
frameCount = frameCount + 1;
if frameCount == 10 then
--print text
frameCount = 0; --reset the counter
end
That'll give it a 'flashing' effect. If you want it to say on-screen for longer than increase the range. e.g
if frameCount > 10 and frameCount < 25 then
--print text
elseif frameCount > 25 then
frameCount = 0; --reset the frame counter
end
-
08-08-2009, 12:16 AM #10138Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Read this tut so you understand firstly how to use the functions:
http://www.evilmana.com/tutorials/lua_tutorial_10.php
To have it check for a pressed state in HM you do:
Code:oldpad = Controls.read() --in while loop pad = Controls.read() if pad:cross() and oldpad:cross() ~= pad:cross() then --play sound end --near end of script oldpad = pad; screen.flip() --or flipscreen() depending on your version. screen.waitVblankStart() end
-
08-08-2009, 12:16 AM #10139QJ Gamer Green
- Registriert seit
- Nov 2008
- Beiträge
- 35
- Points
- 2.236
- Level
- 28
- Downloads
- 0
- Uploads
- 0
thank you but how do put the effect into the script?
-
08-08-2009, 12:19 AM #10140Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0


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