Seite 234 von 342 ErsteErste ... 134 184 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 284 334 ... LetzteLetzte
Zeige Ergebnis 6.991 bis 7.020 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; Zitat von PSPJunkie_ (You posted twice ^^) I see that now, but I was in a hurry and right after ...

  
  1. #6991
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von PSPJunkie_
    (You posted twice ^^)

    I see that now, but I was in a hurry and right after I posted that my browser crapped out on me so I couldn't tell



  2. #6992
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TMNT
    Something like this:

    Code:
    pad = Controls.read()
    ax = pad:analogX()
    if math.abs(ax) > 32 then
    --Right
    end
    if math.abs(ax) <-32 then
    --Left
    end
    ay = pad:analogY()
    if math.abs(ay) > 32 then
    --Up
    end
    if math.abs(ay) <-32 then
    --Down
    end
    This code is flawed and I wish people would stop sharing it.
    math.abs(ax) <-32 will never be true, math.abs() will return the absolute value of a number, so math.abs(-50) will equal 50.

  3. #6993
    QJ Gamer Blue
    Points: 5.344, Level: 46
    Level completed: 97%, Points required for next Level: 6
    Overall activity: 0%

    Registriert seit
    May 2006
    Beiträge
    347
    Points
    5.344
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    Thanks guys i will go to the forums

  4. #6994
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von KleptoOne
    This code is flawed and I wish people would stop sharing it.
    math.abs(ax) <-32 will never be true, math.abs() will return the absolute value of a number, so math.abs(-50) will equal 50.
    Wow, i really have to stop posting. At least i wasn't spamming (whew*). Anyways, thanks for pointing that out. :)
    Calypso - Enjoy the excellent 2D space shooter:
    http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195

    "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)

  5. #6995
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TMNT
    Wow, i really have to stop posting. At least i wasn't spamming (whew*). Anyways, thanks for pointing that out. :)
    By all means, post as much as you like, just make sure you know the code before you share it, because if you don't it can lead to 50 more questions.

  6. #6996
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    hy there people, is there a luaplayer mod thas includes:
    System.setCpuSpeedVHigh() --Sets CPU to 333 Mhz
    System.setCpuSpeedHigh() --Sets CPU to 300 Mhz
    System.setCpuSpeedMed() --Sets CPU to 266 Mhz
    System.setCpuSpeedReg() --Sets CPU to 222 Mhz
    System.setCpuSpeedLow() --Sets CPU to 200 Mhz
    System.setCpuSpeedVLow() --Sets CPU to 100 Mhz
    and
    Gum.lookAt
    i see the lua player v0.20mod
    it have the cpuspeed, but not the gum.lookat

  7. #6997
    lol
    Points: 20.859, Level: 91
    Level completed: 2%, Points required for next Level: 491
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Whittier, CA
    Beiträge
    5.791
    Points
    20.859
    Level
    91
    Downloads
    0
    Uploads
    0

    Standard

    That would be cools lua player mod 2

  8. #6998
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Anti-QJ
    That would be cools lua player mod 2
    waaa thankss.. i found it thankss thanksss.. oo by the way. i read that in the mod 3 cools has remover the speed functions cos it myght me dangerous is that true ??? using the cloock speed could damage psp ?

  9. #6999
    QJ Gamer Silver
    Points: 10.921, Level: 69
    Level completed: 18%, Points required for next Level: 329
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Behind you.
    Beiträge
    1.814
    Points
    10.921
    Level
    69
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von ahrimanes
    waaa thankss.. i found it thankss thanksss.. oo by the way. i read that in the mod 3 cools has remover the speed functions cos it myght me dangerous is that true ??? using the cloock speed could damage psp ?
    No. Overclocking does NOT damage the psp (well, it depends on how much you "overclock" it). I don't think that there is homebrew that overclocks above 333MHz (correct me if i am wrong; it can be done though?). Having the Cpu speed 333MHz is proven that Sony designed the psp to be like that. Overclocking the psp does NOT damage the psp (333MHz). However, it does reduce play time because it consumes quite a lot of battery.
    Calypso - Enjoy the excellent 2D space shooter:
    http://dl.qj.net/Calypso-v1-PSP-Home...6542/catid/195

    "Quoting yourself in your signature means you love to masterbate while looking at the mirror." -me (oh, wait...)

  10. #7000
    QJ Gamer Green
    Points: 11.300, Level: 70
    Level completed: 13%, Points required for next Level: 350
    Overall activity: 0%

    Registriert seit
    Dec 2006
    Ort
    main();
    Beiträge
    1.071
    Points
    11.300
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    The PSP was meant to run at 333, Sony just had to compete with the battery life of Nintendo's DS. Technically, you really aren't overclocking since Sony underclocked it.

  11. #7001
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TMNT
    Something like this:

    Code:
    pad = Controls.read()
    ax = pad:analogX()
    if math.abs(ax) > 32 then
    --Right
    end
    if math.abs(ax) <-32 then
    --Left
    end
    ay = pad:analogY()
    if math.abs(ay) > 32 then
    --Up
    end
    if math.abs(ay) <-32 then
    --Down
    end
    rofl.

    also, that is not the correct usage of the analog. you're using it as an alternative to the d-pad, which it should be. the analog is meant for pressure sensitivity. use it to your advantage.
    -= Double Post =-
    Zitat Zitat von ahrimanes
    waaa thankss.. i found it thankss thanksss.. oo by the way. i read that in the mod 3 cools has remover the speed functions cos it myght me dangerous is that true ??? using the cloock speed could damage psp ?
    there is a 30% chance of bricking when you overclock. JK!! (before i get banned)

    to add on to the 2 peeps above me, overclocking is not dangerous, but it has two bad sides:

    1. reduces your battery life. not sure how much, but i know its not a tiny bit
    2. its a very cheap way to get better performance. people use to make up for their ghey optimization skills.
    Geändert von Grimfate126 (04-20-2007 um 08:20 PM Uhr) Grund: Automerged Doublepost
    --------------------------------------------------------------------------------------

  12. #7002
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    well ok thanks every one. for this explanation, i think i will go trhowth the optimization way :P

  13. #7003
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Grimfate - FYI, the PSP is no Alienware, and although no PSP homebrew optimized to the fullest would require overclocking, its still a useful way to hlep your framerate along when your still a youngin' not knowing how to use C++ to the fullest (templates ftw)

    ...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


  14. #7004
    QJ Gamer Gold
    Points: 11.942, Level: 71
    Level completed: 73%, Points required for next Level: 108
    Overall activity: 0%

    Registriert seit
    Nov 2006
    Ort
    ...
    Beiträge
    2.080
    Points
    11.942
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    how come this doesnt work, even though i thought it would:
    Code:
    function level4()
    nbc=0
    ncc=3
    showblock=false
    lol=true
    	while true do
    	screen:clear()
    Enemy.x=40
    Enemy.y=50
    Stick.x=117
    Stick.y=234
    Stick2.x=230
    Stick2.y=0
    Square.x=480
    Square.y=45
    
    if collision(Player,Stick2) then
    lol=true
    else if collision(Player,Stick2) and Player.img == Sball then
    lol=false
    end
    end
    
    if lol then
    dofile("br.lua")
    end
    
    if collision(Player,Square) then
    Player.img = Sball
    end
    
    screen:blit(Stick2.x,Stick2.y,Stick2.img)
    
    movePlayer()
    screen:blit(0,0,lvl,true)
    screen:blit(Player.x,Player.y,Player.img)
    screen:blit(Enemy.x,Enemy.y,Enemy.img)
    screen:blit(Stick.x,Stick.y,Stick.img)
    screen:blit(Square.x,Square.y,Square.img)
    screen.waitVblankStart()
    screen.flip()
    end
    end

  15. #7005
    QJ Gamer Green
    Points: 6.449, Level: 52
    Level completed: 50%, Points required for next Level: 101
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    17
    Points
    6.449
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard random numbers

    This is my function for generating random cards and placing them into my hand (this function just generates the card though).

    Code:
    function drawcard1()
    
    randz = math.random(1,6)
    
    if randz == 1 then
    hand1 = Image.load("cards/vector.png")
    end 
    
    if randz == 2 then
    hand1 = Image.load("cards/marshie.png")
    end 
    
    if randz == 3 then
    hand1 = Image.load("cards/ring.png")
    end 
    
    if randz == 4 then
    hand1 = Image.load("cards/luigi.png")
    end 
    
    if randz == 5 then
    hand1 = Image.load("cards/homsar.png")
    end 
    
    if randz == 6 then
    hand1 = Image.load("cards/young_link.png")
    end 
    end

    Is there anyway i can change it so that when a number is chosen it is never picked again? ( or until a new game is started )

    -thanks in advance

  16. #7006
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    wootguy -
    Code:
    -- Globally
    used = {}
    -- Place these 6 lines in your 'NewGame' function for when a new game is started
    used[1] = false
    used[2] = false
    used[3] = false
    used[4] = false
    used[5] = false
    used[6] = false
    
    function drawcard1()
    
    randz = math.random(1,6)
    
    if randz == 1 and used[1] == false then
    hand1 = Image.load("cards/vector.png")
    end 
    
    if randz == 2 and used[2] == false then
    hand1 = Image.load("cards/marshie.png")
    end 
    
    if randz == 3 and used[3] == false then
    hand1 = Image.load("cards/ring.png")
    end 
    
    if randz == 4 and used[4] == false then
    hand1 = Image.load("cards/luigi.png")
    end 
    
    if randz == 5 and used[5] == false then
    hand1 = Image.load("cards/homsar.png")
    end 
    
    if randz == 6 and used[6] == false then
    hand1 = Image.load("cards/young_link.png")
    end
    
    used[randz] = true 
    end
    I believe that should work (Although im pretty out of it right now... 420 and all :P)

    ...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


  17. #7007
    Monster Masher
    Points: 5.084, Level: 45
    Level completed: 67%, Points required for next Level: 66
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Behind you...
    Beiträge
    265
    Points
    5.084
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    doesnt math.random return with decimal places? dont you need to math.round it or am I stuck in another programming language here.

  18. #7008
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    No, Lua Player does it for you. (atleast thats how ive been using it)

    ...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


  19. #7009
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    math.random() by itself will return a number greater than 0 but less than 1, put one number in the brackets and it will return a number between 0 and that number, put two numbers in and it will return a number between the two numbers

  20. #7010
    QJ Gamer Green
    Points: 6.449, Level: 52
    Level completed: 50%, Points required for next Level: 101
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    17
    Points
    6.449
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard random

    that seemed to work, but is there a way i can get more realistic random numbers? because every time i start the game, my first hand is always the same.

    I know that "math.randomseed(os.time( ))" is supposed to give realistic random numbers, but i'm not sure how to use it.

  21. #7011
    QJ Gamer Blue
    Points: 4.369, Level: 42
    Level completed: 10%, Points required for next Level: 181
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    246
    Points
    4.369
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    ermm... you use it just like that....

  22. #7012
    QJ Gamer Green
    Points: 6.449, Level: 52
    Level completed: 50%, Points required for next Level: 101
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    17
    Points
    6.449
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    will it still give random numbers between 1 and 6? and it gives me the error "table index is nil"

  23. #7013
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    math.randomseed(os.time)

    blah = math.random(1,6)

  24. #7014
    QJ Gamer Green
    Points: 6.449, Level: 52
    Level completed: 50%, Points required for next Level: 101
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    17
    Points
    6.449
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    so i put blah under "math.randomseed(os.time( ))"?

  25. #7015
    QJ Gamer Gold
    Points: 11.629, Level: 70
    Level completed: 95%, Points required for next Level: 21
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    1.633
    Points
    11.629
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Dude, if you cant figure that out, please, stop programming.
    And yes, you do.

  26. #7016
    QJ Gamer Green
    Points: 6.449, Level: 52
    Level completed: 50%, Points required for next Level: 101
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    17
    Points
    6.449
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    well the reason i asked was because it wasn't working, but now i know that it's from something else

  27. #7017
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    TP - Its a help forum, he's new, and not everyone knows it must be called only once from the start of hte program, so lay off. So cranky...

    Wootguy - Place it at the start of your script (AKA not in your infinite loop)

    ...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


  28. #7018
    QJ Gamer Green
    Points: 6.449, Level: 52
    Level completed: 50%, Points required for next Level: 101
    Overall activity: 0%

    Registriert seit
    Feb 2007
    Beiträge
    17
    Points
    6.449
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    thanks.

    I also have one last question before I'm done here:
    what does "table index is nil"" mean? The "index" part kinda threw me off.

  29. #7019
    QJ Gamer Blue
    Points: 3.768, Level: 38
    Level completed: 79%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Apr 2007
    Beiträge
    70
    Points
    3.768
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    i hate when peole is like knowit all... poor people. they are lonly.
    well i wass testing somthing whith oop, and got this to work:
    Code:
    --ahrimanes oop starfield
    --usb active
    System.usbDiskModeActivate()
    --crear un nuevo objeto de color
    
    gris1 = Color.new(100,100,100)
    gris2 = Color.new(150,150,150)
    gris3 = Color.new(200,200,200)
    blanco = Color.new(255,255,255)
    
    maxstars = 200
    width = 480-1
    height = 272-1
    timer = 0
    bf = Image.createEmpty(480, 272)
    clsstar = {}
    metastar = {}
    math.randomseed(os.time())
    function drawRect(x, y, width, height, color, w)
    	w:drawLine(x, y, x+width, y, color)
    	w:drawLine(x, y, x, y+height, color)
    	w:drawLine(x+width, y, x+width, y+height, color)
    	w:drawLine(x, y+height, x+width, y+height, color)
    end
    function clsstar:New() 
    	x = math.random(width)
    	y = math.random(height)
    	z = math.random(3)
    	if z == 1 then
    		colora = gris1
    		colorb = gris1
    	end
    	if z == 2 then
    		colora = gris2
    		colorb = gris2
    	end
    	if z == 3 then
    		colora = gris3
    		colorb = gris3
    	end
    	return(setmetatable({Position = {X = x, Y = y, Z = z},colora = colora,colorb = colorb}, metastar))
    end 
    function clsstar:draw() 
    	screen:pixel(self.Position.X,self.Position.Y,self.colora)
    	drawRect(self.Position.X-(self.Position.Z-1)/2,self.Position.Y-(self.Position.Z-1)/2,self.Position.Z-1,self.Position.Z-1,self.colora,screen)
    	self.Position.Y = self.Position.Y + self.Position.Z * 2
    	if self.Position.Y > height then
    		self.Position.Y = 0
    		self.Position.X = math.random(width)
    	end
    end 
    metastar.__index = clsstar 
    starfield = {} 
    for i = 1, maxstars do
    	starfield[i] = clsstar:New()    
    end
    while true do
    	screen:waitVblankStart()	
    	screen:clear()
    	for i = 1, table.getn(starfield) do starfield[i]:draw() end
    	screen:flip()
    	
    	pad = Controls.read()
    	if pad:start() then
    		break
    	end
    end
    ok that work good, but im trayingo somthing else and wont work-
    Code:
    hero = {}
    metahero = {}
    function hero:new() 
    	x = 480/2
    	y = 272/2
    	dx = 0
    	dy = 0
    	angle = 0
    	oldangle = 0
    	speed = 0
    	return(setmetatable({X = x, Y = y, dX = dx, dY = dy, Angle = angle, Oldangle = oldangle, Speed = speed}, metahero))
    end 
    function hero:updt()
    	pad = Controls.read()
    	self.dX = pad:analogX()
    	self.dY = pad:analogY()
    	screen:print(0,0,self.dX,white)
    	screen:print(0,20,self.dY,white)
    	screen:print(0,30,self.X,white)
    	screen:print(0,40,self.Y,white)
    end
    sooo
    ship = hero:new()
    then in mainloop
    ship.updt()
    and i got nil value on this line
    screenrint(0,30,self.X,white)
    whats worng?
    itseems that the new obj hass all his fields nil wy ?

  30. #7020
    Developer
    Points: 4.205, Level: 41
    Level completed: 28%, Points required for next Level: 145
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    San Diego
    Beiträge
    177
    Points
    4.205
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    well at a quick glance, the updt function is called from the hero table, which is where all your classes are stored, but your actual x, y, ect values are stored in the meta hero obj, so when you use self it is accessing the hero template which is the wrong one. I could be wrong though.

    *Edit* After reading the first code set, I see that it uses the same structure. The only difference that I'm going to have to research to understand is this command:

    Code:
    metastar.__index = clsstar
    Maybe that links the two objects in some way, I'm not sure, but if you can explain it that would be great. I never considered using OOP in lua, as the only reason I code in it is because tables are so easy to manipulate. Plus without true pointers, In my mind, it would be hard to keep your objects truely seperate.
    Geändert von KleptoOne (04-21-2007 um 11:35 AM Uhr)


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:01 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .