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; Just use this: if player.x == enemy.x then FireBullet() end if bullet.y > player.y then bullet.y = bullet.y - 4 ...
-
08-25-2006, 06:33 AM #3361I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Just use this:
if player.x == enemy.x then
FireBullet()
end
if bullet.y > player.y then
bullet.y = bullet.y - 4
end
This will make it, so when you fire the bullet, it will come straight down. And it will only fire if the player is directly under the enemy.

-
08-25-2006, 06:43 AM #3362
- Registriert seit
- Jul 2006
- Beiträge
- 36
- Points
- 3.957
- Level
- 40
- Downloads
- 0
- Uploads
- 0
ok i guess that will work thnx
-
08-25-2006, 06:45 AM #3363is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
i see what you are doing!
easy, as long asyour player saysy at the same 'y' location, just make its x loaction be called bulletdestination then make thhe bullets go to thereWhat did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
08-25-2006, 06:47 AM #3364I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
You can also make it a little more tolerant. Like it the player is sort of under it. Like this:
if (player.x + 10) == enemy.x then
FireBullet()
end
if (player.x - 10) == enemy.x then
FireBullet()
end
This will make it so if the player is kind of under the enemy, it will fire. You can also change the speed of the bullet from 4 to something faster.
-= Double Post =-
Yeah but you don't want the bullet to follow the player. Bullets go in straight lines not loops and zigzags.
Zitat von Glynnder
Geändert von ARza (08-25-2006 um 06:47 AM Uhr) Grund: Automerged Doublepost

-
08-25-2006, 11:01 AM #3365
How can I make the text from Image2 go into Image1??? Images were borrowed from ProgramLua to show an example...
**Image1**

**Image2**
-
08-25-2006, 12:22 PM #3366I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Well image 2 is transparent, so just paste 2 on top of 1. Like this:
screen:blit(0,0,image1)
screen:blit(0,0,image2)
-
08-25-2006, 12:38 PM #3367
Thanks ARza, sorry for using ur images without asking u...
-
08-25-2006, 12:40 PM #3368No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
Corrected :).
Zitat von Dr.Gringo
-
08-25-2006, 12:41 PM #3369I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
It's cool, you weren't really using them. Only for an example.

-
08-25-2006, 12:45 PM #3370No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
How do I make the player move if the player moves the analog stick in Lua?
-
08-25-2006, 12:59 PM #3371words 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
You know you dont know the concept when you always use game specifics when asking for help ;)
You should be asking how to manipulate a variable, using hte analog stick...
I havent used LUA in forever, so i dont know the control name for the analog stick, but it ranges from -128 - +128, so say if pad:analogX() > 50 then increase_x_co-ordinate...
...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-25-2006, 01:02 PM #3372
Once you have blitted a text image how do you change to another??? Is it going to overlap or would it just substitute...
-
08-25-2006, 01:04 PM #3373No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
I assume you don't know that ARza and I made it together? Look in the credits.
Zitat von Dr.Gringo
-
08-25-2006, 01:05 PM #3374I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
It's actually from -127 to 128. -128 will give you an error.
Zitat von SG57

