Page 2 of 13 FirstFirst 1 2 3 4 12 ... LastLast
Results 11 to 20 of 122

Thread: Lua Help Thread

  
  1. #11
    soulkiller is offline -Hacks Smarty
    Join Date
    Jan 2006
    Location
    pffff I\'m not telling you
    Posts
    197
    Rep Power
    14

    Default

    hmmm isn't 3d rotation a whole nother ball game compared to rotation of 2d objects?

    GOOGLE IS YOUR FREIND, USE IT. IF GOOGLE FAILS THEN REFER TO THIS LINK MQ:BtG Programmer

  2. #12
    ss13801 is offline -Hacks Neophyte
    Join Date
    Jan 2006
    Posts
    55
    Rep Power
    14

    Default

    Hey
    Is there a way in LUA to get total space of memory stick, whats left on stick??

    Thanks

  3. #13
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    Quote Originally Posted by soulkiller
    hmmm isn't 3d rotation a whole nother ball game compared to rotation of 2d objects?
    nope,
    it will work think about it.

    Quote Originally Posted by ss13801
    Hey
    Is there a way in LUA to get total space of memory stick, whats left on stick??

    Thanks
    I do not know of a lua function for that, my search came up with nothing as well. You could run the c++ code from lua you know and get the call that way. I'd ask Nevyn or Shine they'd know, or if you want to take a wild shot psplua.com / ps2dev.org
    july 19

  4. #14
    soulkiller is offline -Hacks Smarty
    Join Date
    Jan 2006
    Location
    pffff I\'m not telling you
    Posts
    197
    Rep Power
    14

    Default

    Hey i checked out the 3d cube demo and said wtf? I'm sorry I ain't to good at 3d and don't understand almost any of it please give me a liitle more gudence as what to do?
    GOOGLE IS YOUR FREIND, USE IT. IF GOOGLE FAILS THEN REFER TO THIS LINK MQ:BtG Programmer

  5. #15
    GreenAndi is offline -Hacks Newbie
    Join Date
    Dec 2005
    Location
    Western Australia
    Posts
    11
    Rep Power
    0

    Default

    Everyone :D
    this is my first Lua script. i want to make PSP Lua Bible. [ that i know there is a Bible for PSP but need web browser...hate that]
    here is my first code [system.lua]


    -- PSP LUA Bible v1.0
    -- By GreenAndi

    -- colors
    white = Color.new(255,255,255)

    -- print on screen
    screen:print(10, 10, "PSP LUA BIBLE v1.0", white)

    screen:print(15, 30, "> Old Testament", white)
    screen:print(15, 40, "> New Testament", white)

    -- onscreen
    screen.flip()

    -- loops
    while true do
    screen.waitVblankStart()
    end

    next, what i want to do are [but i don't know how to write the code]
    1. when the system.lua load[run in lua player], the "> Old Testament" , highlighted in green colour and black in the text.

    2. when i push control pad down, it will be the same as the "> New Testament" highlighted in green colour and black in the text. and the Old Testament back to its original colour, white.

    3. as if i push control pad up again, the something will happen as no. 2 - back to the Old testement.

    3. got what i meant ? there is only 2 options, choose Old or New, then when if i chosen Old Testament, then push pad cross [load] will be bring me to the other script [Old.lua] <<< think about it later

    4. last, maybe i will add sounds to the menu option, like when move to the next option down or up, "blink" sound will hear. [just an idea, see how it will be going]

    5 for the next develompmnt, i will add more features. like file browser, picture viewer, text reader ,etc [ see later]

    the important bit is number 1, 2 and 3
    could someone give me hits how to coding them
    thank you very much
    --- PSP LUA BIBLE v1.0, freely distributed, develop ... do whatever you want as you like :D ---
    God Bless

  6. #16
    soulkiller is offline -Hacks Smarty
    Join Date
    Jan 2006
    Location
    pffff I\'m not telling you
    Posts
    197
    Rep Power
    14

    Default

    Ok I can anwser that one. This is from a wlan script I made that would let you pick your connection then chose if you would like to load a url from a file or type it in manualy (didn't finsish the actual loading of url :D )

    Ok first get ride of your
    Code:
     
        while true do
            screen.waitVblankStart()
        end
    Then add this into the bottom

    Code:
    --Decalre our varibles and arrays (or as lua calls tham "tables")
    green = Color.new(0,255,0)
    oldpad = Controls.read()
    padsel = {}
    padsel[1] = 1
    padsel[2] = 0
    while true do
            --Clear the screen and update the controls
            pad = Controls.read()
    	screen:clear()
    	--Check if the controls are being pressed, if so assign new value in array/table
            if pad:down() and oldpad:down() ~= pad:down() then
    		if padsel[1] == 1 then
    			padsel[1] = 0
    			padsel[2] = 1
    		else
    			padsel[2] = 0
    			padsel[1] = 1
    		end
    	end
    	if pad:up() and oldpad:up() ~= pad:up() then
    		if padsel[1] == 1 then
    			padsel[1] = 0
    			padsel[2] = 1
    		else
    			padsel[2] = 0
    			padsel[1] = 1
    		end
    	end
            --This one is to check if One of them has been selected, if so save the chosen one to the "sel" varible and then break
    	if pad:cross() and oldpad:cross() ~= pad:cross() then
    		if padsel[1] == 1 then
    			sel = 1
    		end
    		if
     padsel[2]
     == 1 then
    			sel = 2
    		end
    		break
    	end
            --now we print the selection
    	screen:print(10, 10, "PSP LUA BIBLE v1.0", white)
            if padsel[1] == 1 then
                    screen:print(15, 30, "> Old Testament", green)
                    screen:print(15, 40, "> New Testament", white)
    	end
    	if pad sel[2] == 1 then
                    screen:print(15, 30, "> Old Testament", white)
                    screen:print(15, 40, "> New Testament", green)
    	end
            --We flip the buffers so we see our updated screen and then we freeze it and update our oldpad varible
    	screen.flip()
    	screen.waitVblankStart()
    	oldpad = pad
    end
    no after that what you would do is put in a loop that checks for the selection
    so basicly if the user chose the old teastment then the varible "sel = 1" if they chose the new testement then "sel = 2" so after that it would say something like

    Code:
    if sel == 1 then
             --display old testement
    end
    if sel == 2 then
             --display new testement
    end
    btw anybody can use my selection script but take note that it only works for two selections I have made one for multiple selections and if anybody wants it I'll gladly post it
    Hope all this helped :D
    GOOGLE IS YOUR FREIND, USE IT. IF GOOGLE FAILS THEN REFER TO THIS LINK MQ:BtG Programmer

  7. #17
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    GreenAndi - looks like soulkiller beat me to it.

    Soulkiller -

    Fine:

    function rotate(image, dir)
    local w = image:width()
    local h = image:height()
    local result = Image.createEmpty(h, w)

    for x=0,w-1 do
    for y=0,h-1 do
    if dir == 0 then
    result:pixel(h-y-1, x, image:pixel(x, y))
    else
    result:pixel(y, w-x-1, image:pixel(x, y))
    end
    end
    end

    To call

    blueboat = Image.load("blueboat.png")
    --90° Clockwise:
    blueboat = rotate(blueboat, 0)
    screen:blit(0, 0, tank, 0, 0, blueboat:width(), blueboat:height(), false)
    --90° Counter-Clockwise:
    blueboat = rotate(blueboat, 1)
    screen:blit(0, 0, tank, 0, 0, tank:width(), tank:height(), false)

    return result
    end

    If psp lua player supported the GD library (which is doesn't currently) then you would be able to use this function: gd.copyRotated(dstImage, srcImage, dstX, dstY, srcX, srcY, srcW, srcH, ang)
    dstImage:copyRotated(srcImage, dstX, dstY, srcX, srcY, srcW, srcH, ang)



    In other news, Dark Killer ( ;) ) has added a few interesting commands that you can all use in V 0.17dk2.
    http://en.wikipedia.org/wiki/Lua_Player

    1. Added System.Quit() which will exit Lua Player back to the PSP browser
    2. Added System.isUmdInserted() and will return true if a UMD is inserted
    3. Added System.initUMD() which will mount the UMD to disk0: (it will not launch it)
    4. Added System.setCpuSpeedHigh(), System.setCpuSpeedMed(), and System.setCpuSpeedReg() which changes the CPU speed to 333 MHz, 266 MHz, and 222 MHz respectively.

    This will help your apps run smoother 8)
    july 19

  8. #18
    joshparrisjosh is offline -Hacks Newbie
    Join Date
    Apr 2006
    Posts
    1
    Rep Power
    0

    Default

    Lately i've been having an overly frustating time trying to figure out how to blit an image to the screen, using the tile system and a mapsource. Can someone please try and help me out.

    Heres my source code

    Layer1=Image.load("StarOcean.png")

    Layer1tiles={{x=11, y=4},
    {x=12, y=4},
    {x=13, y=4},
    {x=14, y=4},
    {x=11, y=5},
    {x=12, y=5},
    {x=13, y=5},
    {x=14, y=5},
    {x=11, y=6},
    {x=12, y=6},
    {x=13, y=6},
    {x=14, y=6},
    {x=11, y=7},
    {x=12, y=7},
    {x=13, y=7},
    {x=14, y=7} }

    Mapdata={}
    for i=1,16 do
    Mapdata[i]=i
    end

    function draw(x,y,spot)
    screen:blit(x*32,y*32,Layer1,spot.x*32,spot.y*32,32,32)
    end

    function HandleTiles()
    for i=1,table.getn(Mapdata) do
    if i==1 then x,y=0,0
    elseif i==5 then x,y=0,32
    elseif i==9 then x,y=0,64
    elseif i==13 then x,y=0,96
    end
    draw(x,y,Layer1tiles[Mapdata[i]])
    x=x+32
    end
    x,y=0,0
    end

    while true do
    pad=Controls.read()
    if pad:start() then break end
    HandleTiles()
    screen.waitVblankStart()
    screen.flip()
    end
    For some reason it only blits one tile to the screen... Im not quire sure whats wronge and whats right so any advise at all would be appreciated. thanks

  9. #19
    illfoundedmind is offline -Hacks Enthusiast
    Join Date
    Nov 2005
    Location
    WTF~~~~~~~~~~> Rank: %NULL
    Posts
    389
    Rep Power
    15

    Default

    oh yes the power of tilesets. Well if your working with tilesets then you're making a video game most likely... and RPG?

    Your Layer1tile array is illogical, and the whole structure of your code should be optimized greatly -- there is a much more easier way to do it and save memory.

    This would be the problem:
    for i=1,table.getn(Mapdata) do
    if i==1 then x,y=0,0
    elseif i==5 then x,y=0,32
    elseif i==9 then x,y=0,64
    elseif i==13 then x,y=0,96
    end
    draw(x,y,Layer1tiles[Mapdata[i]])
    x=x+32
    end
    x,y=0,0
    end

    Now there is two possiblities, either it is only going through the loop once, or it is drawing the tiles in the same place. I can tell you need to improve your debugging skills so I'll let you figure it out I narrowed down the field. Get too stuct and I'll help.

    I'd recommend joining up at the development team in my sig if you want to make an RPG (it is too big a project for one person)
    july 19

  10. #20
    soulkiller is offline -Hacks Smarty
    Join Date
    Jan 2006
    Location
    pffff I\'m not telling you
    Posts
    197
    Rep Power
    14

    Default

    hmmmmmm illfoundedmind won't that just rotate images by 90 degree angles?
    if it is, what I ment was rotation of images in angles such as 30 degrees. I thought in order to do this you would need some kinda of trigometric formula like match.sin(pi / 2) or something like that to find you new x position but then again you are alot better then me at this so I'm not very sure
    GOOGLE IS YOUR FREIND, USE IT. IF GOOGLE FAILS THEN REFER TO THIS LINK MQ:BtG Programmer

Page 2 of 13 FirstFirst 1 2 3 4 12 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •