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; Zitat von jamz1825 ok im using the 5 bullet code from evil mana and i have it set up so ...
-
08-29-2006, 05:07 PM #3421Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von jamz1825
the problem is, even after uve declared bullet firing to false, the x and y valuse retain their valuse. you need a bool:
try thatCode:hit = false if Wario[1].y + 72 > BulletInfo[i].y and BulletInfo[i].x + 8 > Wario[1].x and BulletInfo[i].x < Wario[1].x + 107 then BulletInfo[i].firing = false hit = true end if hit == true then score = score + 1 hit = false end
--------------------------------------------------------------------------------------
-
08-29-2006, 05:12 PM #3422sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
Why does everyone use Charlie's method? Sure its greats for begginers, but not when you go on to greater tasks. I mean his tutorials are for getting people started in lua, and provide a foundation. NOT provide a way you will use your whole career of lua
-
08-29-2006, 05:23 PM #3423
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
ive already tried that the score just continues to rise
EDIT: i double checked and tried urs, still no luck
-= Double Post =-
and bronx... about the getting started part...this is my first luaGeändert von jamz1825 (08-29-2006 um 05:23 PM Uhr) Grund: Automerged Doublepost
-
08-29-2006, 05:24 PM #3424Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
whos charlie???
Zitat von Bronx
--------------------------------------------------------------------------------------
-
08-29-2006, 05:29 PM #3425
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
no worries i just got it, i had to move the coordinates of the bullet after it hit to a random spot that wouldnt make a difference
-
08-29-2006, 05:31 PM #3426sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
Oh, sorry dude... Continue on learning then

Charlie is the owner of Evilmana >.> (AKA PSPMillionare)
-
08-29-2006, 05:58 PM #3427Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
o his bullet code.. i see now.
Zitat von Bronx
--------------------------------------------------------------------------------------
-
08-29-2006, 06:09 PM #3428Banned from QJ for LIFE
- Registriert seit
- Jul 2006
- Beiträge
- 1.557
- Points
- 10.957
- Level
- 69
- Downloads
- 0
- Uploads
- 0
thx aphonia, but the index.lua in snake goes on about strings and stuff i dont get in that bit >.<
i can wait till more program lua tuts come out as it might help me.
-
08-29-2006, 06:31 PM #3429Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
That's an ugly fix... All you had to do was add an extra part to your if statement:
Zitat von jamz1825
Since the if statement will only trigger when firing == true and you immediately set it to false if it does trigger, than it will only run once.Code:if (collision stuff) and BulletInfo[i].firing then BulletInfo[i].firing = false score = score + 1 end
-
08-29-2006, 06:46 PM #3430Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
we all got pwnt.
Zitat von LMelior
--------------------------------------------------------------------------------------
-
08-29-2006, 07:05 PM #3431Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Check out the io.lines entry in the Lua Reference Manual. I've never had to do what you want before, but if I did then I would probably use that. I don't know if this will work or not, but I'd try this:
Zitat von mraellis
No guarantees, of course. :)Code:tableoflines={} k=0 for line in io.lines("filename.txt") do k=k+1 tableoflines[k]=line end randomline=tableoflines[math.random(k)]
-
08-30-2006, 12:01 PM #3432
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
ok, there could be a very simple answer to this but of coarse i dont know...i am jsut begining
andway
can you tell me how to make it so when i press start the game pauses and if i press it agin it resumes.
i know something exists like
system.sleep()
anyway could anyone help me out?
anyone?
i got it so i can pause but i haveto resume with another button
how could i do it with the smae button (start)Geändert von jamz1825 (08-30-2006 um 12:15 PM Uhr)
-
08-31-2006, 12:05 AM #3433QJ Gamer Bronze
- Registriert seit
- Feb 2006
- Ort
- Earth, UK
- Beiträge
- 457
- Points
- 5.924
- Level
- 49
- Downloads
- 0
- Uploads
- 0
did you use this for the pause code?
Code:--This goes somewhere near the start-- function pause() while true do pad:Controls.read() screen:clear() screen:print(200,200,"Game Paused",red) if pad:start() and oldpad:start()~=pad:start() then break end screen.waitVblankStart() screen.flip() end end --This goes in the main loop-- if pad:start() and oldpad:start()~=pad:start() then pause() end
<<Put A message Here>>
<<Just made another rubbish website visit it here.>>
-
08-31-2006, 10:38 AM #3434Banned from QJ for LIFE
- Registriert seit
- Jul 2006
- Beiträge
- 1.557
- Points
- 10.957
- Level
- 69
- Downloads
- 0
- Uploads
- 0
thanks lmelior but that doesnt work

