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 andyauff Okay, so I have just begun learning lua recently, and I am making a stupid app for ...
-
01-19-2007, 06:44 PM #5161QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
I believe this should work. :)
Zitat von andyauff
Its not very much different from yours, i believe you can figure out the differences and their effects.
Code:--App by andyauff --Version .02 of "Useless Music App", finished January , 2007 --define colors--------------------------------------------------- white = Color.new (255,255,255) blue = Color.new (0,0,255) black = Color.new (0,0,0) red = Color.new (255,0,0) green = Color.new (0,255,0) yellow = Color.new (255,255,0) purple = Color.new (255,0,255) oldpad = Controls.read() song = "mindwave" --create the menu function---------------------------------------- function drawMenu() gamestate = "menu" selector = { image = Image.createEmpty (145,15), x = 147, y = 77} selector.image:clear(yellow) screen:clear(green) pad = Controls.read() screen:blit(selector.x,selector.y,selector.image) screen:print(150,80,"Mindwave",blue) screen:print(150,100,"Minute",blue) --controls if pad:up() and oldpad:up() ~= pad:up() then selector.y = 77 song = "mindwave" end if pad:down() and oldpad:down() ~= pad:down() then selector.y = 97 song = "minute" end screen.flip() end --create the game funtion------------------------------------------ function inGame() gamestate = "start" pad = Controls.read() screen:clear(red) screen:print(150,100,"To play song, press X.",green) screen:print(150,120,"To pause song, press X again.",yellow) screen:print(150,140,"Enjoy!",purple) if pad:cross() and oldpad:cross() ~= pad:cross() then if gamestate == "start" then if song == "mindwave" then Music.playFile("mindwave.mod", false) elseif song == "minute" then Music.playFile("minute.xm:, false) end gamestate = "playing" elseif gamestate == "playing" then Music.pause() gamestate = "paused" elseif gamestate == "paused" then Music.resume() gamestate = "playing" end end if pad:start() then gamestate = "menu" end screen.flip() end --main loop--------------------------------------------------------- while true do drawMenu() inGame() oldpad = pad end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-19-2007, 07:31 PM #5162QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Thanks a lot for the help, but unfortunately that didn't work either. It was flashing quickly between the menu and the instructions screen, and the music still starts over instead of pausing. Also, the selector still doesn't move. I think some of it may have to do with the main loop, it may be trying to run both functions at the same time? I'm new to lua but that sounds reasonable to me. Thanks a lot for the help, I'll see if I can mess around with it. And if you want to waste more time helping me, I can give you the eboot so you can run the script to test it. Just if you feel like it though. Thanks a lot for helping.
-
01-19-2007, 08:06 PM #5163QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- www.ultimatetalkforums.com Games, RPG, quickchat and more!
- Beiträge
- 532
- Points
- 8.746
- Level
- 62
- Downloads
- 0
- Uploads
- 0
omfg ive triedso harf to fix my game go go go! but noone will help!
[CENTER][COLOR=black][COLOR=black][URL="http://forums.qj.net/f-psp-firmware-discussion-253/t-psp-firmware-30-get-it-58053.html"][COLOR=cyan]would you upgrade?[/COLOR][/URL] [/COLOR][FONT=Times New Roman][COLOR=navy][URL="http://www.mindistortion.net/iwantyoursoul/?i_am=altunozara"]OMG ITS REAL![/URL][/COLOR][/FONT][COLOR=black] [URL="http://forums.qj.net/showthread.php?t=61756&page=1&pp=10"][COLOR=lime]Sony vs Nintendo[/COLOR][/URL][/COLOR][/COLOR][/CENTER]
[CENTER] [/CENTER]
[CENTER][URL="http://www.ultimatetalkforums.com"][IMG]http://i94.photobucket.com/albums/l82/Altunozara/userbar2.jpg[/IMG][/URL][/CENTER]
[CENTER][SIZE=3]i [/SIZE][URL="http://forums.qj.net/www.gamingwell.com"][SIZE=3]wonder what could be under this hyperlink..hmm[/SIZE][/URL][/CENTER]
[CENTER][SIZE=3][COLOR=green][B][I]Maniakc is awsome!!![/I][/B][/COLOR][/SIZE][/CENTER]
[CENTER][FONT=Arial Black][SIZE=3][COLOR=#660099][I][U][URL="http://forums.qj.net/member.php?u=58299"]The Brain Pwns!!![/URL][/U][/I][/COLOR][/SIZE][/FONT][/CENTER]
[COLOR=sienna]Creator of:[/COLOR][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-go-go-go-beta-66652.html"][COLOR=sienna]GO GO GO![/COLOR][/URL]
-
01-19-2007, 09:00 PM #5164
allot of people dont use the default vBulletin settings for posts per page.Can somone anwser to my question please.Page 516 firstpost.
get the post id.
-
01-19-2007, 10:36 PM #5165QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
I do :P whats the post id?
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-19-2007, 11:15 PM #5166QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- www.ultimatetalkforums.com Games, RPG, quickchat and more!
- Beiträge
- 532
- Points
- 8.746
- Level
- 62
- Downloads
- 0
- Uploads
- 0
hey guys u know when you say like when you clickm square do something
what would it be for the right d pad like wats it called when you right it...r?[CENTER][COLOR=black][COLOR=black][URL="http://forums.qj.net/f-psp-firmware-discussion-253/t-psp-firmware-30-get-it-58053.html"][COLOR=cyan]would you upgrade?[/COLOR][/URL] [/COLOR][FONT=Times New Roman][COLOR=navy][URL="http://www.mindistortion.net/iwantyoursoul/?i_am=altunozara"]OMG ITS REAL![/URL][/COLOR][/FONT][COLOR=black] [URL="http://forums.qj.net/showthread.php?t=61756&page=1&pp=10"][COLOR=lime]Sony vs Nintendo[/COLOR][/URL][/COLOR][/COLOR][/CENTER]
[CENTER] [/CENTER]
[CENTER][URL="http://www.ultimatetalkforums.com"][IMG]http://i94.photobucket.com/albums/l82/Altunozara/userbar2.jpg[/IMG][/URL][/CENTER]
[CENTER][SIZE=3]i [/SIZE][URL="http://forums.qj.net/www.gamingwell.com"][SIZE=3]wonder what could be under this hyperlink..hmm[/SIZE][/URL][/CENTER]
[CENTER][SIZE=3][COLOR=green][B][I]Maniakc is awsome!!![/I][/B][/COLOR][/SIZE][/CENTER]
[CENTER][FONT=Arial Black][SIZE=3][COLOR=#660099][I][U][URL="http://forums.qj.net/member.php?u=58299"]The Brain Pwns!!![/URL][/U][/I][/COLOR][/SIZE][/FONT][/CENTER]
[COLOR=sienna]Creator of:[/COLOR][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-go-go-go-beta-66652.html"][COLOR=sienna]GO GO GO![/COLOR][/URL]
-
01-19-2007, 11:23 PM #5167
buttonstate:left()
and i don't know what the post id is, i was asking zereox to get it for me.
-
01-20-2007, 04:35 AM #5168Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
The psp buttons
pad = Controls.read()
pad:cross()
pad:square()
pad:triangle()
pad:circle()
--shoulder buttons
pad:r()
pad:l()
--d pad
pad:left()
pad:right()
pad:up()
pad:down()
Im pretty sure thats all right.
Now to use them its just if pad:down() then or however you want to use them.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-20-2007, 04:47 AM #5169QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- www.ultimatetalkforums.com Games, RPG, quickchat and more!
- Beiträge
- 532
- Points
- 8.746
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Go Go Go!
you might have heard of GO GO GO! i want to make an ai and ive tried to just do a test...and hmm heres my code can anyone tell me what ive done rong...it wont work
Code:-- Loading music Music.playFile ("ame002.it", true) green=Color.new(0,255,0) timer=Timer.new() math.randomseed(os.time()) -- load graphics tiles = Image.load("tiles.png") figure = Image.load("figure.png")-- load graphics tiles = Image.load("tiles.png") figure = Image.load("figure.png") -- the map mapSource = { "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", "meaaaaaaaaaaaaaaaaaaaaaaaaaafm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "aiooooooooooooooooooooooooooja", "oooooooooooooooooooooooooooooo", "clooooooooooooooooooooooooookc", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mdoooooooooooooooooooooooooobm", "mhccccccccccccccccccccccccccgm", "mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm", } -- offsreen image, where the map will be drawn board = Image.createEmpty(480, 272) -- draw one tile on the map function drawTile(tile, x, y) tile = string.byte(tile, 1) - string.byte("a") local tileX = math.mod(tile, 4) local tileY = math.floor(tile / 4) board:blit(16 * x, 16 * y, tiles, 17 * tileX + 1, 17 * tileY + 1, 16, 16, false) end -- copy the map source to an array for easier access and draw the offscreen board map = {} for y = 1, 17 do line = mapSource[y] map[y] = {} for x = 1, 30 do tile = string.sub(line, x, x) map[y][x] = tile drawTile(tile, x - 1, y - 1) end end -- current player position playerX = 6 playerY = 14 -- current player 2 position playerX = 15 playerY = 15 -- current player animation image animation = 0 -- 1 = animation images increases, -1: decreases animationDirection = 1 -- animation slowdown counter animationSlowDown = 0 -- controls the movement speed. At speedStep == 0, the last -- pad will be evaluated, other steps the pad movements are only -- saved speedStep = 0 -- last pad direction dx = 0 dy = 0 -- current score score = 0 -- text color white = Color.new(255, 255, 255) gameover = Image.load("gameover.png") -- text color white = Color.new(255, 255, 255) gameover = Image.load("gameover.png") while true do timer:start() if timer:time() > 10 then screen:blit(0,0,gameover, true) end -- read current pad pad = Controls.read() if pad:start() then -- exit to lowser, if started from there break end if speedStep == 0 then -- save old player position oldPlayerX = playerX oldPlayerY = playerY -- add last movement playerX = playerX + dx playerY = playerY + dy -- check new tile newTile = map[playerY][playerX] -- if the position is not allowed, restore old player position if newTile ~= "n" and newTile ~= "o" and newTile ~= "r" and newTile ~= "s" and newTile ~= "t" and newTile ~= "p" and newTile ~= "q" then playerX = oldPlayerX playerY = oldPlayerY end -- if it is a tile which can be eaten, eat it if newTile == "o" then score = score + 1 end if newTile == "o" then -- set background tile map[playerY][playerX] = "n" -- draw background tile drawTile("o", playerX - 1, playerY - 1) end -- reset last movement dx = 0 dy = 0 else --Player movements if pad:up() then dy = -1 elseif pad:down() then dy = 1 elseif pad:left() then dx = -1 elseif pad:right() then dx = 1 elseif pad:cross() then drawTile("o", playerX - 1, playerY - 1) elseif pad:square() then drawTile("r", playerX - 1, playerY - 1) elseif pad:circle() then drawTile("s", playerX - 1, playerY - 1) elseif pad:triangle() then drawTile("t", playerX - 1, playerY - 1) elseif pad:l() then drawTile("n", playerX - 1, playerY - 1) elseif pad:r() then dofile("battle land.lua") end end -- update speed step counter speedStep = speedStep + 1 if speedStep == 5 then speedStep = -1 end -- blit board screen:blit(0, 0, board, 0, 0, board:width(), board:height(), false) -- blit current player animation image screen:blit((playerX - 1) * 16 - 4, (playerY - 1) * 16 - 4, figure, 1 + 25 * animation, 1, 24, 24) -- calculate next animation image animationSlowDown = animationSlowDown + 1 if animationSlowDown == 3 then animationSlowDown = 0 animation = animation + animationDirection if animation == 4 then animationDirection = -1 elseif animation == 0 then animationDirection = 1 end end -- print score screen:print(10, 260, "Score: " .. score, white) --print time screen:print(0,0,"Time:"..timer:time()/1000,green) -- wait for vertical sync and show new screen screen.waitVblankStart() screen:flip() end --** AI MOULD CREATION **-- --Mould 1 - figure figuremould = {} --figuremould.AI = math.random(1, 100) To be done later figuremould.run = true figuremould.jog = false figuremould.sprint = false figuremould.x = 0 --**AI Mould Creation End** --main loop while true do screen:clear() screen:blit(0, 0, tiles) --figure AI if figuremould.x <= 480 then figuremould.AI = math.random(1, 100) if figuremould.AI == 75 or Easymould.AI == 100 then figuremould.run = false figuremould.jog = true figuremould.sprint = false end if figuremould.AI == 99 then figuremould.sprint = false figuremould.run = true figuremould.jog = false end if figuremould.AI == 2 then figuremould.sprint = true figuremould.run = false figuremould.jog = false end if figuremould.run == true then figuremould.x = figuremould.x + 2 end if figuremould.jog == true then figuremould.x = figuremould.x + 1 end if figuremould.sprint == true then figuremould.x = figuremould.x + 3 endend --****ARTIFICIAL INTELLIGENCE**** END figuremould.AI = math.random(1, 100) if figuremould.AI == 75 or Easymould.AI == 100 then figuremould.jog = true if figuremould.run == true then figuremould.x = figuremould.x + 2 end if figuremould.jog == true then figuremould.x = figuremould.x + 1 end if figuremould.sprint == true then figuremould.x = figuremould.x + 3 end screen:blit(figuremould.x, 42, figure)[CENTER][COLOR=black][COLOR=black][URL="http://forums.qj.net/f-psp-firmware-discussion-253/t-psp-firmware-30-get-it-58053.html"][COLOR=cyan]would you upgrade?[/COLOR][/URL] [/COLOR][FONT=Times New Roman][COLOR=navy][URL="http://www.mindistortion.net/iwantyoursoul/?i_am=altunozara"]OMG ITS REAL![/URL][/COLOR][/FONT][COLOR=black] [URL="http://forums.qj.net/showthread.php?t=61756&page=1&pp=10"][COLOR=lime]Sony vs Nintendo[/COLOR][/URL][/COLOR][/COLOR][/CENTER]
[CENTER] [/CENTER]
[CENTER][URL="http://www.ultimatetalkforums.com"][IMG]http://i94.photobucket.com/albums/l82/Altunozara/userbar2.jpg[/IMG][/URL][/CENTER]
[CENTER][SIZE=3]i [/SIZE][URL="http://forums.qj.net/www.gamingwell.com"][SIZE=3]wonder what could be under this hyperlink..hmm[/SIZE][/URL][/CENTER]
[CENTER][SIZE=3][COLOR=green][B][I]Maniakc is awsome!!![/I][/B][/COLOR][/SIZE][/CENTER]
[CENTER][FONT=Arial Black][SIZE=3][COLOR=#660099][I][U][URL="http://forums.qj.net/member.php?u=58299"]The Brain Pwns!!![/URL][/U][/I][/COLOR][/SIZE][/FONT][/CENTER]
[COLOR=sienna]Creator of:[/COLOR][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-go-go-go-beta-66652.html"][COLOR=sienna]GO GO GO![/COLOR][/URL]
-
01-20-2007, 04:48 AM #5170Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Well before I look into the vast lines of code you have there what error are you getting?
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-20-2007, 04:53 AM #5171QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- www.ultimatetalkforums.com Games, RPG, quickchat and more!
- Beiträge
- 532
- Points
- 8.746
- Level
- 62
- Downloads
- 0
- Uploads
- 0
umm what do i do to check again..its njust flashing...so what do i dfo like...cmd then somethign or somehting like that
[CENTER][COLOR=black][COLOR=black][URL="http://forums.qj.net/f-psp-firmware-discussion-253/t-psp-firmware-30-get-it-58053.html"][COLOR=cyan]would you upgrade?[/COLOR][/URL] [/COLOR][FONT=Times New Roman][COLOR=navy][URL="http://www.mindistortion.net/iwantyoursoul/?i_am=altunozara"]OMG ITS REAL![/URL][/COLOR][/FONT][COLOR=black] [URL="http://forums.qj.net/showthread.php?t=61756&page=1&pp=10"][COLOR=lime]Sony vs Nintendo[/COLOR][/URL][/COLOR][/COLOR][/CENTER]
[CENTER] [/CENTER]
[CENTER][URL="http://www.ultimatetalkforums.com"][IMG]http://i94.photobucket.com/albums/l82/Altunozara/userbar2.jpg[/IMG][/URL][/CENTER]
[CENTER][SIZE=3]i [/SIZE][URL="http://forums.qj.net/www.gamingwell.com"][SIZE=3]wonder what could be under this hyperlink..hmm[/SIZE][/URL][/CENTER]
[CENTER][SIZE=3][COLOR=green][B][I]Maniakc is awsome!!![/I][/B][/COLOR][/SIZE][/CENTER]
[CENTER][FONT=Arial Black][SIZE=3][COLOR=#660099][I][U][URL="http://forums.qj.net/member.php?u=58299"]The Brain Pwns!!![/URL][/U][/I][/COLOR][/SIZE][/FONT][/CENTER]
[COLOR=sienna]Creator of:[/COLOR][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-go-go-go-beta-66652.html"][COLOR=sienna]GO GO GO![/COLOR][/URL]
-
01-20-2007, 08:42 AM #5172Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
alright i tried doing math.random() but it just says unexpected symbol i dont understand :ARGH:
-
01-20-2007, 09:15 AM #5173QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It works for me. What is your exact code?
Zitat von eyece
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-20-2007, 02:00 PM #5174QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
I think you need to give it a range of numbers to go through...like math.random(1,20) that way, it will pick a number in between (and including) 1 through 20. hope this helps.
Zitat von eldiablov
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-20-2007, 02:07 PM #5175QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Quick question about modules:
How come the variables declared in my modules are not accessible outside of them(the module)? I thought Lua variables defaulted to global? Is there some exception with modules? and is there a way around this?
Smaller question: How do I output a new line to a file? I tried "/n" and nothing worked
-
01-20-2007, 02:51 PM #5176QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Im pretty interested in this as well!
Zitat von PSPhakkor
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-20-2007, 02:56 PM #5177QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
your terminology is better than mine, so forgive me if i'm mistaken, but by 'modules' i'm assuming you mean something like a function or a loop.
Zitat von PSPhakkor
anyways, no, lua variables do not always default to global. if you were just declaring a variable normally without loops or modules, it would be global, but if used like below, it would not be global.
"LocalVariableNameHereWhi chIsOptional" would not be global.Code:--some simple function function CustomNameHere(LocalVariableNameHereWhichIsOptional) if LocalVariableNameHereWhichIsOptional == something then DoSomething end --end 'if' end --end 'function'
oh and "/n" is supposed to be "\n". lol. small mistakes...they suck dont they?
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-20-2007, 03:05 PM #5178QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
"/n" still doesn't work! It's supposed to be in quotes, right?
A module is a file of code that index.lua uses rather than putting all the code in one file. It's a lot more organised, but it doesn't matter if I can't get it working. I'll just have a disorganised program if I have to... No one will know when they play the game
-
01-20-2007, 03:10 PM #5179QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
(lol. i still dont get the modules, i'd have to see it.)
Zitat von PSPhakkor
as for the newline, use the other diagonal line. you have "/" when its supposed to be "\".
and its used like this: file:write("\nText")[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-20-2007, 03:11 PM #5180QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
There isn't a newline character for that function.
Don't assume variables will be declared global across files. It is poor practise and design. Parameter pass the values or objects needed to the functions that you call from other files.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-20-2007, 03:34 PM #5181QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
I need some help with something....(obviously :P)
Alright, what i need help with is, I'm trying to make a Bar, a Vertical bar.
now this is easy to do normally, but i need it so that when L and R are pressed, the Bar, rises, until it hits 100, then it does something ( a charge shot)
then returns to 0, This is pretty easy to do, I can do that, the problem is the Bar goes Down, while charging, instead of up, I've tried using Negative numbers without luck, any Help?NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-20-2007, 03:39 PM #5182QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
well blackshark, you know the drill! post the code soldier!
j/k
or PM it if you want, though making a bar shouldnt be anything to hide...[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-20-2007, 03:53 PM #5183QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
I'm sorry, I typed it wrongly in the post. my program has it going the right way, but it doesn't do anything. Here's the format I'm using: file:write(string1, "\n", string2)
Zitat von EminentJonFrost
If there's no newline character for that function, then how do I get new lines in my files?
As for modules, check out this tut. It's when a lua file connects to another lua file and uses it as code.
-
01-20-2007, 04:41 PM #5184QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Blackshark; easiest way is to use screen:fillRect but thats inefficient so ill show you somethin else:
Code:barfill = 0 bar = Image.createEmpty(10,100) bar:clear(colorofbar) while true do screen:clear() pad = Controls.read() if pad:l() then barfill = barfill + 0.2 end --or some other number screen:blit(x,*the number you want to be the bottom of the bar*-barfill,bar,0,0,10,barfill) if barfill > 100 then barfill = 100 end if barfill == 100 and *buttontobepressedtoactivateattackispressed* then *dotheattack* barfill = 0 end screen.waitVblankStart() screen.flip() end
-
01-20-2007, 04:56 PM #5185
well, i never actualy tried using "~", i just assumed it would not work :P
Zitat von yaustar
did it work with tables though? i'd expect it not to, buts its what i need it for.
-
01-20-2007, 05:03 PM #5186
Sorry to ask again but what do I put where it say number dpiX/Y and what is ther original width and height or the normal print function lettering.
Font Font:setCharSize(number width, number height, number dpiX, number dpiY)Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
01-20-2007, 05:32 PM #5187QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes it did which is why I asked for the exact code.
Zitat von eyece
Printing to the screen, the newline character doesn't work. 'Printing' to files, the newline character 'works' as intended.
Zitat von PSPhakkor
As for your module question, it looks like the variable has to exist in the module to be used in the module.
-= Double Post =-
Did a bit of research. The "\n" does work for files BUT it uses the 'unix' version of newline which notepad does not recognise. Use notepad2, Crimson Editor, Notepad++ (basically any decent text editor) and you 'see' it.Geändert von yaustar (01-20-2007 um 05:32 PM Uhr) Grund: Automerged Doublepost
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-20-2007, 05:44 PM #5188QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Crimson Editor Rules!
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-20-2007, 11:37 PM #5189QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Wow. Thanks for doing research for me!
So you're saying that if I use a different text editor, It will work? That's funny.
Unfortunately, I'm limited to LuaDevKit because I don't have my psp at the moment, and I can only test my programs on its tester thing. It's really handy.
However, I did realize that when I used "\n" (or whatever is the correct one, I can't remember!), it wasn't outputted to the file. Unfortunately, neither was the new line. I just got the two strings right next to each other. I hope the different editor will fix this.
Thanks again for your time
-
01-21-2007, 12:22 AM #5190QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
hehe ya, LuaDevKit is pretty handy for debugging
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:


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