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; Em...yeah. Lua scripters not writing their own code is what is hurting the scene....
-
04-07-2007, 02:21 PM #6631
Em...yeah. Lua scripters not writing their own code is what is hurting the scene.
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 02:29 PM #6632
ok, i made my own code, but it just keeps play the animation for what ever button you press here is my code:
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/") oldpad = Controls.read() player = {} player.x = 20 player.y = 210 player.img = standright while true do screen:clear() pad = Controls.read() oldpad = pad if pad:right() then player.img = runright player.x = player.x + 7 end if pad:left() then player.img = runleft player.x = player.x - 7 end if pad:buttons() < 1 and oldpad:left() then player.img = standleft end player.img:blit(player.x, player.y, 50) screen.waitVblankStart() screen.flip() end
-
04-07-2007, 02:34 PM #6633
eww anim lib, cant help you there
...
...
*sigh*
Flip those. Youre also gonna have to mod it a bit for standleft.Code:player.img = standright while true do
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 02:36 PM #6634
just look at the main loop
p.s. i made a sprite of the player image standing left or right with the same frame so it repeats and gives the illusion of an image
-
04-07-2007, 02:44 PM #6635
...........
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 02:47 PM #6636
it's not clearing the screen making player.img stand left if no buttons are pressed and if left was pressed
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/") oldpad = Controls.read() player = {} player.x = 20 player.y = 210 while true do player.img = standright screen:clear() pad = Controls.read() oldpad = pad if pad:right() then player.img = runright player.x = player.x + 7 end if pad:left() then player.img = runleft player.x = player.x - 7 end if pad:buttons() < 1 and oldpad:left() then screen:clear() player.img = standleft end player.img:blit(player.x, player.y, 50) screen.waitVblankStart() screen.flip() end
-
04-07-2007, 03:11 PM #6637QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
that's why i dont use animLib, too confusing
-
04-07-2007, 03:26 PM #6638QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Why don't you just make a function to flip the image in lua and only need 1 image?
That would (if i didnt mess anything up) flip the image horizontally and be used like this:Code:function flip(img) for i = 0, img:width() do for j = 0, img:height() do img:pixel(i,j,img:pixel(img:width()-i,img:height()-j)) end end return img end
Code:someimage = Image.load("image.png") someflippedimage = flip(someimage)
-
04-07-2007, 04:35 PM #6639
ya, but how would i get it to load a certain image after an animation is done, like if i press left, load playerleft or if i press right load imageright after an animation
-
04-07-2007, 04:36 PM #6640QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
if oldpad:right() and not pad:right() then
player.img = facingright
aka if right was pressed last loop but isnt this loop then make the playerimg facing right
-
04-07-2007, 04:42 PM #6641
the problem im encountering is that it won't load the image i tell it to here is the code:
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/") oldpad = Controls.read() player = {} player.x = 20 player.y = 210 while true do player.img = standright screen:clear() pad = Controls.read() oldpad = pad if pad:right() then player.img = runright player.x = player.x + 7 end if pad:left() then player.img = runleft player.x = player.x - 7 end if oldpad:left() and not pad:left() then player.img = standleft end player.img:blit(player.x, player.y, 50) screen.waitVblankStart() screen.flip() end
-
04-07-2007, 04:45 PM #6642QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You need to put oldpad = pad before pad = Controls.read()
-
04-07-2007, 04:50 PM #6643
ok i did that:
now i get the error: lua:31:attempt to index globa 'oldpad' <a nil value>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/") oldpad = Controls.read() player = {} player.x = 20 player.y = 210 while true do player.img = standright screen:clear() oldpad = pad pad = Controls.read() if pad:right() then player.img = runright player.x = player.x + 7 end if pad:left() then player.img = runleft player.x = player.x - 7 end if oldpad:left() and not pad:left() then player.img = standleft end player.img:blit(player.x, player.y, 50) screen.waitVblankStart() screen.flip() end
-
04-07-2007, 04:51 PM #6644
Because on the first loop you assign it to pad, which is nil
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 04:54 PM #6645
but he said to put old = pad before pad = Controls.read
-
04-07-2007, 04:54 PM #6646
yes, but you need a first value.
do
pad = oldpad
right under oldpad = COntrols.read()牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 04:55 PM #6647
my code:
still doesn't make player.img standleftCode: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/") oldpad = Controls.read() pad = oldpad player = {} player.x = 20 player.y = 210 while true do player.img = standright screen:clear() oldpad = pad pad = Controls.read() if pad:right() then player.img = runright player.x = player.x + 7 end if pad:left() then player.img = runleft player.x = player.x - 7 end if oldpad:left() and not pad:left() then player.img = standleft end player.img:blit(player.x, player.y, 50) screen.waitVblankStart() screen.flip() endGeändert von moncristo_da_dev (04-07-2007 um 04:58 PM Uhr) Grund: Automerged Doublepost
-
04-07-2007, 05:02 PM #6648
blame animlib, it sux0rz
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 05:03 PM #6649
man, i think im cursed with noobness
-
04-07-2007, 06:05 PM #6650QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 172
- Points
- 3.680
- Level
- 38
- Downloads
- 0
- Uploads
- 0
if oldpad:left() and not pad:left() then
player.img = standleft
end
shouldn't it be
if oldpad:left() and ~pad:left() then
player.img = standleft
end
-= Double Post =-
i never seen not be called i don't even know if it can be called as notGeändert von seenit (04-07-2007 um 06:06 PM Uhr) Grund: Automerged Doublepost
-
04-07-2007, 06:16 PM #6651
Not checks if all the following code block is false. Ive never seen ~pad:left(), that works?
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
04-07-2007, 06:19 PM #6652QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 172
- Points
- 3.680
- Level
- 38
- Downloads
- 0
- Uploads
- 0
i know you can use oldpad:left ~= pad:left
idk it's been a long time since i programmed with lua
-
04-07-2007, 06:39 PM #6653
it doesn't work, i have tried a lot of things before asking you guys here
-
04-07-2007, 06:40 PM #6654QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 172
- Points
- 3.680
- Level
- 38
- Downloads
- 0
- Uploads
- 0
o ok
-
04-07-2007, 07:06 PM #6655QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i agree with that
Zitat von youresam
that's why i use sprite sheets to do the animations
-
04-07-2007, 07:08 PM #6656Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
umm, animlib supports all sprite sheets. (v4)
Zitat von Urameshi
:)--------------------------------------------------------------------------------------
-
04-07-2007, 07:09 PM #6657
i am using sprite sheets on animlib
Zitat von Urameshi
-= Double Post =-
grim solve my problem please!!!!Geändert von moncristo_da_dev (04-07-2007 um 07:09 PM Uhr) Grund: Automerged Doublepost
-
04-07-2007, 07:10 PM #6658QJ Gamer Blue
- Registriert seit
- Apr 2007
- Beiträge
- 172
- Points
- 3.680
- Level
- 38
- Downloads
- 0
- Uploads
- 0
@mon lose animlib make the images into their own images then just load them as there names and then it should work
-
04-07-2007, 07:12 PM #6659Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
try putting this line:
Zitat von moncristo_da_dev
before your main loop. also, your state system is faulty. gimme a min, ill show you how to improvise yours.Code:player.img = standright
--------------------------------------------------------------------------------------
-
04-07-2007, 07:13 PM #6660
ok thanks a lot


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