and that lua link is confusing.
i think i'll wait till a few more lua tuts for program luas out before i make something.
-
08-31-2006, 03:47 PM #3435Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
ok heres my problem i got my code pretty much sorted out but when i olay it the loading screen stays on 0% and then turns off my psp whats wrong anybody know?
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
08-31-2006, 03:54 PM #3436Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von %chrono trigger%
can we see your code?
its probably a loading problem.--------------------------------------------------------------------------------------
-
08-31-2006, 04:10 PM #3437Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
nope didnt find it here is my code:
pink = Color.new(255, 0 , 153)
GameStatus = "Loading"
LoadingTimer = Timer.new()
LoadingTimer:start()
if GameStatus == "Loading" and LoadingTimer:time() >= 1 and LoadingTimer:time() < 50 then
screen:clear()
screen
rint(194, 136, "Loading: 0%", pink)
screen.flip()
gunscreen = Image.load("gunscreen.jpg ")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 50 and LoadingTimer:time() > 100 then
screen:clear()
screen
rint(194, 136, "Loading: 20%", pink)
screen.flip()
gunman = Image.load("gunman.jpg")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 100 and LoadingTimer:time() > 150 then
screen:clear()
screen
rint(194, 136, "Loading: 40%", pink)
screen.flip()
background = Image.load("background.jp g")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 150 and LoadingTimer:time() > 200 then
screen:clear()
screen
rint(194, 136, "Loading: 60%", pink)
screen.flip()
playera = Image.load("playera.png")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 200 and LoadingTimer:time() > 250 then
screen:clear()
screen
rint(194, 136, "Loading: 80%", pink)
screen.flip()
playerb = Image.load("playerb.png")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 250 and LoadingTimer:time() > 300 then
screen:clear()
screen
rint(194, 136, "Loading: 90%", pink)
screen.flip()
end
if GameStatus == "Loading" and LoadingTimer:time() >= 300 and LoadingTimer:time() > 350 then
screen:clear()
screen
rint(194, 136, "Loading: 100%", pink)
screen.flip()
end
if GameStatus == "Loading" and LoadingTimer:time() > 351 then
LoadingTimer:stop()
LoadingTimer:reset()
GameStatus = "Menu"
end
screen:blit(0,0,gunman)
screen.waitVblankStart(60 )
screen:clear()
screen.waitVblankStart(60 )
screen:clear()
screen:blit(0,0,backgroun d)
playera = {}
player[a] = {x = 200, y = 50}
playerb = {}
player[b] = { x = 400, y = 100 }
screenwidth = 480 - player.width()
screenheight = 272 - player.width()
player[b] = { x = 400, y = 100 }
screen:blit(Player [a].x,Player [a].y,playera)
screen:blit(Player[b].x,Player.y,playerb)
screenwidth = 480 - player.width()
screenheight = 272 - player.width()
Playerb = { x = 400, y = 100 }
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 2
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 2
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 2
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 2
end
screen.waitVblankStart()
screen.flip()**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
08-31-2006, 04:22 PM #3438QJ Gamer Green
- Registriert seit
- Jun 2006
- Ort
- London
- Beiträge
- 645
- Points
- 6.256
- Level
- 51
- Downloads
- 0
- Uploads
- 0
But why use Lua for "your whole career" when you have C++?
Zitat von Bronx
@ Chrono, i think that would load the image into memory over and over again realy quickly, crashing the PSP.
Use
That was terrible i dont even know if there is a ELSE function in Lua.Code:if loading step = 1 IF background (or whatever image) = null //* Print text saying 20% done or whatever //* Load Background image... END else load = 2 END END
Wait, i dont know Lua at all! But anyway what you want done can be acomplished with Null.
So
isCode:IF Background = null
orCode:If the memory at the address background is empty then.
Code:if background is empty then.
Geändert von Nutterbutter (08-31-2006 um 04:24 PM Uhr) Grund: Automerged Doublepost
[b][center]
[URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]
[url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]
-
08-31-2006, 04:28 PM #3439Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
where do i put the IF Background = null?
and what does the code do? (so im not just coping and pasting)**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
08-31-2006, 04:31 PM #3440QJ Gamer Green
- Registriert seit
- Jun 2006
- Ort
- London
- Beiträge
- 645
- Points
- 6.256
- Level
- 51
- Downloads
- 0
- Uploads
- 0
I explained it at the bottom. DONT copy that code, i dont know lua, it wont work. It was just theory code.
IF background = null will check to see if there is no image in background.
Soo take out the timer and put that there instead. The timer is what is crashing the PSP.
Ergh ive explained this terribly...[b][center]
[URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]
[url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]
-
08-31-2006, 04:32 PM #3441Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
yeah but im sort of getting the idea
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
08-31-2006, 04:33 PM #3442QJ Gamer Green
- Registriert seit
- Jun 2006
- Ort
- London
- Beiträge
- 645
- Points
- 6.256
- Level
- 51
- Downloads
- 0
- Uploads
- 0
Good, null is a useful part of programming.
[b][center]
[URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]
[url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]
-
09-01-2006, 06:14 AM #3443QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Use nil instead of NULL for Lua.
-
09-01-2006, 11:07 AM #3444
- Registriert seit
- Apr 2006
- Beiträge
- 10
- Points
- 4.094
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Hey can someone help me out with making this rpg work. I'm trying to make my sprites do a proper walk so if they press down it looks like it's going down like it is a real rpg.
Code:grass = Image.load("grass.png") player = Image.load("player.png") player1 = Image.load("player1.png") player2 = Image.load("player2.png") player3 = Image.load("player3.png") player4 = Image.load("player4.png") player5 = Image.load("player5.png") player6 = Image.load("player6.png") screenwidth = 480 - player:width() screenheight = 272 - player:width() Player = { } Player[1] = { x = 200, y = 50 } while true do pad = Controls.read() screen:clear() for a = 0, 14 do for b = 0,8 do screen:blit(32 * a, 32 * b, grass) end end screen:blit(Player[1].x,Player[1].y,player) if Player[1].dir=="left" then screen:blit(Player[1].x,Player[1].y,player1) end if Player[1].dir=="right" then screen:blit(Player[1].x,Player[1].y,player2) end if Player[1].dir=="up" then screen:blit(Player[1].x,Player[1].y,player3) end if Player[1].dir=="down" then screen:blit(Player[1].x,Player[1].y,player4) end if pad:left() and Player[1].x > 0 then Player[1].dir = "left" Player[1].x = Player[1].x - 4 end if pad:right() and Player[1].x < screenwidth then Player[1].dir = "right" Player[1].x = Player[1].x + 4 end if pad:up() and Player[1].y > 0 then Player[1].dir = "up" Player[1].y = Player[1].y - 4 end if pad:down() and Player[1].y < screenheight then Player[1].dir = "down" Player[1].y = Player[1].y + 4 end if pad:home() then break end screen.waitVblankStart() screen.flip() end
-
09-02-2006, 06:57 AM #3445
hey can someone tell me:
A. what image files are supported with luaplayer
B. what image file can be over 480x272 while still being transparent
C. why a png can't be over 480x270
i need this for a boss in my game Orbz. the boss looks horrible because I used a jpeg for it cause the total strip image is 30XX by 163
also, coding help:
A. is there a function/code that will allow me to do something like:
move_towards(xvar_of_obje ct,yvar_of_object,x,y,spe ed)
or any form of a "move towards a point"? or even like move in a direction
move(xvar_of_object,yvar_ of_object,direction,speed ) ?
-
09-02-2006, 10:01 AM #3446Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
A. png and jpg, bmp if you use BMPlib be youresam.
Zitat von mako
B. none. if you have anything over 480x272, theres a 90% chance lua wont load it.
C.cause it takes wayyy too much ram. a 200x200 png image takes almost 1MB, and you only have like 10MB to work with.
CODING
A. youll have to do it yourself.--------------------------------------------------------------------------------------
-
09-02-2006, 10:37 AM #3447
B: I can load a 3000x163 jpg fine, just no transparency. and on the psp, it doesn't show up at all. just a big white block
Zitat von Grimfate126
so will splitting the images and loading them separately work? i reeli doubt it, but hey, its worth a shot. there would be about 40 163x163 pngs
-
09-02-2006, 10:42 AM #3448Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
well, jpegs have a higher chance of loading, but they just become white blocks.
Zitat von mako
--------------------------------------------------------------------------------------
-
09-02-2006, 10:59 AM #3449
so will splitting the images and loading them separately work? i reeli doubt it, but hey, its worth a shot. there would be about 40 163x163 pngs
-
09-02-2006, 11:03 AM #3450Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von mako
40?!?? i doubt it. but u might as well try. if that dont wrk. convert your code to C. it should work much better.--------------------------------------------------------------------------------------


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