Seite 185 von 342 ErsteErste ... 85 135 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 235 285 ... LetzteLetzte
Zeige Ergebnis 5.521 bis 5.550 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; What's the command to make a new file and the command to paste ? TP's idea sounded right to me, ...

  
  1. #5521
    QJ Gamer Blue
    Points: 4.210, Level: 41
    Level completed: 30%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Sydney, Australia
    Beiträge
    117
    Points
    4.210
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    What's the command to make a new file and the command to paste ?
    TP's idea sounded right to me, but it didn't work (see post above Shroom's)



  2. #5522
    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

    He just copies the stuff inside a file and paste it inside another file, It doenst make a new file.
    His is like copy and overwrite.

  3. #5523
    QJ Gamer Blue
    Points: 4.210, Level: 41
    Level completed: 30%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Sydney, Australia
    Beiträge
    117
    Points
    4.210
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    I think it actually creates the file if it doesn't exist.
    Anyway, what is that error !? What does it mean ?

  4. #5524
    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

    No, you can make a new file, itll automatically create the file you write to if it isnt there. And thats basically the only way to do it. And by .ext i mean .extension, whatever the extension is.

  5. #5525
    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

    Ah, I didn't know that it would automatically make the file, Well im always learning.

  6. #5526
    QJ Gamer Blue
    Points: 4.210, Level: 41
    Level completed: 30%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Sydney, Australia
    Beiträge
    117
    Points
    4.210
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Lol yeah I know that ext is the extension of the file. I need to know how to fix the error lol ! :)

    EDIT: I seem to have fixed that error, a file now appears in the directory I've indicated, however, it is only 1KB in size and contains only 2F6E 0C20 0B20 0220 2F6E (/n . . . /n). I'm not so sure what's wrong...

    Zitat Zitat von Code
    function backup( )
    System.currentDirectory(" c:/scripts")
    copy = io.open("something.dat"," r")
    for line in copy:lines( ) do
    System.currentDirectory(" c:/")
    paste = io.open("something.dat"," w")
    paste:write(line.."/n")
    end
    end
    Geändert von TheBressman (02-03-2007 um 11:00 PM Uhr)

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

    I found an interesting set of functions, it allows you to load and save tables to and from files:

    http://lua-users.org/wiki/SaveTableToFile

    If what your planning on in the end is to save and load tables, as if you were loading a saved game (like level, map, guns, ammo, etc.), than use this.

    If not, than your problem there is, im guessing, is 'lines' is simply the hex offset of what line your on... Also, if your tring to copy exactly the same as the file you loaded in, there is no need for hte '\n', as file:read also reads in the newline character, so youd actually be double spacing whatever file your triyng to copy ;)
    Code:
    function backup( )
    System.currentDirectory(" c:/scripts")
    copy = io.open("something.dat"," r")
    paste = io.open("something.dat"," w")
    System.currentDirectory(" c:/")
    for line in copy:lines( ) do
    paste:write(line)
    end
    end
    Try that...

    If it doesnt work, ill take the time to write a working one (im searching ebay for some stuff, but i can take a break ;))

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


  8. #5528
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    hey TP,

    Im trying to make it so that in a browser, if you click on a directory that contains "index.lua" then it runs that file., Would you, (or any body else) know how to do that?
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.

  9. #5529
    QJ Gamer Blue
    Points: 4.210, Level: 41
    Level completed: 30%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Sydney, Australia
    Beiträge
    117
    Points
    4.210
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    @SG57: Cheers, but now I get the same error as before
    (error: Attempt to index global 'copy' (a nil value))

    EDIT: Lol, this is getting crazy. I fixed it again by getting rid of some stupid spaces I put in, but the file created consists of 4C4F 434B FFFF 32 (LOCK..2).

  10. #5530
    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

    BlackShark - look at gpack v.2, as TP made that one. But honestly, its not all that hard... This is basically what you are asking for:
    Code:
    fileSystem = System.listDirectory("ms0:/")
    file = 1
    oldpad = Controls.read()
    
    while true do
      pad = Controls.read()
      if pad ~= oldpad then
        if pad:up() and file > 1 then file = file - 1
        elseif pad:down() and file < table.getn(fileSystem) then file = file + 1 end
    
        if pad:cross() and fileSystem[file].name == "index.lua" then dofile(fileSystem[i].name) end
      end
    
      screen:clear()
      for i=1,table.getn(fileSystem) do
          screen:print(10,i*10,fileSystem[i].name,Color.new(255,255,255)) 
      end
      screen:print(11,file*10,fileSystem[file].name,Color.new(0,255,0))
    
      screen.waitVblankStart()
      screen.flip()
      oldpad = pad
    end
    Very simpleand easy to make, dont be fooled now.
    -= Double Post =-
    TheBressman - post exactly what you have, as Id like to work with your exact code so I know its not YOU making hte mistake during hte copy&paste.
    Geändert von SG57 (02-04-2007 um 12:34 AM Uhr) Grund: Automerged Doublepost

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


  11. #5531
    QJ Gamer Blue
    Points: 4.210, Level: 41
    Level completed: 30%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Sydney, Australia
    Beiträge
    117
    Points
    4.210
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Alright then.

    Zitat Zitat von Code
    -- Registry backup function
    function backup( )
    System.currentDirectory(" c:/registry")
    copy = io.open("system.dreg","r" )
    System.currentDirectory(" c:/")
    paste = io.open("system.dreg","w" )
    for line in copy:lines( ) do
    paste:write(line)
    end
    end
    PS: Weird forum editing is putting a space between " and c in "c:/registry" and "c:/"

  12. #5532
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TacticalPinguin
    Try something like:

    memfree = System.getFreeMemory()/1024/1024
    print("About "..math.floor(memfree+0.5 ).." megabytes of free memory")

    The math.floor(memfree+0.5) part rounds it to the nearest number. It's about, not exactly.
    the strange thing is, that System.getFreeMemory / 1024 / 1024 will get number 18, but my free memory is 288..... strange o_O

  13. #5533
    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

    TheBressman - Try this:
    Code:
    System.currentDirectory ("c:/registry/")
    Instead of what you have.

    ...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. #5534
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    PLS can anyone test:

    System.getFreeMemory()

    in his PSP ????????

    does this get free memory on memory stick???

  15. #5535
    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

    myschoo - System.getFreeMemory returns the number of bytes free on the memory card. To get kilobytes, divide it by 1000. To get megabytes, divide it by 1000000. So...
    Code:
    screen:print(0,0,System.getFreeMemory/1000000 .. "megabytes",Color.new(255,0,0))
    Does this or does this not print out how much space you have free, if not, than your memory stick must have some weird formatting or be fake or something...
    Geändert von SG57 (02-04-2007 um 04:04 AM Uhr)

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


  16. #5536
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    it gives you the free space of ram, not the memory stick. lol

    edit - i double posted...lol
    Geändert von EminentJonFrost (02-04-2007 um 05:45 AM Uhr) Grund: Automerged Doublepost
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  17. #5537
    QJ Gamer Green
    Points: 11.800, Level: 71
    Level completed: 38%, Points required for next Level: 250
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Ort
    Middle Europe
    Beiträge
    1.281
    Points
    11.800
    Level
    71
    Downloads
    0
    Uploads
    0

    Standard

    omg
    i thought so... Lol !
    because i have SanDisk Ultra II 100% percent not fake...

    thx for explanation Eminent ;)

  18. #5538
    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

    Hmm... to get free space from memory, maybe... First get how much memory has been used on the memory stick by adding up all the sizes of the files found through a recursive scan of 'ms0:/' and add that to the amount able to be written. So - write to a file, one byte at a time, or 100 bytes at a time, or some interval for how accurate you want to be, until it cant write anymore. Thats my theory...

    ...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. #5539
    QJ Gamer Silver
    Points: 7.371, Level: 57
    Level completed: 11%, Points required for next Level: 179
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    貴方
    Beiträge
    1.159
    Points
    7.371
    Level
    57
    Downloads
    0
    Uploads
    0

    Standard

    how to unload images from ram?

  20. #5540
    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

    headshot - To free anything from RAM, set it's value to nil.
    Code:
    image = Image.load("blah.png") -- allocate memory for image and store image data
    image = nil -- free image data from ram
    
    sound = Sound.load("blah.wav") -- allocate memory for sound and store it
    sound = nil -- free sound data from memory

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


  21. #5541
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57
    headshot - To free anything from RAM, set it's value to nil.
    Code:
    image = Image.load("blah.png") -- allocate memory for image and store image data
    image = nil -- free image data from ram
    
    sound = Sound.load("blah.wav") -- allocate memory for sound and store it
    sound = nil -- free sound data from memory
    Slightly incorrect. You have to 'nil' or remove all references to the data in RAM.

    Code:
    Blah = Image.load("blah.png"); -- allocate memory for image and store image data
    Blah2 = Blah;
    Blah = nil; -- blah.png not flagged for removal for the garbarge collection because Blah2 still references to it
    Blah2 = nil -- blah.png is now flagged for removel for the garbarge collection because no variables reference to it

  22. #5542
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von yaustar
    Slightly incorrect. You have to 'nil' or remove all references to the data in RAM.

    Code:
    Blah = Image.load("blah.png"); -- allocate memory for image and store image data
    Blah2 = Blah;
    Blah = nil; -- blah.png not flagged for removal for the garbarge collection because Blah2 still references to it
    Blah2 = nil -- blah.png is now flagged for removel for the garbarge collection because no variables reference to it
    but what if Blah2 wasnt there in the first place? THEN would SG be "fully" correct?
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  23. #5543
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von EminentJonFrost
    but what if Blah2 wasnt there in the first place? THEN would SG be "fully" correct?
    No, he will be partially correct.

  24. #5544
    Points: 8.718, Level: 62
    Level completed: 90%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Beiträge
    484
    Points
    8.718
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    When i start this it just shows the black screen from when the loop starts. But how come the if statment doesnt worK!!??
    Code:
    white =Color.new(255,255,255)
    red =Color.new(255,0,0)
    background =Image.load("Background.png")
    man =Image.load("Man.png")
    x,y = 240,136;
    
    screen:clear()
    screen:print(0,0,"Connecting...",Color.new(255,0,0))
    screen.flip()
    dofile("netlib.lua")
    netlib_server = "66.25.53.65"
    Wlan.init()
    Wlan.useConnectionConfig(1)
    System.sleep(50)
    screen.flip()
    screen:print(0,10,"Connecting to netlib...",Color.new(255,255,255))
    screen.flip()
    netconnect()
    System.sleep(50)
    screen.flip()
    y = 0
    p1 = y
    netsend("p1",y,"w")
    netget("p1")
    
    
    while true do
    screen:clear()
    	netrecv()
    	buffer = netvalue("p1")
    		if buffer == "0" then 
    			screen:print(0,0,buffer,red)
               end
    screen.waitVblankStart(); 
    screen.flip()
    end
    -= Double Post =-
    That is just pat of my game by the way
    -= Double Post =-
    Anyone??
    Geändert von pspfreak9 (02-04-2007 um 02:50 PM Uhr) Grund: Automerged Doublepost

  25. #5545
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    maybe cause 'buffer' does not equal zero...lol
    from what you posted, it looks like theres something going in netlib.lua affecting 'buffer'.
    (but i cant tell since buffer doesnt even show up anywhere in the script you put up before that 'if' loop)
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  26. #5546
    Points: 8.718, Level: 62
    Level completed: 90%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Beiträge
    484
    Points
    8.718
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Buffer is netvalue("p1") and i sent 0 to p1 read from the begining

  27. #5547
    QJ Gamer Green
    Points: 13.310, Level: 75
    Level completed: 15%, Points required for next Level: 340
    Overall activity: 0%

    Registriert seit
    Dec 2005
    Ort
    Here
    Beiträge
    2.715
    Points
    13.310
    Level
    75
    Downloads
    0
    Uploads
    0

    Standard

    if by some slim chance, your problem wasnt from net coding, i mightve been able to help. but i'm no use here since it is.
    sorry.
    [CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]

  28. #5548
    Points: 8.718, Level: 62
    Level completed: 90%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Beiträge
    484
    Points
    8.718
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    ok thx for trying anyone have experinece coding with netlib

  29. #5549
    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

    pspfreak - Your comparing "0" to buffer. Your saying you sent the value 0, not the char '0', so it shouldnt run as 0x00 is differnent than 0x30.

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


  30. #5550
    QJ Gamer Silver
    Points: 7.278, Level: 56
    Level completed: 64%, Points required for next Level: 72
    Overall activity: 0%

    Registriert seit
    Oct 2006
    Ort
    Pimp'en in the US F#
    Beiträge
    1.254
    Points
    7.278
    Level
    56
    Downloads
    0
    Uploads
    0

    Standard

    Aright, im Editing TP's browser, and want to make it so that if you click on a directory with "index.lua" inside it then it launches the index.lua.

    This is what I have so far?


    if pad:cross() and oldpad:cross() ~= pad:cross() and bfold == true and fl[s].directory == true then
    System.currentDirectory(f l[s].name)
    s = 1
    fl=System.listDirectory()
    nf=table.getn(fl)
    elseif pad:cross() and oldpad:cross() ~= pad:cross() and bfold == true and fl[s].directory == true and string.lower(fl[s].name) == "index.lua" then
    dofile("index.lua")
    System.currentDirectory(" ./../..")
    end
    The Wentire Worls in two Sectors....
    When did I get dev statz?
    Spoiler for my PSP homebrewReleases:
    Ace of Space V1|PvP Pong Online|PvP Pong v3 | 3.03 BlackShark Custom Firmware
    (PvP Pong DL'ed well over 2403 times combined! get yours now!)
    Spoiler for Great Quotes:

    "No Snowflake in an Avalanche ever feels responsible....." - Fortune Cookie.


 

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 .