Zeige Ergebnis 3.001 bis 3.030 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; thanks again. this is my last post here for awhile , i promise....
-
07-27-2006, 02:05 PM #3001Developer

- Registriert seit
- Jun 2006
- Ort
- USA, Virginia
- Beiträge
- 580
- Points
- 5.650
- Level
- 48
- Downloads
- 0
- Uploads
- 0
thanks again. this is my last post here for awhile , i promise.
-
07-27-2006, 06:44 PM #3002QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
hey ever1 i got a question=-)
how do you load in music:
Music.playFile( string file, bool loop )
is the function that i got from the lua functions list on their website
so thus i tried:
music1 = Music.playFile("music1.it ")
i'm not sure what to put for bool loop o and get the following error in lua windows:
LuaPlayer's Mikmod has a critical error:
_mm_critical 1
_mm_errno 1
Cannot open requested file
6 [unknown (0xFFC)] luaplayer 2852 handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
106850 [unknown (0xFFC)] luaplayer 2852 open_stackdumpfile: Dumping stack trace to luaplayer.exe.st
ackdump
i'd like a reply asap and thanks in advance1. 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
-
07-27-2006, 07:42 PM #3003Developer

- Registriert seit
- Jun 2006
- Ort
- USA, Virginia
- Beiträge
- 580
- Points
- 5.650
- Level
- 48
- Downloads
- 0
- Uploads
- 0
well acctually it dosent work for eboots , i need something that will work for eboots.. but thanks , it worked in lowser.
-
07-27-2006, 09:23 PM #3004QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
branin whats your prob i don't feel like having to try and figure it all out from the last few pages
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
-
07-27-2006, 11:17 PM #3005words 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
The bool 'loop' as true if you want it to keep playing over and over, or false to make it play once...
Zitat von slicer4ever
As for the actual loading/playing, yours should work as string file = path to music file, and the bool set to either true or false for repeat/non-repeat.
...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
-
07-28-2006, 01:58 AM #3006QJ Gamer Blue
- Registriert seit
- Jul 2006
- Ort
- Alabama
- Beiträge
- 142
- Points
- 4.241
- Level
- 41
- Downloads
- 0
- Uploads
- 0
I made (in the loosest sense of the word) this simple mapbuilder from chunks of PSPMilllionaire's scrolling engine, but I don't completely understand it.
1. What is string.byte, and what does string.byte("1") mean?
2.How do I modify this to build maps with more than 9 different images (instead of 1-9, 001-999)?
Sorry if #2 is too much to ask.white = Color.new(255,255,255)
green = Color.new(0, 255, 0)
blue=Color.new(0,0,255)
red=Color.new(255,0,0)
grey=Color.new(108,108,10 8)
yellow=Color.new(255,255, 0)
Images = { }
Images[1] = Image.createEmpty(8,8)
Images[1]:clear(green)
Images[2] = Image.createEmpty(8,8)
Images[2]:clear(blue)
Images[3] = Image.createEmpty(8,8)
Images[3]:clear(red)
Images[4] = Image.createEmpty(8,8)
Images[4]:clear(grey)
Images[5] = Image.createEmpty(8,8)
Images[5]:clear(yellow)
TILE_SIZE = 8
MAP_WIDTH = 4
MAP_HEIGHT = 4
SCREEN_WIDTH =272
SCREEN_HEIGHT =480
MX = TILE_SIZE
MY = TILE_SIZE
-- Level Map
map1 = {
"1111",
"2154",
"3312",
"1121",
}
map = { }
for y = 1, MAP_HEIGHT do
map[y] = {}
end
-- Functions
function buildmap()
for y = 1, MAP_HEIGHT do
line = map1[y]
for x = 1, MAP_WIDTH do
map[y][x] = string.byte(line, x) - string.byte("1") +1
end
end
end
buildmap()
function getMapTile(y,x)
if x >= 0 and x <= MAP_WIDTH and y >= 0 and y <= MAP_HEIGHT then
img = map[y][x]
return img
else return 0
end
end
function drawMap(mapDrawX, mapDrawY)
mapx = math.floor(mapDrawX / TILE_SIZE)
mapy = math.floor(mapDrawY / TILE_SIZE)
xoff = math.floor(mapDrawX - mapx*TILE_SIZE)
yoff = math.floor(mapDrawY - mapy*TILE_SIZE)
for x = 0,SCREEN_WIDTH do
for y = 0,SCREEN_HEIGHT do
img = getMapTile(mapy+y, mapx+x)
if img > 0 then screen:blit(x*TILE_SIZE - xoff, y*TILE_SIZE - yoff,Images[img]) end
end
end
end
--MAIN LOOP
while true do
screen:clear()
MXa = math.floor(MX)
MYa = math.floor(MY)
drawMap(MXa,MYa)
screen.waitVblankStart()
screen.flip()
end
-
07-28-2006, 01:59 AM #3007QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
ok so for example:
music1 = music.load("music.it",tru e)
^^ that should work well i'll try it but just asking also thanks=-)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
-
07-28-2006, 08:05 PM #3008Developer

