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; ive edited my post to include the lua files -= Double Post =- hey ive just edited my code and ...
-
11-13-2006, 06:23 AM #4081QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ive edited my post to include the lua files
-= Double Post =-
hey ive just edited my code and now when you go outside no matter where you start you end up in the middle of the screen but when you go inside you start at the entrance instead of the center. Can someone please help me because this is confusing
Geändert von mark.sparky (11-13-2006 um 06:23 AM Uhr) Grund: Automerged Doublepost
-
11-13-2006, 07:29 AM #4082Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
okay im getting an error when i run this something like
index.lua 16 expected near ')' the usual well heres the code
Also my patrolling code im still having trouble understanding it but if it looks right then can i just get an ok on it. thanks.--//maze of doom
--loads the map
grass = Image.load("grass.png")
--loads the player and enemies
player = Image.load("player.png")
enemy1 = Image.load("enemy1.png")
enemy2 = Image.load("enemy2.png")
--screen width and height
screenwidth = 480 - player:width()
screenheight = 272 - player:width()
--player table
Player = {}
Player[1]= {x=0, y=0}
-- enemy table
enemy = {}
enemy[1]= {x=10, y=10)
--first loop
while true do
pad = Controls.read()
for a = 0, 14 do
for b = 0, 8 do
screen:blit (32*a, 32*b, grass)
end
end
-- print the player to the screen
screen:blit(Player[1].x,Player[1].y,player)
-- now lets make him move
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 3
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 3
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 3
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 3
end
--x=width and y= height
-- this prints the enemy1 to screen
screen:blit(enemy[1].x,enemy[1].y,enemy1)
-- now lets try to get him patrolling
Direction = { x = 0, y = 0 }
Direction.x = 1
enemy[1].x = 10
enemy[1].y = 10
Speed = 3
while true do
if enemy[1].x < 10 then
Direction.x = 1
end
if enemy[1].x > 200 then
Direction.x = -1
end
enemy[1].x = enemy[1].x + ( Speed * Direction.x )
enemy[1].y = enemy[1].y + ( Speed * Direction.y )
end
screen.waitVblankStart()
screen.flip()
endIf you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-13-2006, 07:45 AM #4083QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
on line sixteen in the array( i think that is what it is called ) you have a { and finish with a )
-
11-13-2006, 09:36 AM #4084Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
alright i was really bored today as i was waiting for the feedback on my maze thing so i coded a simple rock paper scissors game. i havent tested it yet so can someone just proof read my source really fast and i would appreciate you not taking it because after working on this for a couple more days i may release it.
--removed the code because of the problem being fixed.
Smileyface with tongue sticking out == : p (take away the spaces)
EDIT: O didnt even see your posts mark.sparky thanks for the correction. once im done with rock paper and scissors ill test it again.
EDIT AGAIN: i tried this game and im getting an error 28 or something like that. it says i have like an unknown symbol or something cant really figure it out help plz.Geändert von GuitarGod1134 (11-14-2006 um 08:54 AM Uhr)
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-13-2006, 12:20 PM #4085QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
error:28: unexpected symbol near "and"
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
11-13-2006, 01:36 PM #4086Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
yah thats the error but whats the fix?
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-13-2006, 05:58 PM #4087I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
In this line:
if pad:circle() then
screen:blit(390, 20, rock) and player2 = player2 + 3
end
You don't put and, you do this:
if pad:circle() then
screen:blit(390, 20, rock)
player2 = player2 + 3
end
-
11-13-2006, 06:34 PM #4088QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
lol, I made rock paper scissors for my old calculator, a casio fx 9750g plus.
I had to type all the things in on the stupid calculator and it made me so mad...
it was text only too...
much better with lua.
-
11-14-2006, 07:00 AM #4089Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
thanks access denied. i think im gonna actually go really far with this game thing. at first i was just coding it for fun but its a really fun idea and there is one other game but its not being updated.
EDIT: ok how do i make it so that when i press start it exits the game isnt it like
if pad:start() then
os.exit
or something like that.Geändert von GuitarGod1134 (11-14-2006 um 08:29 AM Uhr)
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 03:26 PM #4090QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
if pad:start() then
break
end
-
11-14-2006, 03:34 PM #4091I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
That doesn't exit the game. It switches from one loop to another. os.exit() or System.Quit() exits to the XMB. It's most likely os.exit() but System.Quit() might work too.
Zitat von -TacticalPaper-

-
11-14-2006, 03:38 PM #4092Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
i tried os.exit() and it just turns the screen black for a second and it starts my game again. one time it even turned the psp off. lol so in that case should i use system.quit()?
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 03:38 PM #4093lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
does
os.exit()
work on 2.71 SE-B"?
I try it and it never works for me, It just freezes...
-
11-14-2006, 03:41 PM #4094I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
That's the problem with os.exit() it sometimes doesn't work. So if you download LuaPlayer .20 mod by Cools, you can use System.Quit(). It only works with the .20 mod though, not the normal version.
Zitat von GuitarGod1134

