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; I'm not (Well, not in any recent programs), I've just seen it used in a few examples, and was curious ...
-
06-06-2008, 06:42 AM #8701QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
I'm not (Well, not in any recent programs), I've just seen it used in a few examples, and was curious is all. Thanks.
-
06-09-2008, 10:47 AM #8702Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I just need an quick explaintion of what this does cause it don't have an clue
i don't understand this, and have never used this functionCode:colour = col:pixel(mar.x + 2, mar.y + 15)
-
06-09-2008, 01:00 PM #8703QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
someimagename
ixel(x,y) returns the color of the pixel at the x,y coordinates in the image someimagename
someimagename
ixel(x,y,color) sets the pixel in the image someimagename at coordinates x,y to the color color
-
06-11-2008, 05:01 AM #8704QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
What's wrong with my code?
My menu works perfectly without this, so everything is configured alright.--if currentlySelectedLineNumb er = 1 and pad:cross() then
--Code goes here
--end
--if currentlySelectedLineNumb er = 2 and pad:cross() then
--Code goes here
--end
if currentlySelectedLineNumb er = 3 and pad:cross() then
break
end
This is the error I get:
'then' expected near '='
-
06-11-2008, 05:12 AM #8705QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
when comparing one number to the other use ==
when setting one value equal to another use =
therefore in an if clause, you must use if somevariablename == somenumber, not =
also tonight ill be able to help you more on msn
-
06-11-2008, 05:52 AM #8706QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
-
06-11-2008, 06:40 AM #8707Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Would something like this world work?
Because i've used dofile ( experimenting ) with this but every time i use oldx, oldy it never works :?Code:colour = col:pixel(mar.x + 2, mar.y + 15) if colour = red then mario.x = oldx end if colour = blue then mario.y = oldy end
-
06-11-2008, 02:39 PM #8708QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
again, if colour ==, not =. Also, I assume you have red and blue declared as Color.new(255,0,0) and Color.new(0,0,255)
-
06-13-2008, 11:19 AM #8709QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
Aww me and my problems...
I try to use danzeff osk, and it either writes in black, or not at all.
This is my code:
Of course I got the color white installed, and here are a few other lines:screen
rint(5,5,typingstring, white)
keyboard.process(2,105,pa d,oldpad)
typingstring = keyboard.typeToString(typ ingstring)
dofile("keybd.lua")I don't get any error, but when I use the OSK it doesn't write.typingstring = ""
displaykeyboard = true
(which means all the variables are ok and the code is stable, which is why I didn't gave u the whole code).
I will soon check if it writes in black (screen:clear(white)).
Oh and penguin I haven't worked on it since we talked coz I ****ed up my leg... which is why I have to ask here
-
06-13-2008, 11:36 AM #8710Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
make sure typingstring is above while true do
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
06-13-2008, 11:41 AM #8711QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
of course it's above.
but it's in the main loop, the loop of the menu.
Maybe I should put it in the loop of the certain part?
(above while true do)
-
06-13-2008, 01:02 PM #8712QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
No, I tried changing background color to white, and moving the variables to that certain loop.
-
06-13-2008, 02:40 PM #8713Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
06-14-2008, 12:43 AM #8714QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Yeah, using a '==' verifies something (sees if it is true), whereas '=' changes the variable to, in this case, 1. I'm not sure if it works in Lua, but using '!==' checks to see if something is not true:
Or, you could do:Code:if whatever !== 0 then whatever = 0 end
You see? :)Code:if whatever == 1 then whatever = 0 end
-
06-14-2008, 12:57 AM #8715words 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
Moose_Island - your explanation is worded somewhat awkward, and wrong about the 'not equal' operator.
The '=' symbol alone is used to assign the preceding variable with the following value where the '==' symbol is used to compare the preceding and following variables if they are true (of the same data type), returning true or false respectively.
With C's syntax, the != operator is the same as saying 'not equal'. In Lua the ~= operator is the equivalent of != in C.
...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
-
06-14-2008, 02:59 AM #8716QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
Hey I write this again, because it got lost in those 872 pages.
What's wrong with my code?
My menu works perfectly without this, so everything is configured alright.Code:--if currentlySelectedLineNumb er = 1 and pad:cross() then --Code goes here --end --if currentlySelectedLineNumb er = 2 and pad:cross() then --Code goes here --end if currentlySelectedLineNumb er = 3 and pad:cross() then break end
This is the error I get:
'then' expected near '='Geändert von Moose (06-14-2008 um 03:24 AM Uhr)
-
06-14-2008, 03:58 AM #8717QJ Gamer Bronze
- Registriert seit
- Mar 2007
- Beiträge
- 758
- Points
- 8.665
- Level
- 62
- Downloads
- 0
- Uploads
- 0
It's "==" instead of "=".
-
06-14-2008, 04:12 AM #8718Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
michaelp is right thats the promblem, basically what the first posts on this page is about
lol
look at the other posts above yours.
Also does Mp3me.eos() work???
cause i try to say
Code:if the end of song (Mp3me.eos() ) is true (it uses true/false to determine ) then --whatever end
-
06-14-2008, 04:50 AM #8719words 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
Still dan?
Make sure you are constantly polling, a song is loaded into mp3me and '--whatever' is actual code that will somehow signify the if clause is true.
...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
-
06-14-2008, 06:22 AM #8720Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
06-14-2008, 07:00 AM #8721QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
LuaplayerHM is retarded and returns strings: "true" and "false"
-
06-14-2008, 07:40 AM #8722Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
so would i pu this instead
Code:if Mp3me.eos() == true then screen:clear() screen:print(10,10,"Song Finished",white) end
-
06-14-2008, 08:36 AM #8723QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
-
06-14-2008, 09:53 AM #8724Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
06-14-2008, 01:30 PM #8725words 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've looked at the source and it's because he doesn't know how to return a boolean embarrassingly enough (for the record, with every 'me' release, that luaplayer is getting slower and bigger meaning slower and bigger games if any)