-
08-25-2006, 01:05 PM #3375No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
Thanks
Zitat von SG57
.
Thanks
Zitat von ARza
!
-
08-25-2006, 01:07 PM #3376is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
lol, ouch no recognition.
and its analog_x methinksWhat did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
08-25-2006, 01:09 PM #3377No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
Tell me about it. Every person who thinks ProgramLua is great knows that I did half of the work. Except Dr. Gringo.
Zitat von Glynnder
And... hey, Glynnder, you keep changing your sig. Maybe I should make one for ya? That'll be 500 poitns please. Lol!
-
08-25-2006, 01:09 PM #3378I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
As most of you probably know, I'm making a game where you draw designs. I have the drawing part done. When you press X on a square, it turns it black. O turns it white. Well, when trying it on my PSP it runs horribly slow. I am using PSPmillionaire's scrolling tile engine. I modified it to work. But when it's on a PSP is runs slow. I've tried .16 and .20. I even tried the .20 mod by Cools and set the CPU to 333 and it still runs slow. Here's my code, any suggestions?
Code:-- Define Variables --============== currenty = 3 currentx = 3 Colliding = false --Images black = Color.new(0,0,0) white = Color.new(255,255,255) Images = { } Images[1] = Image.createEmpty(5,5) Images[2] = Image.createEmpty(5,5) Images[1]:clear(black) Images[2]:clear(white) Images[50] = Image.load("Selector.png") base = Image.load("Base.png") TILE_SIZE = 6 CHARACTER_SIZE = 7 MAP_WIDTH = 42 MAP_HEIGHT = 42 SCREEN_HEIGHT = 272 SCREEN_WIDTH = 480 SCREEN_WIDTH_BOUNDARY = 480 SCREEN_HEIGHT_BOUNDARY = 272 SCROLL_BOUNDARY = TILE_SIZE*7.5 SCROLL_BOUNDARY2 = TILE_SIZE*2.5 STAT_BOX_HEIGHT = 40 MX = TILE_SIZE MY = TILE_SIZE player = {speed = 6,x = 11, y = 11} map = { } map[1] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[2] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[3] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[4] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[5] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[6] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[7] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[8] = {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2} map[9] = {2,2,2,2,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_SIZE) py = py + (MY-TILE_SIZE) mapx1 = math.floor(px / TILE_SIZE + 1) mapy1 = math.floor(py / TILE_SIZE + 1) mapx2 = math.floor((px+CHARACTER_SIZE) / TILE_SIZE + 1) mapy2 = math.floor(py / TILE_SIZE + 1) mapx3 = math.floor(px / TILE_SIZE + 1) mapy3 = math.floor((py+CHARACTER_SIZE) / TILE_SIZE + 1) mapx4 = math.floor((px+CHARACTER_SIZE) / TILE_SIZE + 1) mapy4 = math.floor((py+CHARACTER_SIZE) / TILE_SIZE + 1) id1 = getMapTile(mapy1, mapx1) id2 = getMapTile(mapy2, mapx2) id3 = getMapTile(mapy3, mapx3) id4 = getMapTile(mapy4, mapx4) if id1 < 50 and id2 < 50 and id3 < 50 and id4 < 50 then Colliding = false else Colliding = true end end function getMapTile(y,x) if x >= 0 and x <= MAP_WIDTH and y >= 0 and y <= MAP_HEIGHT then img = map[y][x] return img else return 0 end end function drawMap(mapDrawX, mapDrawY) mapx = math.floor(mapDrawX / TILE_SIZE) mapy = math.floor(mapDrawY / TILE_SIZE) xoff = math.floor(mapDrawX and (TILE_SIZE-1)) yoff = math.floor(mapDrawY and (TILE_SIZE-1)) xoff = math.floor(mapDrawX - mapx*TILE_SIZE) yoff = math.floor(mapDrawY - mapy*TILE_SIZE) for x = 2,42 do for y = 2,42 do img = getMapTile(mapy+y, mapx+x) if img > 0 then screen:blit(x*TILE_SIZE - xoff, y*TILE_SIZE - yoff,Images[img]) end end end end function PositionPlayer(x, y) screen:blit(x,y,Images[50]) end --Main Loop oldpad = Controls.read() while true do screen:clear() screen:blit(0,0,base) oldPlayerX = player.x oldPlayerY = player.y pad = Controls.read() if pad:up() and oldpad:up() ~= pad:up() then player.y = player.y - 6 currenty = currenty - 1 end if pad:down() and oldpad:down() ~= pad:down() then player.y = player.y + 6 currenty = currenty + 1 end if pad:right() and oldpad:right() ~= pad:right() then player.x = player.x + 6 currentx = currentx + 1 end if pad:left() and oldpad:left() ~= pad:left() then player.x = player.x - 6 currentx = currentx - 1 end if pad:up() and oldpad:up() ~= pad:up() and pad:square() then player.y = player.y - 24 currenty = currenty - 4 end if pad:down() and oldpad:down() ~= pad:down() and pad:square() then player.y = player.y + 24 currenty = currenty + 4 end if pad:right() and oldpad:right() ~= pad:right() and pad:square() then player.x = player.x + 24 currentx = currentx + 4 end if pad:left() and oldpad:left() ~= pad:left() and pad:square() then player.x = player.x - 24 currentx = currentx - 4 end if player.y > 245 then player.y = 245 end if player.x > 245 then player.x = 245 end if player.y < 11 then player.y = 11 end if player.x < 11 then player.x = 11 end if currentx > 42 then currentx = 42 end if currentx < 3 then currentx = 3 end if currenty > 42 then currenty = 42 end if currenty < 3 then currenty = 3 end if pad:circle() and oldpad:circle() ~= pad:circle() then map[currenty][currentx] = 2 end if pad:cross() and oldpad:cross() ~= pad:cross() then map[currenty][currentx] = 1 end CollisionOverlaps(player.x,player.y) if Colliding == true then player.x = oldPlayerX player.y = oldPlayerY else end MXa = math.floor(MX) MYa = math.floor(MY) drawMap(MXa,MYa) PositionPlayer(player.x, player.y) --PrintStats(player) screen.waitVblankStart() screen:flip() oldpad = pad end
-
08-25-2006, 01:10 PM #3379
Once you have blitted a text image how do you change to another??? Is it going to overlap or would it just substitute...
I did know that Appleseed629 did half of programlua however i said arza because he was on the above post, rofl
-
08-25-2006, 01:13 PM #3380Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dr.Gringo
why did you post the same question twice?? anyway, what do you mean by "text image"?? like an image with text on it?? it so, just clear the screen, and blit the next image. OR, keep the background image the same, and just substitue the text.--------------------------------------------------------------------------------------
-
08-25-2006, 01:14 PM #3381I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I did this:
current = 1
image = {}
image[1] = "image.png"
image[2] = "image.png"
image[3] = "image.png"
image[4] = "image.png"
current_image = nil
current_image = Image.load(image[current])
Understand? If you change the variable "current" the image will change.
-
08-25-2006, 01:14 PM #3382No longer a community member.
- Registriert seit
- Jan 2006
- Beiträge
- 2
- Points
- 25.679
- Level
- 96
- Downloads
- 0
- Uploads
- 0
Then why did you say, "Sure, Appleseed629." That I wonder...
Zitat von Dr.Gringo
ProgramLua is like that: it changes to another image when you press a button. If you want two images at the same time, you're gonan have to move the second by 1 more in the x/y coordinate.
-
08-25-2006, 01:15 PM #3383
Arza if i do it your method would i have to Load all the images at the beginning of my script
-
08-25-2006, 01:30 PM #3384Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dr.Gringo
not necessaliry. but you have to load them before yu use them.
and try not to load them in your while true do loop, thats make your game VERY VERY slow.--------------------------------------------------------------------------------------
-
08-25-2006, 08:33 PM #3385
When I clear the screen how can i keep my background and only change the picture with the text.
Example:
Code:oldpad = Controls.read() while true do pad=Controls.read() screen:clear() screen:blit(0, 0, clear, false) if pad:down() and oldpad:down() ~= pad:down() and current = 20 then pictext = Image.load("images/pictext.png") screen:blit(0, 0, pictext, false) end screen.waitVblankStart() oldpad = pad screen.flip()
-
08-25-2006, 08:40 PM #3386Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Dr.Gringo
actually, ur gonna have to make an array:
Code:text = {} text[1] = Image.load("yourtextimagename") -- etc. currentText = 0 oldpad = Controls.read() while true do pad=Controls.read() screen:clear() screen:blit(0, 0, clear, false) if currentText ~= 0 then screen:blit(0, 0, text[currentText]) end if pad:down() and oldpad:down() ~= pad:down() and current = 20 then currentText = 1 end screen.waitVblankStart() oldpad = pad screen.flip() end--------------------------------------------------------------------------------------
-
08-26-2006, 02:18 AM #3387Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
what's wrong with this one
Code:red = Color.new(255,0,0) black = Color.new(0,0,0) white = Color.new(255,255,255) menustatus = 1 while true do screen:clear(black) pad = Controls.read() if pad:up() then menustatus = menustatus - 1 screen.waitVblankStart(4) end if pad:down() then menustatus = menustatus + 1 screen.waitVblankStart(4) end color={white, white, white} while true do screen:print(50, 50, "Play", color[1]) screen:print(50,60,"Options", color[2]) screen:print(50,70,"Exit", color[3]) end color[menustatus]=red if menustatus == 1 then if pad:cross() then screen:clear() screen:print(50, 50, "Play", color[1]) end end if menustatus == 2 then if pad:cross() then screen:clear() screen:print(50, 50, "Play", color[1]) end end if menustatus == 3 then if pad:cross() then break end end if menustatus <= 0 then menustatus = 3 end if menustatus => 4 then menustatus = 1 end screen.flip() screen.waitVblankStart() end
-
08-26-2006, 03:27 AM #3388QJ Gamer Bronze
- Registriert seit
- Feb 2006
- Ort
- Earth, UK
- Beiträge
- 457
- Points
- 5.924
- Level
- 49
- Downloads
- 0
- Uploads
- 0
You have two 'While true do' loops
Zitat von hallo007
<<Put A message Here>>
<<Just made another rubbish website visit it here.>>
-
08-27-2006, 04:35 PM #3389QJ Gamer Bronze
- Registriert seit
- Jul 2005
- Ort
- USA
- Beiträge
- 496
- Points
- 14.090
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Working on a game. Here's my code.
Code thats a problem -
Example of my table -Code:EnemyList = {1,2,3,4,5,6} (REST OF CODE) if Enemy[EnemyList[target]].health <= 0 then Enemy[EnemyList[target]].state = "dead" end if Enemy[EnemyList[Length]].state = "dead" then screen:print(10, 130, "You killed all the enemies") end
The error I get is " 'then' expected near '=' "Code:Enemy = {} Enemy[1] = {name = "Zombie", damage = 3, health = 15, combatx = 300, combaty = 5, image = mzombie, state = "living"} Enemy[2] = {name = "Zombie", damage = 3, health = 20, combatx = 310, combaty = 15, image = mzombie2, state = "living"}
I probably didn't need to include all that information, but more is better then less. This is probably an easy solution also, but I don't care b/c im tired.
-
08-27-2006, 04:40 PM #3390Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
you need two '=' to compare:
Zitat von CtrlAltDeleteDie
Example of my table -Code:EnemyList = {1,2,3,4,5,6} (REST OF CODE) if Enemy[EnemyList[target]].health <= 0 then Enemy[EnemyList[target]].state = "dead" end if Enemy[EnemyList[Length]].state == "dead" then screen:print(10, 130, "You killed all the enemies") end
Code:Enemy = {} Enemy[1] = {name = "Zombie", damage = 3, health = 15, combatx = 300, combaty = 5, image = mzombie, state = "living"} Enemy[2] = {name = "Zombie", damage = 3, health = 20, combatx = 310, combaty = 15, image = mzombie2, state = "living"}--------------------------------------------------------------------------------------


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