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; Yes, set a bool... Code: -- Note, I dont know LUAs syntax 100%, but I do understand the 'coding' --concept ...
-
08-03-2006, 02:45 AM #3091words 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
Yes, set a bool...
... SG57... out!Code:-- Note, I dont know LUAs syntax 100%, but I do understand the 'coding' --concept very well IMO, AKA LUA isnt C, so if you see C syntax, just ignore it ;) run = false while true do if run~=true then function_needed_to_run_once_here() run = true end end

...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-03-2006, 02:47 AM #3092QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok thanks. How did i not think of that
-
08-03-2006, 03:37 AM #3093words 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
'Your young and naieve...' lol, jk... Id be a hypicrit for such a thought ;)

...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-03-2006, 03:49 AM #3094QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
dont worry i am only 12 so yeah i am young
-
08-03-2006, 04:05 AM #3095words 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
I am only 14, and I get judged/treaed differently then the average... I want to say 16 ish coder... Most are around there Im assuming.

...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-03-2006, 04:46 AM #3096QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey is there a way to make the controls less sensitive because sometimes when you press x it goes straight through two scripts because the game thinks i pressed it twice
-
08-03-2006, 06:29 AM #3097sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
yeah add a
somewhere in you code. remember each number in that is a millisecond.Code:screen.waitVblankStart(10)
Also you could incorporate a timer, but thats the hard way ;)
-
08-03-2006, 06:43 AM #3098Developer

- Registriert seit
- Jun 2006
- Ort
- USA, Virginia
- Beiträge
- 580
- Points
- 5.650
- Level
- 48
- Downloads
- 0
- Uploads
- 0
i had this problem too , i put pad = oldpad in the function and it worked for me... i could be wrong so dont get mad if it dosent work out..
-= Double Post =-
is that even remotely right? check my above post.. sorry for the double post if it dosent merge it.Geändert von branin (08-03-2006 um 06:43 AM Uhr) Grund: Automerged Doublepost
-
08-03-2006, 07:30 AM #30996201ymereJ

- Registriert seit
- Jul 2005
- Ort
- Baltimore
- Beiträge
- 588
- Points
- 7.062
- Level
- 55
- Downloads
- 0
- Uploads
- 0
have it be
Zitat von mark.sparky
Code:if pad:cross and oldpad ~= pad then --your code end oldpad = pad
-
08-03-2006, 09:18 AM #3100QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok thnx
-
08-03-2006, 08:56 PM #3101
if anyone could i would like to know how to fix a problem with my fps cause it slows down when i blit a background and since i screen clear whenever the player moves or jumps it slows down with the background in but without it its perfect:Argh: please help.....thanks
-
08-03-2006, 09:58 PM #3102Developer

- Registriert seit
- Jun 2006
- Ort
- USA, Virginia
- Beiträge
- 580
- Points
- 5.650
- Level
- 48
- Downloads
- 0
- Uploads
- 0
@mark.sparky
Nice Game! Actually seeing how hard lua can be i have a differant outlook on LUA coders.. i know that took alot of work so... good job!
-
08-04-2006, 10:42 AM #3103QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 166
- Points
- 5.453
- Level
- 47
- Downloads
- 0
- Uploads
- 0
if someone could help me with a problem I'm having.
I'm trying to make a game, and have everything I need already done, except I need to be able to get the color of certain pixels as the game goes on.
I tried using
buit had to change it to screen:pixel, instead of image:pixel before it would do anything.Code:Color image:pixel(x, y)
what I want to know is, is it possible to get the r,g,b,a values out of the table made with that function and put the values into variables.
-
08-04-2006, 10:47 AM #3104words 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
How did you try to use it? That function right there returns a color strctured like:
Color.new(r,g,b)
So make a variable = image
ixel(x,y) If this isnt what u were saying, sorry but i didnt quite understand..

...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-04-2006, 10:50 AM #3105QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 166
- Points
- 5.453
- Level
- 47
- Downloads
- 0
- Uploads
- 0
edit- nvm I figured it out and fixed it.
but is it possible to extract the color values from a color?
for example can I extract the Blue value into a variable?Geändert von vettefan (08-04-2006 um 11:07 AM Uhr)
-
08-04-2006, 11:26 AM #3106words 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
Yes im sure it is... Id need to look at the pixel function in LUA players source though, as i may make it into a structure and easily extract the blue data from it...

