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; It's ok now, I've got it working like this... PHP-Code: -- Defining colors -- green = Color .new( 0 , 255 ...
-
04-18-2006, 01:44 AM #1681
- Registriert seit
- Jan 2006
- Beiträge
- 7
- Points
- 4.172
- Level
- 41
- Downloads
- 0
- Uploads
- 0
It's ok now, I've got it working like this...
Thanks...PHP-Code:-- Defining colors --
green = Color.new(0,255,0)
ball1 = Image.load("ball1.png")
ball2 = Image.load("ball2.png")
ball3 = Image.load("ball3.png")
-- Math --
pi = 4*math.atan(1)
-- Defining tables --
ball = {}
ball[1] = {ball = ball1, x = 20, y = 20, speed = 5000, angle = pi/8}
ball[2] = {ball = ball2, x = 40, y = 60, speed = 5000, angle = pi/8}
ball[3] = {ball = ball3, x = 60, y = 100, speed = 5000, angle = pi/8}
-- Functions --
function move()
for k in pairs(ball) do
screen:blit(ball[k].x, ball[k].y, ball[k].ball, true)
ball[k].x = ball[k].x + ball[k].speed
ball[k].y = ball[k].y + ball[k].speed
end
end
function moving()
for k in pairs(ball) do
a = ball[k].speed / 500
if a >= 0 then
if ball[k].x <= 6 or ball[k].x >= 460 then
ball[k].angle = pi - ball[k].angle
end
if ball[k].y <= 5 or ball[k].y >= 252 then
ball[k].angle = ball[k].angle * (-1)
end
ball[k].x = ball[k].x + math.cos(ball[k].angle) * a
ball[k].y = ball[k].y + math.sin(ball[k].angle) * a
ball[k].speed = ball[k].speed - 10
end
screen:blit(ball[k].x,ball[k].y,ball[k].ball,true)
end
end
while true do
screen:clear()
moving()
screen.waitVblankStart()
screen.flip()
end
-
04-18-2006, 06:18 AM #1682
well i didn't do that much hehe but you're welcome!
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-18-2006, 11:45 AM #1683Developer

- Registriert seit
- Mar 2006
- Ort
- Guadalajara
- Beiträge
- 958
- Points
- 7.499
- Level
- 57
- Downloads
- 0
- Uploads
- 0
can I play 2 sounds at the same time?? if there is a way post it please!!!

Current projects:
- pspshootoutsv0.4
- PSPIRATESv6 :D
- Kindom Hearths: Sora´s Adventure V0.2
- PSPirates Alarm Clock v0.3
- Changos!: fall of the army-ITS ALIVE AND WORKING (coming soon)
PSPMEX DevTeam.
-
04-18-2006, 12:13 PM #168411th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Yes, You Can.
Zitat von MEXICANSNAKE
FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
04-18-2006, 12:45 PM #1685Jesus loves me more.
- Registriert seit
- Mar 2006
- Ort
- Illegal Abric Sites
- Beiträge
- 1.551
- Points
- 11.452
- Level
- 70
- Downloads
- 0
- Uploads
- 0
How would i get it to sellect somthing in a list randomly? and if i have it load a txt would it see the info in hte txt as whats in it ex.: Viat(is the first line in the txt) i have it load Viat.txt and the value for tthe Viat.txt would be Viat?

-
04-18-2006, 01:07 PM #1686Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
can anyone help me pls??
--------------------------------------------------------------------------------------
-
04-18-2006, 01:38 PM #1687is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
whats ur question grimfate?
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
04-18-2006, 01:51 PM #1688
Zitat von Grimfate126
The math.ceil function will make it return either 1 or -1 based on if dx is positive or negative.Code:pad = Controls.read() dx = pad:analogX() dy = pad:analogY() if math.abs(dx) > 32 then cursorx = cursorx + dx / 64 height = height + math.ceil(1/dx) end if math.abs(dy) > 32 then cursory = cursory + dy / 64 end牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-18-2006, 02:32 PM #1689
- Registriert seit
- Aug 2005
- Beiträge
- 28
- Points
- 4.621
- Level
- 43
- Downloads
- 0
- Uploads
- 0
I am having trouble with some random numbers. I have my code set up perfectly the way I want it and it works except that I get the same random numbers for different variables at times, which is not what I want. I have tried to counteract this by setting up kind of a checker system to detect like numbers in different variables and change them accordingly, however my efforts haven't succeded as of yet. I have an example of the type of code I am using and if anyone has any suggestions or now exactly whats up with it I will appreciate the advice/help.
Code:function randomnumbers() var1 = math.random(1,4) var2 = math.random(1,4) var3 = math.random(1,4) var4 = math.random(1,4) if var2 == var1 then var2 = math.random(1,4) end if var2 == var3 then var2 = math.random(1,4) end if var2 == var4 then var2 = math.random(1,4) end if var3 == var1 then var3 = math.random(1,4) end if var3 == var2 then var3 = math.random(1,4) end if var3 == var4 then var3 = math.random(1,4) end if var4 == var1 then var4 = math.random(1,4) end if var4 == var2 then var4 = math.random(1,4) end if var4 == var3 then var4 = math.random(1,4) end end
-
04-18-2006, 03:12 PM #1690
Have you used "random.seed(os.time( ))"? Thats makes the random "truly" random.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-18-2006, 04:31 PM #1691QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
I think that's what your talking about
Zitat von Grimfate126
-
04-18-2006, 06:34 PM #1692Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
okay, what is wrong with this?
I dont know how to make the randomization start...Code:yellow = Color.new(255, 255, 0) math.randomseed(os.time() ) while true do number = math.random(1,4) if number == 1 then screen:print(0, 0, "Poo", yellow) end if number == 2 then screen:print(0, 0, "Monger", yellow) end if number == 3 then screen:print(0, 0, "Turd", yellow) end if number == 4 then screen:print(0, 0, "Face", yellow) end end
-
04-18-2006, 06:51 PM #1693QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
the random should be fine
-
04-18-2006, 06:57 PM #1694QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
i just tested it and it does work
forgot to hit edit.sorry for double postGeändert von soadnation (04-18-2006 um 07:00 PM Uhr)
-
04-19-2006, 12:24 AM #1695
- Registriert seit
- Aug 2005
- Beiträge
- 28
- Points
- 4.621
- Level
- 43
- Downloads
- 0
- Uploads
- 0
I assume that the two previous posts were directed toward my question. Assuming so, that's not what I"m trying to do. I'm printing 4 random variables to the screen at one time and I don't want any of them to be the same as another. An example would be if you put each variable as equaling math.random(1,4) for all 4 variables to print to the screen it would print a random variable for each one put there is a chance you would get two 1's or two 2's or three 1's. I am trying to develop a system that would check if any of the variables are the same and repeat randomizing numbers until one is found that isn't already used.
-
04-19-2006, 01:45 AM #1696
function randomnumbers()
while true do
var1 = math.random(1,4)
var2 = math.random(1,4)
var3 = math.random(1,4)
var4 = math.random(1,4)
if var2 == var1 then
var2 = math.random(1,4)
end
if var2 == var3 then
var2 = math.random(1,4)
end
if var2 == var4 then
var2 = math.random(1,4)
end
if var3 == var1 then
var3 = math.random(1,4)
end
if var3 == var4 then
var3 = math.random(1,4)
end
if var4 == var1 then
var4 = math.random(1,4)
end
if var1~=var2 and var2~=3 and var1~=var3 and var1~=var4 and var2~=4 and var3~=var4 then
break
end
endLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-19-2006, 10:28 AM #1697
- Registriert seit
- Apr 2006
- Ort
- Bay Area, California
- Beiträge
- 26
- Points
- 4.133
- Level
- 40
- Downloads
- 0
- Uploads
- 0
I need help. I can get everything to work but the dPad.
Code:--Basic Variables white = Color.new(255,255,255) titlePlay = Image.load("titlePlay.png") titleInfo = Image.load("titleInfo.png") titleExit = Image.load("titleExit.png") titleNumber = 1 dPad = Controls.read() --Main Menu function mainMenu(titleNumber) if titleNumber == 1 then screen:blit(0,0,titlePlay) screen:flip() end if titleNumber == 2 then screen:blit(0,0,titleInfo) screen:flip() end if titleNumber == 3 then screen:blit(0,0,titleExit) screen:flip() end if titleNumber < 1 or titleNumber > 3 then screen:print(0,0,"error in titleNumber", white) screen:flip() end end --Main Menu D-Pad Controls if dPad:right then titleNumber = titleNumber + 1 mainMenu(titleNumber) end --I Dont Know while true do screen.waitVblankStart() end
-
04-19-2006, 10:58 AM #1698
- Registriert seit
- Aug 2005
- Beiträge
- 28
- Points
- 4.621
- Level
- 43
- Downloads
- 0
- Uploads
- 0
Disregaurd my question. I figured it out myself :icon_bigg .
-
04-19-2006, 12:43 PM #1699QJ Gamer Green
- Registriert seit
- Oct 2005
- Beiträge
- 543
- Points
- 6.721
- Level
- 53
- Downloads
- 0
- Uploads
- 0
Put everyting but the variable defines in the while true loop. Don't forget screen:clear()
Zitat von siqq
HELP ME HAIRY LEG!!!!
I have a 1.5 (downgraded) US PSP
[code]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( P | S | P | - | P | r | o | g | r | a | m | m | i | n | g )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_ _ _ _ _
/ \ / \ / \ / \ / \
( A | d | m | i | n )
\_/ \_/ \_/ \_/ \_/ [/code]
-
04-19-2006, 12:44 PM #1700
- Registriert seit
- Apr 2006
- Ort
- Bay Area, California
- Beiträge
- 26
- Points
- 4.133
- Level
- 40
- Downloads
- 0
- Uploads
- 0
testing...
[edit] It didnt work my code looks like this now.
Code:--Basic Variables white = Color.new(255,255,255) titlePlay = Image.load("titlePlay.png") titleInfo = Image.load("titleInfo.png") titleExit = Image.load("titleExit.png") titleNumber = 1 pad = Controls.read() while true do --Main Menu function mainMenu(titleNumber) if titleNumber == 1 then screen:clear() screen:blit(0,0,titlePlay) screen:flip() end if titleNumber == 2 then screen:clear() screen:blit(0,0,titleInfo) screen:flip() end if titleNumber == 3 then screen:clear() screen:blit(0,0,titleExit) screen:flip() end if titleNumber < 1 or titleNumber > 3 then screen:clear() screen:print(0,0,"error in titleNumber", white) screen:flip() end end --Main Menu D-Pad Controls if pad:right() and titleNumber < 3 then titleNumber = titleNumber + 1 mainMenu(titleNumber) end if pad:left() and titleNumber > 1 then titleNumber = titleNumber - 1 mainMenu(titleNumber) end endGeändert von siqq (04-19-2006 um 12:51 PM Uhr)
-
04-19-2006, 12:56 PM #1701QJ Gamer Green
- Registriert seit
- Oct 2005
- Beiträge
- 543
- Points
- 6.721
- Level
- 53
- Downloads
- 0
- Uploads
- 0
whats the error?
HELP ME HAIRY LEG!!!!
I have a 1.5 (downgraded) US PSP
[code]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( P | S | P | - | P | r | o | g | r | a | m | m | i | n | g )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_ _ _ _ _
/ \ / \ / \ / \ / \
( A | d | m | i | n )
\_/ \_/ \_/ \_/ \_/ [/code]
-
04-19-2006, 12:57 PM #1702
Hi guys. i just stared messing up with lua yesturday night
and i m starting to love this
I have a question though
To make the word blink again and again nonstop i have to copy screen.waitVblankStart(50 )Code:blue = Color.new(0 , 153, 255) screen.waitVblankStart(50) screen:print(200, 100, "Hello!", blue) screen.flip(0) screen.waitVblankStart(50) screen.flip(0) screen.waitVblankStart(50) screen.flip(0) screen.waitVblankStart(50) screen.flip(0) screen.waitVblankStart(50) screen.flip(0) screen.waitVblankStart(50) screen.flip(0) screen.waitVblankStart(50) screen.flip(0) while true do screen.waitVblankStart() end
screen.flip(0)
and make a long list ?? or is there is a code to make it repeat blinking for ever?
I also have some questions
there is a site that i got here from sam that have codes like this for an example but cant figure out
http://wiki.ps2dev.org/psp:lua_player:functions is the site
Code:Font Font:setCharSize(number width, number height, number dpiX, number dpiY)
where do i put the numbers ? please post an example with the numbers filled in so i can learnCode:image:clear([color = transparent-black])
Thanks!Geändert von natan333 (04-19-2006 um 01:09 PM Uhr)
Bequiet!!!
I'm learning cc©cc
-
04-19-2006, 01:09 PM #1703QJ Gamer Green
- Registriert seit
- Oct 2005
- Beiträge
- 543
- Points
- 6.721
- Level
- 53
- Downloads
- 0
- Uploads
- 0
That should work.Code:blue=Color.new(0,153,225) while true do screen:clear() for i=1,50 do if i=1 and blit=false then blit=true end if i=1 and blit=true then blit=false end if blit then screen:print(200, 100, "Hello!", blue) end end screen.flip() screen.waitVblankStart() end
HELP ME HAIRY LEG!!!!
I have a 1.5 (downgraded) US PSP
[code]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( P | S | P | - | P | r | o | g | r | a | m | m | i | n | g )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
_ _ _ _ _
/ \ / \ / \ / \ / \
( A | d | m | i | n )
\_/ \_/ \_/ \_/ \_/ [/code]
-
04-19-2006, 01:11 PM #1704
hmm the end and the spaces confuse me becuase i just started this
and the site that i put below explain what the codes do but i think it dosent have all the codes for me to learn
i will try to understandGeändert von natan333 (04-19-2006 um 01:14 PM Uhr)
Bequiet!!!
I'm learning cc©cc
-
04-19-2006, 01:13 PM #1705QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
im not exactly sure what your error was but after messing with it for a minute or two i got it to display the images when u move the dpad. im not sure if this is what u want however. Also I changed some of the picture names(the ones it loads not the variables) because i didnt have your pictures. I also have a background image added which is just a white picture
Zitat von siqq
Code:--Basic Variables white = Color.new(255,255,255) titlePlay = Image.load("Ball.png") titleInfo = Image.load("PlayerRight.png") titleExit = Image.load("PlayerLeft.png") titleNumber = 1 background = Image.load("background.PNG") function mainMenu() if titleNumber == 1 then screen:blit(0,0,titlePlay ) end if titleNumber == 2 then screen:blit(0,0,titleInfo ) end if titleNumber == 3 then screen:blit(0,0,titleExit ) end if titleNumber < 1 or titleNumber > 3 then screen:print(0,0,"error in titleNumber", white) end end while true do screen:clear() screen:blit(0, 0, background, false) pad = Controls.read() if pad:start() then break end --Main Menu D-Pad Controls if pad:right() and titleNumber < 3 then titleNumber = titleNumber + 1 mainMenu() end if pad:left() and titleNumber > 1 then titleNumber = titleNumber - 1 mainMenu() end screen.flip() end
-
04-19-2006, 01:14 PM #1706
- Registriert seit
- Apr 2006
- Ort
- Bay Area, California
- Beiträge
- 26
- Points
- 4.133
- Level
- 40
- Downloads
- 0
- Uploads
- 0
testing...
[edit]I think it will work BUT...
in lua player for windows how do you move the d pad? ive tried all arrows and pressed like every button but it does nothing. i thought it was the arrows but i guess not.[/edit]Geändert von siqq (04-19-2006 um 01:19 PM Uhr)
-
04-19-2006, 01:16 PM #1707
nathan42100 i tryed the code , dint work . the window shuts down after 0.5 seconds
Bequiet!!!
I'm learning cc©cc
-
04-19-2006, 01:20 PM #1708QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
i havent used lua player windows in a while but im pretty sure its the arrow keys. also the images will flash real7y quick
-
04-19-2006, 01:21 PM #1709
What does this code mean ?Code:for i=1,50 do if i=1 and blit=false then blit=true end if i=1 and blit=true then blit=false end if blit then
i think this is not correct becuase i deleted the spaces to no make me crazyBequiet!!!
I'm learning cc©cc
-
04-19-2006, 01:41 PM #1710
- Registriert seit
- Apr 2006
- Ort
- Bay Area, California
- Beiträge
- 26
- Points
- 4.133
- Level
- 40
- Downloads
- 0
- Uploads
- 0
why wont they stay?
Zitat von soadnation
[edit]and i dont think its working at all cause when i press start to break the program it does nothing as well[/edit]Geändert von siqq (04-19-2006 um 01:45 PM Uhr)


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