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; LOL, today seems to be "hate animlib day" heh. BAN ON ANIMLIB!! (JK!!)...
-
04-07-2007, 07:14 PM #6661Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
LOL, today seems to be "hate animlib day" heh.

BAN ON ANIMLIB!! (JK!!)
--------------------------------------------------------------------------------------
-
04-07-2007, 07:15 PM #6662
i actually like it because i can do an animation in two lines which kicks a$$
-
04-07-2007, 07:15 PM #6663QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
actually i dont like animLib on like walking animations, but on other animation animLib saves the day
-
04-07-2007, 07:18 PM #6664QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Which string function counts how many times a letter occurs in that string (if such a function exists). For example: string.getnum(mystring,"\ n") would count how many newlines in a string.
-
04-07-2007, 07:20 PM #6665
You gotta write it yourself.
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 07:21 PM #6666QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 172
- Points
- 3.680
- Level
- 38
- Downloads
- 0
- Uploads
- 0
in c/c++ there is a command in the string.h library(don't remeber it off hand)
-
04-07-2007, 07:21 PM #6667QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
but this is lua
-
04-07-2007, 07:22 PM #6668Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
almost done...
--------------------------------------------------------------------------------------
-
04-07-2007, 07:23 PM #6669QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Any idea on how I could do this youresam? You've probably done something like this before I suppose?
EDIT: Nevermind, I know how.
-
04-07-2007, 07:32 PM #6670
bleh?
total = 0
for a=1,string.len(str) do
if string.sub(str,a,a) == char then total = total + 1 end
end牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 07:42 PM #6671QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Mine was:
Zitat von youresam
lastenter = string.find(currenttext," \n",0)
numenter = 0
function NumEnters( )
lastenter = string.find(currenttext," \n",lastenter)
if lastenter ~= nil then
numenter = numenter + 1
end
end
-
04-07-2007, 07:43 PM #6672Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Code:dofile("animLib.lua") standright = SS.new("jackstandright", "png", 24, 50, "images/jack/") standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/") runright = SS.new("jackrunright", "png", 64, 48, "images/jack/") runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/") pad = Controls.read() player = {} player.x = 20 player.y = 210 player.state = "standRight" -- ditch the img, use states -- -- NOTE: oldpad isnt necessary. -- while true do screen:clear() -- NOW, the part you're having trouble with -- if pad:right() then -- if RIGHT is pressed -- player.state = "runRight" player.x = player.x + 7 elseif pad:left() then -- if LEFT is pressed -- player.state = "runLeft" player.x = player.x - 7 else -- meaning NEITHER IS PRESSED -- if player.state == "runRight" then -- if he was running right before -- player.state = "standRight" -- then he is standing right -- elseif player.state == "runLeft" then -- same as above -- player.state = "standLeft" end end -- draw animation -- if player.state == "runRight" then runright:blit(player.x, player.y, 50) elseif player.state == "standRight" then standright:blit(player.x, player.y, 50) elseif player.state == "runLeft" then runleft:blit(player.x, player.y, 50) elseif player.state == "standLeft" then standleft:blit(player.x, player.y, 50) end screen.waitVblankStart() screen.flip() endGeändert von Grimfate126 (04-07-2007 um 07:57 PM Uhr)
--------------------------------------------------------------------------------------
-
04-07-2007, 07:45 PM #6673QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
I haven't checked it but should work (I hope).
-
04-07-2007, 07:46 PM #6674
That would be the proper way to do it. Except you forgot to loop it
Zitat von romulator
-= Double Post =-
Grim you know you could replace the states with the images, would make it a lot easier to blit.Geändert von youresam (04-07-2007 um 07:50 PM Uhr) Grund: Automerged Doublepost
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 07:54 PM #6675
yea, why did you switch to states? You said it was easier in that code but i don't see how.
Zitat von youresam
-
04-07-2007, 07:54 PM #6676QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- Tokoroa, New Zealand
- Beiträge
- 103
- Points
- 4.412
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Oh yeah woops. Well its good to know I was on the right track.
-
04-07-2007, 08:03 PM #6677
lol, i just made a script of:
Zitat von youresam
and it turns out pressing cross == 16384Code:while true do screen:clear() pad = Controls.read() screen:print(100,100,pad:buttons(),Color.new(255,255,255)) screen.flip() screen.waitVblankStart() end
-
04-07-2007, 08:04 PM #6678Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
im simply thinking for a long term solution. suppose you had a player image (which is treated like a state) and you didnt have an animation for it. (believe me, it does happen. such as: player.img = dead) if you did that, you would need an animation for every single state. on the other hand, using states seperately gives you the freedom to not have to use animations for everything. sure, the blitting is a bit tedious, but its ultimately the better choice.
Zitat von emericaska8r
--------------------------------------------------------------------------------------
-
04-07-2007, 08:05 PM #6679
Wait a minute, Controls:buttons() returns the C variable of the pad?
Zitat von emericaska8r

I shoulda guessed that, since there is no "total buttons" variable. So yeah, I guess you can use bitmasks in lua for buttons
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 09:13 PM #6680QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Does anybody know where to get an lrx or something w/ zip compress and uncompress abilities
-
04-07-2007, 09:33 PM #6681
someone wrote a lib in lua that does it btw
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 10:02 PM #6682
my god, animlib is getting complicated with my demands
-
04-07-2007, 11:20 PM #6683QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
how come this doesnt work:
when Player collides with Enemy i want it to wait 5 seconds and blit the image next then go to level2() but it just pauses then goes to level2 without blitting the image:Argh: :Argh:Code:if collision(Player,Enemy) then screen.waitVblankStart(300) screen:blit(0,0,next) level2() end
-
04-08-2007, 03:05 AM #6684
Oh god, that's so easy.
Just take a look at your code again and really think about what you've written, if you still can't figure it out...
-
04-08-2007, 03:54 AM #6685QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
if collision(Player,Enemy) then
screen:blit(0,0,next)
screen.flip()
screen.waitVblankStart(30 0)
level2()
end[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
04-08-2007, 09:08 AM #6686QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
thanks dude, i dont know why, but when i tried that earlier it didnt work
Zitat von myschoo
-
04-08-2007, 10:25 AM #6687
r u done grim?
Geändert von moncristo_da_dev (04-08-2007 um 11:39 AM Uhr)
-
04-08-2007, 12:02 PM #6688Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i posted it yesterday... here:
Zitat von moncristo_da_dev
Code:dofile("animLib.lua") standright = SS.new("jackstandright", "png", 24, 50, "images/jack/") standleft = SS.new("jackstandleft", "png", 24, 50, "images/jack/") runright = SS.new("jackrunright", "png", 64, 48, "images/jack/") runleft = SS.new("jackrunleft", "png", 64, 48, "images/jack/") pad = Controls.read() player = {} player.x = 20 player.y = 210 player.state = "standRight" -- ditch the img, use states -- -- NOTE: oldpad isnt necessary. -- while true do screen:clear() -- NOW, the part you're having trouble with -- if pad:right() then -- if RIGHT is pressed -- player.state = "runRight" player.x = player.x + 7 elseif pad:left() then -- if LEFT is pressed -- player.state = "runLeft" player.x = player.x - 7 else -- meaning NEITHER IS PRESSED -- if player.state == "runRight" then -- if he was running right before -- player.state = "standRight" -- then he is standing right -- elseif player.state == "runLeft" then -- same as above -- player.state = "standLeft" end end -- draw animation -- if player.state == "runRight" then runright:blit(player.x, player.y, 50) elseif player.state == "standRight" then standright:blit(player.x, player.y, 50) elseif player.state == "runLeft" then runleft:blit(player.x, player.y, 50) elseif player.state == "standLeft" then standleft:blit(player.x, player.y, 50) end screen.waitVblankStart() screen.flip() end--------------------------------------------------------------------------------------
-
04-08-2007, 12:14 PM #6689
now it doesn't move but i get the idea thanks
-
04-08-2007, 01:55 PM #6690
whats a bitmask?
Zitat von youresam


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