Zeige Ergebnis 8.401 bis 8.430 von 10238
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; Judas is right. It is already in write mode....
-
03-14-2008, 01:45 PM #8401Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Judas is right. It is already in write mode.
-
03-14-2008, 05:47 PM #8402Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
ok i need some help with reading and writing files, so far i have got it to write out the player's X andY values and read it but nothing else, how would u do it so that when i come out of a pause screen it will read that file and using those X and Y values???
instead off starting again.
-
03-16-2008, 12:30 PM #8403Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
writing:
reading:Code:file_variable = io.open(filepath) file_variable:write("x = " .. x_coordinate) file_variable:write("x = " .. x_coordinate) file_variable:close()
untested but looks like it will work to meCode:dofile(filepath) x_coordinate = x y_coordinate = y
------ 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).
-
03-16-2008, 09:56 PM #8404QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Having to write variables to a file is a clear sign of bad program structure. You can go on and do what FatBoy suggests, but I am warning you, it is considered bad practice. You should rather consider re-organizing your program (Use some kind of state system).
Zitat von dan369
-
03-17-2008, 01:17 AM #8405
- Registriert seit
- Mar 2008
- Beiträge
- 37
- Points
- 2.816
- Level
- 32
- Downloads
- 0
- Uploads
- 0
is there a command to shutdown or standby?
thanks in advance.
-
03-17-2008, 06:40 AM #8406Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
he asked how using files so i answered i dint say it was ant good, i do agree with you and to do it a better way you could set some more variables up that hold the x and y values while you change the state or, set up a second state system, which is the best way for a pause menu or inventory, so you would have something like ss1.a ss1.b ss1.c where ss.b is your game or something and set up another state system inside of that like this ss1.a ss1.b ss2.a ss2.b ss1.c where ss2.a is the game and ss2.b is the pause menu or inventory, this way any data held in the main state system is kept while entering the second level state system
Zitat von Nielkie
------ 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).
-
03-17-2008, 09:11 AM #8407Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
i have got state's!!!
good idea but how would u store the players X and Y ???
would u use something like an btw my variable is Link.x and .y
i use this
Code:Link.x = oldx Link.y = oldy
-
03-17-2008, 09:21 AM #8408Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
I dont see what that achieves.
-
03-17-2008, 09:22 AM #8409Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
to make it easy you can use two state tables one inside another state, so you have your main file with all of your states and stuff in
Zitat von dan369
e.g.
Code:if game_state == state.game then -- -*- link.x = ? link.y = ? state_table_for_in_game = { in_game = 1, in_pause = 2} in_game_state = state_table_for_in_game.in_game if in_game_state == state_table_for_in_game.in_game then -- whatever the controlls and screen display for the game is if pad:up() then link.y = link.y - 1 end -- and so on -- this will change the link.x and link.y outside of the states -*- if pad:start() then in_game_state = state_table_for_in_game.in_pause end elseif in_game_state == state_table_for_in_game.in_pause then -- whatever you have in your pause if pad:start() then in_game_state = state_table_for_in_game.in_game end -- when you retun to the game the x and y should stay end endkeeping link in his correct x and y positions after the game has been paused
Zitat von eldiablov
------ 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).
-
03-17-2008, 11:22 AM #8410Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
ok i'm on my ps3 using an wirless keyboard!!!!
so i have states like this:
like that i've tried writing files to hold the players x and y values in my case Link.x and .yCode:state = "Game" state = "Credits" state = "Inventory"
i also have a statement that holds the players x and y values and stores them into an variable that holds them during collisions etc.
like this
like that it stores it's previous x and y postition useful for collisions like i said, anyway the game starts and you have to press START to load the Inventory screenCode:Link.x = oldx Link.y = oldy
so then when i exit it will load the file which is the first level but of course it has the same starting postition so it would start from where u began!!!
I would like to know how to make the store the player's X and Y values and when you want to return from the Inventory menu and the place where u pressed start that would be where u would be placed when you exit the Inventory screen????????????????
-
03-17-2008, 12:03 PM #8411
do you loose state all the time that you need to save variables like that? I'm not sure why you would loose the interpreter state, but I dont use luaplayer, i just embed my own modified lua interpreter (no doubles/floats for speed, and other patches).
if they are global vars, you should be ok, unless your code is really bad and you clobber your global vars in functions that shouldnt be touching them... (this is why local exists!)..
you could always do state inside lua's _G[] table.
I assume your doing loadfile/loadstring/dofile etc.. but I dont see why lua player would be killing your lua_State* that you need to write out links x/y position..
something very wrong here if you need to be doing that just to show a pause screen.
also since you've limited memory (its a good practice) to not use strings if you dont really need to, you could define state modes as; even tho the global string table holds only 1 copy of a string.. waste not want not.
state_Game = 1
state_Credits = 2
state_Inventory = 3
state = state_Game
something sounds totally wrong with your code based on your above statements.... or you are correct and my knowledge of lua is wrong in its implementation in luaplayer...-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
03-17-2008, 12:29 PM #8412Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
as i said you need states inside states and it is not good practice to use dofiles that is why people like me created state snippets so you dont have to, and files dont have to be loaded
so now to tell you what i said before
you need to have a main state system
containing
game
credits
and inside the game state of the fist state system you need another
containing
main_game
inventory
then it will be set out something like this
- game
-- main_game
-- inventory
- credits
which is what my example before showed
then the variables for links x and y positions need to be inside the first state system under game but outside of the other state system, like so
- game
- links x and y variables
-- main_game
-- inventory
- credits
this way when you enter game you have links x and y co ordinates
when you enter main_game you also have links x and y co ordinates
and finally when you enter inventory you have links x and y co ordinates
now seen as you should only be changing links x and y co ordinates inside main_game if you swap to and from inventory the x and y co ordinates will be kept and when you actually do exit from the inventory link will be in the same position at the same point in the game
if you still dont understand it will be because of one or more of these three reasons
1. you are relatively new to coding
2. the structure of your game is just plain bad
3. you do not understand how states work properly------ 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).
-
03-17-2008, 12:45 PM #8413Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
so i have to do some IF statements????
i am relatively new
all i would link to know is how to store Link's X and Y when START is pressed then use the numbers given to be used AS the players X and Y???
-
03-17-2008, 01:24 PM #8414Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
out side of all game states above while true do make two new variables,
link_x_store = 0
link_y_store = 0
then inside the state that you swap to, save them to that
so when in the game state
if pad:start() then
link_x_store = link.x
link_y_store = link.y
-- swap state to inventory state
end
-- inside inventory state
if pad:start() then
-- swap to game state
link.x = link_x_store
link.y = link_y_store
end------ 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).
-
03-17-2008, 02:46 PM #8415Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
i understand
thanks 4 being patient with me i do understand it now
-
03-24-2008, 10:06 AM #8416Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Rotating a 2d image using the gu ? Is it possible?
-
03-24-2008, 01:14 PM #8417QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Check out this:
http://www.forums.evilmana.com/index.php?topic=676.0
Haven't tried it, but looks good enough.
-
03-24-2008, 11:00 PM #8418
- Registriert seit
- Sep 2007
- Beiträge
- 21
- Points
- 3.007
- Level
- 33
- Downloads
- 0
- Uploads
- 0
Hi to all, I am using LUA for this homebrew. Im trying to play music on a homebrew game so I am using this command:
Music.playFile(”music.it” , true), the music file is 12.5 MB in size, so when I try to load the game calling the music the PSP shows the MS light then it stops and hangs and then turns off the PSP. How do I add some music to the homebrew?
Thanks to all in advance!
-
03-25-2008, 12:43 AM #8419words 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
JOY - you don't think 12.5mb worth of compressed music + anyother of your resources could maybe exceed the 24mb RAM limit? (especially in Lua as it takes away atleast 3mb of RAM alone...)