- Registriert seit
- Jun 2006
- Ort
- USA, Virginia
- Beiträge
- 580
- Points
- 5.650
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Can anyone tell me if theres a tutorial somewhere on installing Danzeffs OSK to your script? I'm looking to make something and i need it. But i realise it will be quite a task without some sort of tutorial or help.
-
07-28-2006, 08:31 PM #3009QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
ok i come back i've tried the following to try and load in a .it music file:
music1 = Music.playFile("music1.it ")
music1 = Music.playFile("music1.it ",true)
sg57 could you post an example of the proper way to load it in?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
-
07-28-2006, 11:44 PM #3010Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
I just wanted to say, GREENSKULL'S BACK! I think when I get my other computer set up, I will finish what I'd started with Smile Quartet
-
07-29-2006, 12:17 AM #3011words 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
Sound
Lua Player supports sound in WAV format and music in the MOD formats UNI, IT, XM, S3M, MOD, MTM, STM, DSM, MED, FAR, ULT and 669 (use Google to find some editors for it and perhaps some music files, but ask the composer, if you are allowed to use it).
Playing a music is easy: For example to play the file “stranglehold.xm” (composed by Jeroen Tel, (C) 1995 Maniacs of Noise) from the Snake game (Jeroen has allowed to use it in this game), which is included in the standard distribution with Lua Player, just call “Music.playFile(”strangle hold.xm”, true)”. If you specify “false” instead of “true”, the sound will not loop. Call “Music.stop()” to stop the music.
For WAV files first you load the file like with Images: “explode = Sound.load(”explode.wav”) ”. Later you can call “explode
lay()” to play the music.
Just pasting it like it is 'yo'
Now my example:
I dont know the screen.waitVblankStart REAL function name, so if its wrong, then just correct it yourself, since i cant neigther the C or LUA one rightCode:repeat=true while true do pad = Controls.read() if pad:cross() then Music.playFile("sg57 was here...it",repeat); elseif pad:square() then Music.stop() end if pad:triangle() then if repeat==true then repeat=false screen.WaitVblankStart(20) -- whatever that function is named elseif repeat==false then repeat=true screen.WaitVblankStart(20) end end end
Hope that helps...Geändert von SG57 (07-29-2006 um 12:22 AM Uhr)