-
11-14-2006, 03:43 PM #4095lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Where can i download the mod?
Zitat von Access_Denied
-
11-14-2006, 03:44 PM #4096Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
o ok well at the moment im running .20 so i guess ill download the mod thanks. and one more thing to generate a random number isnt it like math.random or something like that but how would you generate a random number between 3-5. like the psp chooses its self either 3, 4 or 5 but random. ?? im looking on evilmana right now cant find anything.
EDIT: I think i found it
http://evilmana.com/tutorials/codeba...om_numbers.php
is that it? pretty sure thats right.If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 03:49 PM #4097QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
math.random(3,5)
-
11-14-2006, 03:52 PM #4098Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
i have a scrolling background. it repeats it self as it scrools from right to left. but my problem is after it repeats itself twice, it doesnt repeat itsself again leving me with a black background
bg=background
-= Double Post =-Code:bgy = 482 bgy = bgy - 5 if bgy<= 482 then bgy = 0 end if bgy>1 then bgy = bgy - 481 end screen:blit(bgy,0,bg) screen:blit(bgy+bg:width(),0,bg)
nevermidn i got itGeändert von yoyomacy (11-14-2006 um 03:52 PM Uhr) Grund: Automerged Doublepost

-
11-14-2006, 03:56 PM #4099Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
would i do something like this
Zitat von -TacticalPaper-
if pad:r() then
computer = math.random(3,5)
and ya computer is a variable nameIf you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 04:08 PM #4100QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- London, United Kingdom
- Beiträge
- 131
- Points
- 4.812
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Can someone give me an example of how to write text thats right justified? I had attempted once but the amount of padding would change depending on the letters and the writing isnt going to be always the same...
Geändert von trex6662k5 (11-14-2006 um 04:36 PM Uhr)
-
11-14-2006, 04:09 PM #4101lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Just use screenprint but make the pixels on the right part of the screen.
-
11-14-2006, 04:10 PM #4102Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Ok heres part of my code here
but the problem is as soon as i press r my pic goes away and the variable returns to its orginal state. how can i make it so that one press of r and boom the pic stays blitted and the variable stays at the random selection. also i tried holding r and since its random it doesnt work it just keeps changing.if pad:r() then
computer = math.random(3,5)
end
-- Also with the progress im making we may see Lua RPS v0.02 by tomorrow or maybe even today lol.If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 04:12 PM #4103QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Something like
computer = math.random(3,5)
if computer == 3 then
blah
end
if computer == 4 then
blah
end
if computer == 5 then
blah
end
-
11-14-2006, 04:19 PM #4104Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Well I have it like
I thought i would have to do something like oldpad=pad or something so that one i press it i dont have to hold it down.if pad:r() then
computer = math.random(3,5)
end
--// then further down i have the
if computer == bla bla statementsIf you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 04:26 PM #4105I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
If you're going to be using math.random, put this line at the beginning of your code:
math.randomseed(os.time() )
-
11-14-2006, 04:32 PM #4106Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
i saw that line on evilmana but shouldnt it be my variable in there too. my variable is computer so shouldnt it be
Zitat von Access_Denied
math.computer(os.time())) ?
EDIT
still need this quesiton
Well I have it like
Quote:
if pad:r() then
computer = math.random(3,5)
end
--// then further down i have the
if computer == bla bla statements
I thought i would have to do something like oldpad=pad or something so that one i press it i dont have to hold it down.
Also is there any definite way to exit the lua script. i see u guys saying that os exit doesnt work and that other function only works on that lua player mod but i want this game to run on all lua players so the common homebrewer will be able to play it.If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 04:33 PM #4107QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Ok then maybe something like
variable = 0
if pad:r() then
variable = variable + 1
end
if variable > 0 then
computer = math.random(3,5)
end
-
11-14-2006, 04:38 PM #4108Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Ill try.
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 04:40 PM #4109Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
is it possible to do a collision with dofile, i have my bullet settings in one file and my game in another lua file. i want bullets to do collision with oobjects in my game file. how do i do that

-
11-14-2006, 04:47 PM #4110Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von GuitarGod1134
ROFL! HAHHAHAHAHAHAHAHAHAHAHA :ROFL: :ROFL: :ROFL: :ROFL: HAHAHAHA..
lol, sorry, couldnt hold myself there. NO, you keep itrandom.randomseed is a function, you cant change it.Code:math.randomseed(os.time())
--------------------------------------------------------------------------------------


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