...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
-
06-14-2008, 11:38 PM #8726QJ Gamer Silver

- Registriert seit
- Sep 2007
- Ort
- AUS
- Beiträge
- 284
- Points
- 12.501
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Geändert von Moose (06-15-2008 um 12:18 AM Uhr) Grund: Double Post Merge
Wyvern. That is all
-
06-15-2008, 03:01 AM #8727QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
First of all thanks HomeMister for the quick help.
Now, I got this interesting issue:
[QUOTE]screen
rint(5,20,"You should take in "..(typingstring*2.1) .." grams of protein each day", white)[/QUOTE
I got an osk installed and everything.
Now, the only way this line will work, is to configure typingstring as a number.
I did this:
typingstring = "0"
Now it works, but the users gotta delete the 0 before they start to write their own number.
(if I set typingstring = "" then the value wouldn't be a number).
Is there any way that the users can start writing from nothing?
instead of having to delete my number before?
(If I set the intial value of typingstring to nothing, then it's not a number and the luaplayer crashes).
-
06-15-2008, 04:12 AM #8728Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
just put
and then to convert it to a number useCode:typingstring = ""
p.s. use code tagsCode:number_choice = tonumber(typingstring)
[code]
Code:and then the second has a / before the word code [ /-Here code]
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
06-15-2008, 04:27 AM #8729QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
-
06-15-2008, 04:32 AM #8730Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
omg this thing is stupid it wont let you edit posts and it always posts the same thing twice meh arg grr
put it where you need the number, i take it that you want the user to enter a number well
is the number it will convert the data from the osk into a numberCode:number_choice = tonumber(typingstring)
Geändert von Moose (06-15-2008 um 04:34 AM Uhr) Grund: Added [code] tags.
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).


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