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; Zitat von gameo I have it to make the loading a little serious... else you wont reach to see anything. ...
-
01-01-2007, 11:13 AM #4891
gosh
why do people put loading screens if nothing is being loaded????????
Zitat von gameo
-
01-01-2007, 11:33 AM #4892
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
look at the bold underlined and italic print. It just says scorefile but did you tell it what scorefile is?? (extension)
Zitat von Nicko01
-
01-01-2007, 12:25 PM #4893QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Does it need one?
my actual file has no extension...
now its called "scorefile.stupidsavedata filethatididntknowwhattoc allit"...
no, it didnt work.
-
01-01-2007, 12:27 PM #4894Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Cant you save it is a dat file or txt ? it should have some extension
-
01-01-2007, 12:34 PM #4895QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
I called it a .pie file.
is that bad?
.dat doesnt work either!!
it says "attempt to index global 'scorefile' (a nil value)
-
01-01-2007, 12:43 PM #4896
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Try this:
file = io.open(scorefile.txt, "w")
if that doest work try this:
scorefile = "scorefile.txt"
file = io.open(scorefile.txt, "w")
I'm not sure about the second one cuase in C U use characters i think this is how you do it in lua
-
01-01-2007, 12:44 PM #4897Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Try txt and see what happens EDIT psp freak beat me to it
-
01-01-2007, 12:54 PM #4898QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
now its saying
bad argument #1 to 'open' (string expected, got nil)
-
01-01-2007, 01:01 PM #4899
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
well is there anything in the file?? Since you have check to see..,.
-
01-01-2007, 01:08 PM #4900QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
file = io.open("scorefile.txt", "w")
Note the quotation marks round the string scorefile.txt.
-
01-01-2007, 01:09 PM #4901
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
oops ididnt see that
-
01-01-2007, 08:01 PM #4902.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
What would i edit in the luaplayer source code to gain flash0 writing access?
-
01-02-2007, 02:13 AM #4903Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Is that possible? If so then you would probaly just have to look for flash0 refresences. But it might be the psp thats not allowing the flash0 access not luaplayer. But then again wasnt that xmb pic editor in lua?
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-02-2007, 07:51 AM #4904Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Yongobongo
look at the PSPSDK samples for flash0 writing. and look at the luaplayer soruce to find out how to make your own functions. (you need to know atlest some C/C++)--------------------------------------------------------------------------------------
-
01-02-2007, 03:54 PM #4905QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
All right, I recently learned how to find the FPS of my game and it runs at 45 FPS at its fastest, and drops to a little less than 40 (about 37) when theres activity. (in my defense, theres quite a bit of activity. lol)
My question is: What are some 'rules of thumb', if any, to add some speed to your app/game?[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-02-2007, 04:33 PM #4906QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Optimization. If youd like you could post your code and I could look at it and show you some things you could do to optimize it.
-
01-02-2007, 05:34 PM #4907Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von EminentJonFrost
just some off the top of my head:
1. avoid more than 1 "while" loop.
2. avoid too many copies of one thing. (use functions instead)
3. use function arguments as much as you can.
umm.. i forgot some others. post your code, as it might help.--------------------------------------------------------------------------------------
-
01-02-2007, 06:46 PM #4908
umm how exactly do you find the fps of your game?
-
01-02-2007, 06:47 PM #4909QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Its a function with a few variables and stuff. Yaustar's snippet examples have it.
-
01-02-2007, 07:14 PM #4910QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
look at my post somewhere in the latest posts in the lua snippets thread. i posted there an example of how to get the FPS to show.
Zitat von emericaska8r
i dont want to actually post my game code up. (but some of the beans are gonna drop later in my post anyway...) so far, i've been using functions, and i only have one 'while true' loop in my game script. however, i have a main menu which then goes to the actual game via 'dofile("./fileName.lua")'.
would that slow the game down? (i think dofile is essentially a function but with the function being in another file)
aside from the game's speed, i'll bet there is a way to shorten this script of my extras. its for scrolling text up and down in a certain area in the 'extras' part of my game.
the code just seems so repetitive to me, it must be compressable. (<--that a word?)Code:--\\\\\\\\\\\\\\\\\\\\\\\\\\\ --Variable for scrolling list up and down --/////////////////////////// scrollY = 30 --\\\\\\\\\\\\\\\\\\\\\\\\\\\ --Main loop --/////////////////////////// while true do screen:clear(black) pad = Controls.read() if pad:start() then break end if pad:up() then if upPressed == false then scrollY = scrollY + 10 if scrollY > 30 then scrollY = 30 end upPressed = true end else upPressed = false end if pad:down() then if downPressed == false then scrollY = scrollY - 10 if scrollY < -210 then scrollY = -210 end downPressed = true end else downPressed = false end if a < 255 and b < 255 and c < 255 then a = a + 5 elseif a == 255 and b < 255 and c < 255 then b = b + 5 elseif a > 1 and b == 255 and c < 255 then a = a - 5 elseif a < 1 and b == 255 and c < 255 then c = c + 5 elseif a < 1 and b > 1 and c == 255 then b = b - 5 elseif a < 255 and b < 1 and c == 255 then a = a + 5 elseif a == 255 and b < 1 and c > 1 then c = c - 5 elseif a > 1 and b < 1 and c < 1 then a = a - 5 end color = Color.new(a, b, c) lineimg:clear(color) screen:drawLine(1, 1, 479, 1, color) screen:drawLine(1, 1, 1, 272, color) screen:drawLine(1, 272, 479, 272, color) screen:drawLine(479, 1, 479, 272, color) screen:fillRect(8, 28, 443, 111, gray) screen:fillRect(9, 29, 441, 109, black) screen:print(10, 10, "EXTRAS", color) screen:print(80, 10, "Coder: EminentJonFrost", color) --this is where i DESPERATELY need to find a way to shorten the code. it MUST be possible! if scrollY == 30 then screen:print(10, scrollY, "", color) end if scrollY <= 30 and scrollY >= 20 then screen:print(10, scrollY + 10, "", color) end if scrollY <= 30 and scrollY >= 10 then screen:print(10, scrollY + 20, "", color) end if scrollY <= 30 and scrollY >= 0 then screen:print(10, scrollY + 30, "", color) end if scrollY <= 30 and scrollY >= -10 then screen:print(10, scrollY + 40, "", color) end if scrollY <= 30 and scrollY >= -20 then screen:print(10, scrollY + 50, "", color) end if scrollY <= 30 and scrollY >= -30 then screen:print(10, scrollY + 60, "", color) end if scrollY <= 30 and scrollY >= -40 then screen:print(10, scrollY + 70, "", color) end if scrollY <= 30 and scrollY >= -50 then screen:print(10, scrollY + 80, "", color) end if scrollY <= 30 and scrollY >= -60 then screen:print(10, scrollY + 90, "", color) end if scrollY <= 30 and scrollY >= -70 then screen:print(10, scrollY + 100, "", color) end if scrollY <= 10 and scrollY >= -90 then screen:print(10, scrollY + 120, "", color) end if scrollY <= -10 and scrollY >= -110 then screen:print(10, scrollY + 140, "", color) end if scrollY <= -20 and scrollY >= -120 then screen:print(10, scrollY + 150, "", color) end if scrollY <= - 30 and scrollY >= -130 then screen:print(10, scrollY + 160, "", color) end if scrollY <= -50 and scrollY >= -150 then screen:print(10, scrollY + 180, "", color) end if scrollY <= -60 and scrollY >= -160 then screen:print(10, scrollY + 190, "", color) end if scrollY <= -70 and scrollY >= -170 then screen:print(10, scrollY + 200, "", color) end if scrollY <= -80 and scrollY >= -180 then screen:print(10, scrollY + 210, "", color) end if scrollY <= -90 and scrollY >= -190 then screen:print(10, scrollY + 220, "", color) end if scrollY <= -100 and scrollY >= -200 then screen:print(10, scrollY + 230 , "", color) end if scrollY <= -110 and scrollY >= -210 then screen:print(10, scrollY + 240, "", color) end if scrollY <= -120 and scrollY >= -220 then screen:print(10, scrollY + 250, "", color) end if scrollY <= -140 and scrollY >= -240 then screen:print(10, scrollY + 270, "", color) end if scrollY <= -150 and scrollY >= -250 then screen:print(10, scrollY + 280, "", color) end if scrollY <= -160 and scrollY >= -260 then screen:print(10, scrollY + 290, "", color) end if scrollY <= -170 and scrollY >= -270 then screen:print(10, scrollY + 300, "", color) end if scrollY <= -180 and scrollY >= -280 then screen:print(10, scrollY + 310, "", color) end if scrollY <= -190 and scrollY >= -290 then screen:print(10, scrollY + 320, "", color) end if scrollY <= -210 and scrollY >= -310 then screen:print(10, scrollY + 340, "", color) end screen:print(10, 190, "Controls for Extras:", color) screen:print(10, 210, "Up to scroll up", color) screen:print(10, 220, "Down to scroll down", color) screen:print(10, 230, "Start to go back to menu", color) screen.flip() screen.waitVblankStart() end
Geändert von EminentJonFrost (01-03-2007 um 07:19 AM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-02-2007, 09:37 PM #4911.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Crappity crap
Zitat von Grimfate126
I know nothing about C/C++
Help?
Also, would it be possible for me to make a function in luaplayer with the source to copy a file to flash0?
-
01-03-2007, 12:29 AM #4912words 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
Hmmm... I actually may do that... Ill make an unofficial Lua Player vX.1 that will have flashing capabilities... I just got a Wii though, so Ill develope it in my spare spare time ;)

...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
-
01-03-2007, 01:28 AM #4913.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Awesome :) I <3 wii...Not wee, wii
-
01-03-2007, 10:12 AM #4914Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Is the wii really good or is zelda basically the wii's finest and nothing else? if so then ill stick with project64 lol. Anyways what place can i got to to find lua player functions for the psp
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-03-2007, 11:31 AM #4915QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
You can find lua functions here GG:
http://wiki.ps2dev.org/psp:lua_player
Back on my issue with FPS and code efficiency, I just discovered what a difference the CPU speed makes! (better late than never) i ran my game with IR Shell at cpu speed 222, and i got an FPS in the range of 37-44, then i put up the speed to 333 so i could listen to music while working, without problems. then the FPS shot past 60! at its best, it goes to a little past 70!
so just a note to other lua devs: merely putting up CPU speed should result in faster performance. i dont know why i find this out now 1 year and a quarter later...i guess i still fit in the 'noob' profile...lol
now i use cool's (aka Sphinx, Spirax) mod of luaplayer. it has a special function which allows to set the cpu speed. its mod 2 in the QJ downloads area just sos you know. ok, just thought i should post that up for future reference! :)[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-03-2007, 12:15 PM #4916lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I hvae been using the CPU speed functions for awhile and they really give your game a boost.
Zitat von EminentJonFrost
-
01-03-2007, 12:19 PM #4917QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
no kidding! my game doubled in speed. but i also did some code optimization, which cut my script's size to roughly half. (again, i fit the noob profile well..lol) but im getting better! i guarantee my first GAME release will turn heads! (see how long i've been a member here? i know what most first releases look like, mine will not follow suit)
Zitat von pspgamer81
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-03-2007, 01:29 PM #4918words 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
Funny... My game is doing swell at 222 (~60 FPS) and it just needs some enemies AI implemented for a complete side-scrolling beat em' up... But I have a Wii now... So all coding is in spare spare time...

...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
-
01-03-2007, 02:28 PM #4919Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von EminentJonFrost
just a warning. CPU does indeed give a good boost, but dont rely on it. i do all my C/C++/lua projects at 222 first, and if they are playable, then i up the CPU to 333.
using the CPu is good, but it wont do you good if you rely too much on it.
(just a warning)
@SG57, shouldnt studies be first, Programming 2nd, and Wii in your spare time? lol, jk.
P.S. IM GETTING A PS3 NEXT MOTH!--------------------------------------------------------------------------------------
-
01-03-2007, 04:12 PM #4920QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yea speeding up the cpu to run your game faster is a crutch. You need to optimize it to get it to run well without having to use 333mhz.


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