...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
-
03-25-2008, 11:42 AM #8420
- Registriert seit
- Sep 2007
- Beiträge
- 21
- Points
- 3.007
- Level
- 33
- Downloads
- 0
- Uploads
- 0
Ok, well I got it to be 1.57 MB in size but still cant find the way to make the music play
.
Ok, is there a limit in size for the music files? I still get the same hang on the PSP.
-
03-25-2008, 12:58 PM #8421Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
1. .wav files are better
2. it needs a low kbps rate and bit rate to work
3. if you send me a copy in .wav form ill convert it 4 u
if it still doesn't work it is because the file is still too big, or is corrupted or something else that we dont know the reason for------ 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).
-
03-31-2008, 03:11 PM #8422
- Registriert seit
- Sep 2007
- Beiträge
- 31
- Points
- 3.194
- Level
- 34
- Downloads
- 0
- Uploads
- 0
how do i run an eboot.pbp file??? i've used luaplayer HM but nothing happens! plz help
-
04-01-2008, 11:07 AM #8423Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
because of the kernel the function used has some problems loading eboot files, its trying to be fixed
Zitat von nickdagamer
------ 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).
-
04-01-2008, 01:35 PM #8424
- Registriert seit
- Sep 2007
- Beiträge
- 31
- Points
- 3.194
- Level
- 34
- Downloads
- 0
- Uploads
- 0
oh ok! i hope it is fixed quickly!
-
04-01-2008, 11:33 PM #8425
help me please ^^
Nielkie-san help me no need for this post :P
Geändert von matsuda (04-02-2008 um 02:33 PM Uhr)
-
04-02-2008, 02:43 AM #8426QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Short answer: You need to use "==" instead of "=". "=" sets a value, while "==" reads a value. You are also assigning your page values as both a image and a booleen.
Long answer: You need to change your coding style. Use indenting and tables, and do not repeat code. Here is what I think your code should look more like:
Code:--learn japanese white = Color.new(255,255,255) graphics = {} graphics.page = {Image.load("images/lesson1/page1.png"), Image.load("images/lesson1/page2.png"), Image.load("images/lesson1/page3.png"), Image.load("images/lesson1/page4.png"), Image.load("images/lesson1/page5.png"), Image.load("images/lesson1/page6.png"), etc...} graphics.menu = Image.load("images/menu.png") graphics.lesson1menu = Image.load("images/lesson1menu.png") graphics.lessoncomplete = Image.load("images/lessoncompletedefault.png ") states = {} states.page = {} states.page.n = 1 states.menuon = true states.lessondone = false while true do screen:clear(white) pad = Controls.read() if states.menuon then if pad:cross() and states.menuon then screen:clear(white) states.menuon = false end elseif states.lessondone then if pad:cross() then dofile quiz1.lua() end if pad:circle() then dofile menu.lua() end else if pad:r() then screen:clear(white) states.page.n = states.page.n + 1 end if pad:l() then screen:clear(white) states.page.n = app.states.page.n - 1 end if states.page.n < 1 then states.page.n = 1 elseif states.page.n > table.getn(graphics.page) then states.page.n = table.getn(graphics.page) end screen:blit(0,0,graphics.page[states.page.n]) end screen:blit(0,0,graphics.menu) screen:blit(183,88,graphics.lesson1menu) screen.waitVblankStart() screen.flip() endGeändert von Nielkie (04-02-2008 um 09:56 PM Uhr)
-
04-02-2008, 03:35 AM #8427
thank you so much
thank you very much Nielkie-san! i am very glad you helped me.
I have learned more functions thanks to you! This style is much cleaner. thank you!
-
04-02-2008, 09:55 PM #8428QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
No problem, if you want to know more (e.g. functions, usage, etc) There are some great resources around.
For Library definitions, I greatly recommend http://lua-users.org/wiki/TutorialDirectory
-
04-02-2008, 11:18 PM #8429words 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
Just throwing this out there - Nielkie - '==' doesn't 'read' a value, it's a comparing operator ;)

...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
-
04-03-2008, 01:48 PM #8430
hey everyone, i am working on a lua project, and i would like to add support to play mp3 music from the memorystick, i do not know how to do this, can i get some help, also which version of lua player hm will i need


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