...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-04-2006, 11:45 AM #3107QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 166
- Points
- 5.453
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I think I have something that does what I need it to.
thanks for the help though, I was getting something with the pixel colors wrong, now everything's fine :Jump:
-
08-04-2006, 11:52 AM #3108QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Hey what does this erorr mean. "<eof> expected near 'end'" .
Any help would be useful
-
08-04-2006, 11:55 AM #3109Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von mark.sparky
usually (for me) it means that u have an exta a "end" in ur code.
im not 100% sur tho.--------------------------------------------------------------------------------------
-
08-04-2006, 12:00 PM #3110QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
thnx. The code thought there was an extra end because i didnt declare the function
-
08-04-2006, 12:24 PM #3111Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
no prob.
Zitat von mark.sparky
BTW, is there any command that gives u how many sub-sets are in an array??
E.g.:
Code:bob = {} bob[1] = "joe" bob[2] = "zOMG" bob[3] = "can we build it??"
the array "bob" would have 3 sub-sets.--------------------------------------------------------------------------------------
-
08-04-2006, 12:27 PM #3112words 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
In C, the equivalent is the 'sizeof' operator...
VERY useful when allocating memory (for me, i need it alot for my 3d texture loading...)Code:char bob[3] = { 'S','G','5','7' }; int bob_size = (sizeof(bob));
So if ther eis a LUA equivalent, you got it ;)
...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-04-2006, 01:13 PM #3113Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
thx! ill reseach it.
Zitat von SG57
--------------------------------------------------------------------------------------
-
08-04-2006, 02:20 PM #3114
Anything wrong with this, I keep getting an error saying "no script found"
Code:-- Functions file = io.open("counter.txt", "r") counter = file:read("*n") file:close() selector = { image = Image.createEmpty(145,15), x = 147,y = 77 } selector.image:clear(blue) function drawMenu() screen:clear() pad = Controls.read() screen:blit(selector.x,selector.y,selector.image) screen:print(150,80,"Start Game (Black)",white) screen:print(150,100,"Start Game (Blue)",white) if pad:up() and oldpad:up() ~= pad:up() then selector.y = 77 startcolor = black local sound = menusound voice = sound:play() end if pad:down() and oldpad:down() ~= pad:down() then selector.y = 97 startcolor = blue local sound = menusound voice = sound:play() end if pad:cross() and oldpad:cross() ~= pad:cross() then gamestate = "game" counter = counter + 1 file = io.open("counter.txt","w") file:write(counter) file:close() end end function playGame() screen:clear(startcolor) pad = Controls.read() screen:print(100,100,"This program has been executed " .. counter .. " times.",white) screen:print(100,110,"Press Start to exit to Menu",white) if pad:start() then gamestate = "menu" local sound = goodbye voice = sound:play() end end -- Main Loop while true do if gamestate == "menu" then drawMenu() end if gamestate == "game" then playGame() end screen.flip() oldpad = pad end
-
08-04-2006, 02:45 PM #3115Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Shadox75
does it give a line number?? or it just could be that ur using windows luaplayer and u named ur script wonrg.--------------------------------------------------------------------------------------
-
08-04-2006, 03:54 PM #3116
I forgot to include some of the code.
It won't work.Code:-- Colors white = Color.new(255,255,255) blue = Color.new(0,0,255) black = Color.new(0,0,0) -- Variables oldpad = Control.read() startcolor = black gamestate = "menu" menusound = Sound.load("Sounds/beep.wav",false) goodbye = Sound.load("Sounds/goodbye.wav",false) -- Functions file = io.open("counter.txt", "r") counter = file:read("*n") file:close() selector = { image = Image.createEmpty(145,15), x = 147,y = 77 } selector.image:clear(blue) function drawMenu() screen:clear() pad = Controls.read() screen:blit(selector.x,selector.y,selector.image) screen:print(150,80,"Start Game (Black)",white) screen:print(150,100,"Start Game (Blue)",white) if pad:up() and oldpad:up() ~= pad:up() then selector.y = 77 startcolor = black local sound = menusound voice = sound:play() end if pad:down() and oldpad:down() ~= pad:down() then selector.y = 97 startcolor = blue local sound = menusound voice = sound:play() end if pad:cross() and oldpad:cross() ~= pad:cross() then gamestate = "game" counter = counter + 1 file = io.open("counter.txt","w") file:write(counter) file:close() end end function playGame() screen:clear(startcolor) pad = Controls.read() screen:print(100,100,"This program has been executed " .. counter .. " times.",white) screen:print(100,110,"Press Start to exit to Menu",white) if pad:start() then gamestate = "menu" local sound = goodbye voice = sound:play() end end -- Main Loop while true do if gamestate == "menu" then drawMenu() end if gamestate == "game" then playGame() end screen.flip() oldpad = pad end
It saysI am using LUA on my PSP.error: index.lua:7: attempt to index global 'Control' (a nil value)
ERROR: No script file found
-
08-04-2006, 04:00 PM #3117I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
At line 7 it's Controls.read() not Conrol.read(). You have to put the "s" in controls.
-= Double Post =-
Does anyone know of a way where if I hold down the UP/DOWN button, it scrolls fast, but if I just tap it, it scrolls one at a time. Like in the PSP's XMB.Geändert von Access_Denied (08-04-2006 um 04:00 PM Uhr) Grund: Automerged Doublepost

-
08-04-2006, 04:01 PM #3118QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 166
- Points
- 5.453
- Level
- 47
- Downloads
- 0
- Uploads
- 0
if your using lua player through eloader you may get no script found error.
that kept happening to me when I had to use eloader.
-
08-04-2006, 04:08 PM #3119
I was using 1.50, I got to it work.
-
08-04-2006, 07:30 PM #3120QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
@access_denied just try the following:
somtin like that should workCode:blue = Color.new(0,0,255) screen:clear() player = Image.createNew(5,5) -- i know it's sometin like that player:clear(blue) button = "no" time_held = 0 x = 240 y = 0 oldpad = pad while true do pad = controls.read() if time_held < 20 if pad:left() then time_held = time_held + 1 endif if pad:left() and oldpad:left() ~= pad:left() then x = x - 1 end end if oldpad:left() ~= pad:left() then time_held = 0 end if time_held > 19 then if pad:left() then x = x - 1 end end screen:blit(x,y,player) screen.flip() screen.waitVblankStart() oldpad = pad end
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been


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