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; OKay I wrote this code so when you press X you throw something. But I have to hold X for ...
-
06-16-2006, 10:19 AM #2671Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
OKay I wrote this code so when you press X you throw something. But I have to hold X for it to travel across the screen. What would I put in the code?
Code:if pad:cross() then if z == 2 then poox = poox + poospeed elseif z == 1 then poox = poox - poospeed end screen:blit(poox, pooy, poo) if poox >= 480 then poox = player.x pooy = player.y + 12 elseif poox <= 0 then poox = player.x pooy = player.y + 12 end end

--XBL Gamertag: PhenoM904--
-
06-16-2006, 04:37 PM #2672QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Dark_Alex Command Center
- Beiträge
- 597
- Points
- 5.866
- Level
- 49
- Downloads
- 0
- Uploads
- 0
I am having trouble using \n (newline) option with lua 0.16 and .20. here is my code...
--Readfile config file, print
--
red = Color.new(255, 0 , 0)
black= Color.new(0,0,0)
white= Color.new(255,255,255)
blue= Color.new(0,0,255)
grey= Color.new(192,192,192)
file = io.open("TODO", "r")
if file then
screen:clear(white)
screen
rint(140,126,"File Found")
screen.flip()
System.sleep(2000)
screen:clear(white)
for line in file:lines() do
screen
rint(10,10,line .. "\n")
screen.flip()
end
end
else
screen:clear(black)
screen
rint(140,100,"file Don`t Exist!",red)
screen.flip()
end
---------------------------------
What i want it to do is print the textfile to screen which it does but it only prints one line and goes off screen i want to use \n newline option but it doesn't seem to work for me. Instead of newline i get a wierd circle symbol. I am also using ttlde2.0 to edit and run my lua scripts if that helps.
Thanks for any help[FONT=Fixedsys][spoiler="PSP DAX_Hacks"]PSP1001 3.71-M33-4 ------------------------------------------
- 17 Diff Castlevania Games on 4Gb Stick Cps2psp2.30 - MVSpsp[/FONT][FONT=Fixedsys]2.30[/FONT][FONT=Fixedsys] + Bootlegs - gpSP09 - PsUltraRip - Manhunt2 Uncensored
[/spoiler] [/FONT][FONT=Fixedsys]Consoles Pwnd: PSP, Xbox360
Pwnd: PSP, PSOne, PS2, Xbox360
[/FONT]
-
06-17-2006, 12:19 AM #2673Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von MaSt3r_ShAk3
try this:
THEN put:Code:if pad:cross() and oldpad:cross() ~= pad:cross() then if poofire == false then poofire = true elseif poofire == true then poofire = true end
youll have to put in oldpad statements tho.Code:if poofire == true then if z == 2 then poox = poox + poospeed elseif z == 1 then poox = poox - poospeed end screen:blit(poox, pooy, poo) if poox >= 480 then poox = player.x pooy = player.y + 12 elseif poox <= 0 then poox = player.x pooy = player.y + 12 end end--------------------------------------------------------------------------------------
-
06-17-2006, 12:24 AM #2674is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
i am having the same problem as mstrhelix if anyone could help
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
06-17-2006, 01:54 AM #2675Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i could try, i guess.
Zitat von Glynnder- PSPro
--------------------------------------------------------------------------------------
-
06-17-2006, 03:55 AM #2676
You cant use it to go to a next line on the screen, because it doesnt know what a return is. It works when you write to a file.
For the screen you have to have a variable for the y coordinate and add 8 to it for every new line.
BTW Grimfate why do you post that you will try, what help is that?LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
06-17-2006, 05:11 AM #2677
or to solve the throwing problem you could just use a loop like:
Code:if pad:cross() then while true do poox = poox + speed if poox > 480 then throw = false end else screen:blit(poo) end
-
06-17-2006, 05:18 AM #2678is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
well pplease can u help? that would help lol!
Also, i get what u mean with the variable thing...What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
06-17-2006, 05:45 AM #2679Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von emericaska8r
that would work, but you cant have too many loops.
@ gynnder -PSPro, i need your code.--------------------------------------------------------------------------------------
-
06-17-2006, 06:42 AM #2680Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
OK thanks, how do i use it in screen:blit() then?
Zitat von Altair
--Vaza
-
06-17-2006, 07:39 AM #2681is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
kk, i'll try and give it to you, its gonna be simple cos its part of something huge!
Also, why aint this a sticky anymore?What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
06-17-2006, 07:46 AM #2682Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Yea I dunno why its not a sticky. Its harder to find.
-
06-17-2006, 08:00 AM #2683QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
I got two questons
1.
Can any one help me I want my program to Save a irda signal to a variable on a botton press while selecting an object on a menu.
This is what I have so far:
2.Code:if pad:circle() and menustatus == -1 then irdasignal = System.irdaRead() end
when I hit left or right my pic. doesnt move but when I hit up or down it moves .
Code:red = Color.new(255, 0, 0); white = Color.new(255, 255, 255); char = Image.load("char.png") y = 100 x = 100 while true do screen:clear() -- read current pad pad = Controls.read() if pad:up() then y = y - 1 elseif pad:down() then y = y + 1 elseif pad:left() then X = x - 1 elseif pad:right() then X = x + 1 end screen:blit(x, y, char, 0, 0, char:width(), char:height(), true) screen.flip() screen.waitVblankStart() if pad:start() then break end end
-
06-17-2006, 11:25 AM #2684Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
1. I dont use IRDA so i don know
Zitat von zmathue
2.
Code:red = Color.new(255, 0, 0); white = Color.new(255, 255, 255); char = Image.load("char.png") y = 100 x = 100 while true do screen:clear() -- read current pad pad = Controls.read() if pad:up() then y = y - 1 elseif pad:down() then y = y + 1 elseif pad:left() then X = x - 1 elseif pad:right() then X = x + 1 --Caps lock on for first X but not on for 2nd X, same with Pad:left(). end screen:blit(x, y, char, 0, 0, char:width(), char:height(), true) screen.flip() screen.waitVblankStart() if pad:start() then break end end
-
06-17-2006, 11:55 AM #2685
for the ir signal, my only advice would be to look at the ir source code of the program that is bundled into lua player when u get it.
-
06-17-2006, 12:16 PM #2686QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
um all that does is store it to the variable for like a second then the variable is replaced with null or another empty data.
-
06-17-2006, 01:28 PM #2687
Whar is the Analog configuration how do i use it EX:
if nub:up() then ...Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
06-17-2006, 01:57 PM #2688Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
i think its:
Zitat von ZereoX
if pad:analog() >/</~=/== [number in degrees] then
ex.
if pad:analog() > 45 then
screen
rint(10, 10, "Test", red)
end
This means that if the Analog is at a angle that is greater than 45 Degrees then the text will print.
--Vaza
-
06-17-2006, 02:04 PM #2689
Thanks Vaza... That help me alot too!
(Off subject) haha... it won't let you post screen: print!
-
06-18-2006, 04:14 AM #2690<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
what sound files does lua player surrport>
is it just mod an wav,, or is there anything else
-
06-18-2006, 04:24 AM #2691Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
The Mod family and WAV.
Zitat von Sousanator
Mod Family consists of Mod, XM, IT, S3M and many more.
--Vaza
-
06-18-2006, 04:48 AM #2692<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
thanks,,
but when i convert a mid to an xm, or it,, it wont play right,, is that normal,
-
06-18-2006, 09:58 AM #2693is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
errr, didn't think so...
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
06-18-2006, 10:51 AM #2694<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
i just did a whole bunck of checks,,
turns out im processing too much at the same time,, cause the music to be chuncky,,
anyway to avoid that(on pc, it sounds nice)
and what is the proper way to exit your game from lua player,,
since break, just breaks the loop,, (and music continues and such)
-
06-18-2006, 11:15 AM #2695
Zitat von Sousanator
yes i hate it when i quit a game and the music is still playing from it.
-
06-18-2006, 01:31 PM #2696QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
well you got to kill the music playing before you exit.
-
06-18-2006, 01:33 PM #2697sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
anyone good with AI? i have a game with AI but it wont load
-
06-18-2006, 03:10 PM #2698
Anyone has a good and easy wait to make a scrolling map where you can move a guy.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
06-18-2006, 04:29 PM #2699<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
but even if you do that, the game still continues to run in the bgwell you got to kill the music playing before you exit.
-
06-19-2006, 01:25 AM #2700
It does say so, but if you think about it, you do exit the game loop so it isn't running anymore. I don't know why its saying it is.
@Vaza
transparency:
This will create a square of width and height, ay x and y, that has a half-transparant red color. The boldfaced 128 is why its half-transparant. 255 would mean fully transparant and 0 not transparant. Also you have to put true in screen:blit so it knows there are transparant pixels in the image.Code:redTrans=Color.new(255, 0, 0, 128) transparantPic=Image.createEmpty(width, height) transparantPic:clear(redTrans) screen:blit(x,y,image,0,0,width,height,true)
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]


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