...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
-
07-29-2006, 03:56 AM #3012
is there any way to load a .txt like this
if pad:cross() then
then i have no idea how to load it
-
07-29-2006, 05:19 AM #3013Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
@Aphonia
1. If you ever come across a function you don't understand, check the Lua manual here, or if it's a Luaplayer function then look at the Luaplayer function list here . Notice that the code defines the map as a string with numbers. Since string.byte returns the "numerical code" of a character, then the numerical code of "1" is subtracted, and then 1 (the number, not the string) is added to the result...you can figure out the rest. Hint: string.byte("2")-string.byte("1")=1
2. There are probably many ways, but I can think of two. The first will be easier but will only allow you to use 26 different tiles. Hint: string.byte("b")-string.byte("a")=1. Actually, now that I think about it, if you know the numerical codes of every character you could use as many different tiles as there are characters. Often the numerical codes for capital letters are the numerical codes for lowercase letters plus 26, but don't quote me on that.
The second way is the way I use, but you'd have to change your code a bit to work with it. Instead of using strings to store the map, why not use a table? You could have an unlimited amount of different characters that way. For instance:
For this map, map[1][3]=5345. Hope this helps.Code:map={{1,2,5345,7}, {16/9,8+3,"tile 1","g"}, {100000000,5,"asdf","qwerty"}, {1,1,1,1}}
@slicer4ever
This might be silly but make sure the .it file is in the same folder as your main script, or else change the command so that it includes the path and filename instead of just the filename. Also, that error looks much nastier than normal Luaplayer errors (trust me, I see a lot of them :)). Maybe Luaplayer for windows doesn't have .it support?
-
07-29-2006, 09:35 AM #3014QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
o ok i see so i load wav files with my images and stuff but for music you load that when in the game i'll try it and thanks=-)
edit: hmm yes does it work in luawindows?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
-
07-30-2006, 10:11 AM #3015QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey can someone tell me what is worng with this code because i cant seem to EVER get an animation loop working
Double Post MergeCode:white = Color.new(255,255,255) donald = Image.load("donaldduck.png") while true do screen:clear(white) counter = Timer.new() counter:start() anicounter = counter:time() if anicounter <= 1000 then screen:blit( 220, 100, donald, 0, 0, 33, 48) end if anicounter <= 2000 and anicounter > 1000 then screen:blit( 220, 100, donald, 33, 0, 33, 48) end if anicounter <= 3000 and anicounter > 2000 then screen:blit( 220, 100, donald, 66, 0, 33, 48) end if anicounter <= 4000 and anicounter > 3000 then screen:blit( 220, 100, donald, 99, 0, 33, 48) counter:reset(0) end screen.flip() end
sorry to double post but can someone delete my previous post because i solved the problemGeändert von mark.sparky (07-30-2006 um 07:26 AM Uhr)
-
07-30-2006, 10:13 AM #3016is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
OK, why don't u enlighten on on what the answer was?
That'll help more people with the problem.
I cant delete, not a mod, sorry!What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
07-30-2006, 10:17 AM #3017sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
yes, please tell us :)
-
07-30-2006, 11:44 AM #3018QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok so i got the animation working but now the ai doesnt work
<?>*^|&@~{}@ (that is not gibberish it is words i would like to say but cant). Well to the point can someone check out the code and tell me what is wrong
Double Post Merge
here is the code http://www.sharebigfile.com/file/16570/Horses.rar.htmlGeändert von mark.sparky (07-30-2006 um 11:42 AM Uhr)
-
07-30-2006, 11:57 AM #3019
- Registriert seit
- Dec 2005
- Beiträge
- 30
- Points
- 4.368
- Level
- 42
- Downloads
- 0
- Uploads
- 0
ok, this sounds really silly lol, cos i know a fair bit of lua, but is there an or operator, like the and operator? for an if statement. would be used in the code below
if enemyCheck.roamX = nil or enemyCheck.roamX = enemyCheck.x then
cheers
EDIT: dont worry, i have found the solution, its a school boy error lol, its fixed nowGeändert von mimminito (07-30-2006 um 12:23 PM Uhr)
-
07-31-2006, 12:24 PM #3020QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey, im going to get straight to the point . Is there a way to find out if a button is not being pressed.
-
07-31-2006, 12:26 PM #3021is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
yea, if not pad:thebutton()
replace thebutton with a buttonWhat did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
07-31-2006, 12:27 PM #3022sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
yes, here ya go:
-= Double Post =-Code:if tostring(pad) == "Controls (0)" then -- do whatever here end
that wont work, cuz he wants specifically after a button is pressed, not whenever a button isnt being pressed
Zitat von Alex.
Geändert von Bronx (07-31-2006 um 12:27 PM Uhr) Grund: Automerged Doublepost
-
07-31-2006, 12:30 PM #3023is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
oh ok, so like 'on mouseup' for windows?
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
07-31-2006, 12:50 PM #3024QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
yeah, that is what i mean alex and can someone explain what bronx said coz its kinda confusing
-= Double Post =-
infact ill explain in more deatil what i want to do. i want it so that when you press down button (just an example) the character moves and the animation of walking happens but as soon as you stop pressing that button the character stops. And also is there anyway to stop the character forom going diagonal i.e. when down and left is pressedGeändert von mark.sparky (07-31-2006 um 12:50 PM Uhr) Grund: Automerged Doublepost
-
07-31-2006, 01:03 PM #3025sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
if you want the player to move on command he will stop automatically when you release down. and to stop from diagnol do sumtin like this
if pad:down() and pad:left then
enemy.x = enemy.x
enemy.y = enemy.y
end
-
07-31-2006, 01:05 PM #3026QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
no it is not the player i want to stop. it is the animation because i dont want it to look as if he is walking when he isnt. Again also is there way to get a variable to change in a table. I know it sounds confusing but here is the code.
Code:this is what i want to change. the width and height according to what image it has in the animation I I link = {} v link[1] = { x = 220, y = 120, face = down, walk = false, width = image:width(), height = image:height()}Geändert von mark.sparky (07-31-2006 um 01:13 PM Uhr)
-
07-31-2006, 01:06 PM #3027is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
yea, so just say if pad:down() then whatever whatever else end
i like putting that else in cos to me it assures me it wont do anything if u dont have them pressed
-= Double Post =-
the in ur animation code put "while pad:down() do" all the animations mumbo jumbo "end"Geändert von Glynnder (07-31-2006 um 01:06 PM Uhr) Grund: Automerged Doublepost
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
07-31-2006, 01:07 PM #3028sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
you animation is wrong if it does that
Zitat von mark.sparky
, fix ur animation
-
07-31-2006, 01:15 PM #3029QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Well I know what to do that now because as alex said all I need is a simple while loop but also is there a way to do what i asked in post # 3026 ( i edited the post). The easy to way to sort it I think is to have an if loop to check to see if that image has been blited to the screen. Is this right? If this is right how would you check to see if the image is on the screen. And sorry if im bein a bother
Geändert von mark.sparky (07-31-2006 um 01:21 PM Uhr)
-
07-31-2006, 08:21 PM #3030Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i need desperate help guys: here is my code:
Code:function test(header, frames, name) name = {} for a = 1, frames do name[a] = Image.load(header..a..".png") end name[frames+1] = 1 end
this function is supposed to load some images, depending on the header, and how many there are.
here is when i call it:
but i makes an array called "name" not "array"Code:while true do test("test", 2, array)
help. thx.!!--------------------------------------------------------------------------------------


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