Seite 292 von 342 ErsteErste ... 192 242 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 ... LetzteLetzte
Zeige Ergebnis 8.731 bis 8.760 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; I got this: Code: screen:print(5,20,"You should take in "..(typingstring*2).." grams of protein each day", white) do I need to change ...

  
  1. #8731
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    I got this:

    Code:
    screen:print(5,20,"You should take in "..(typingstring*2).." grams of protein each day", white)
    do I need to change the typingstring*2?

    go to MSN


    Geändert von Moose (06-15-2008 um 04:36 AM Uhr) Grund: Added [code] tags

  2. #8732
    QJ Gamer Platinum
    Points: 66.627, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    National Front Disco
    Beiträge
    13.057
    Points
    66.627
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    Please remember to add the [CODE] tags where needed. ;)

  3. #8733
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von CoMbiNa Beitrag anzeigen
    I got this:

    Code:
    screen:print(5,20,"You should take in "..(typingstring*2).." grams of protein each day", white)
    do I need to change the typingstring*2?

    go to MSN
    i have to go but here is your answer

    Code:
    screen:print(5,20,"You should take in "..(tonumber(typingstring)*2).." grams of protein each day", white)
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  4. #8734
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    I didn't really understand, what I want is to put this:
    Code:
    typingstring = ""
    so the users can start writing from nothing.
    But of course "" isn't a number, so it gives me an error.

    I'm really confused now

  5. #8735
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Code:
    screen:print(5,20,"You should take in "..((tonumber(typingstring) or 0)*2).." grams of protein each day", white)

  6. #8736
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Hey I want to make a selection between 2 values, it goes like this:

    text number 1: Kilograms to Pounds
    text number 2: Pounds to Kilograms

    Kilograms to Pounds
    Pounds to Kilograms
    When pressing the select button, one of those lines will flash, (appear, disappear, appear, disappear).
    And it will change the wunit value each time
    wunit = kglb
    wunit = lbkg

    Sorry if it's complicted or something

  7. #8737
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von CoMbiNa Beitrag anzeigen
    Hey I want to make a selection between 2 values, it goes like this:...
    What's stopping you?

  8. #8738
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Nielkie Beitrag anzeigen
    What's stopping you?
    I'm kinda new to lua.
    I don't know how to make it flash, and how to make it switch values each click.

  9. #8739
    QJ Gamer Silver
    Points: 6.948, Level: 54
    Level completed: 99%, Points required for next Level: 2
    Overall activity: 0%

    Registriert seit
    Aug 2007
    Beiträge
    657
    Points
    6.948
    Level
    54
    Downloads
    5
    Uploads
    0

    Standard

    Need help...

    How could I take all the binary data from a file, and paste it into a specific hex address in another file ??
    PSP: PSP SLIM 2001 TA-088v2
    Custom Firmware: 5.00 M33-6

  10. #8740
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Assuming I understand correctly you want to go from:
    file1:
    binary stuff
    file2:
    some stuff
    some other stuff
    to:
    file1:
    binary stuff
    file2:
    some stuff
    binary stuff
    some other stuff

    Just some simple IO stuff and some seeking through file2 to get to where you want. The bottom of this has stuff about seeking but I'm not sure how it would apply with hex addresses. Essentially you're trying to make an on-psp hex editor and I haven't messed with that much, mostly just plaintext io.

  11. #8741
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Mr_Shizzy Beitrag anzeigen
    Need help...

    How could I take all the binary data from a file, and paste it into a specific hex address in another file ??
    The fact that you're perceiving it as a hex address matters little, it's still an offset into a file.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  12. #8742
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Code:
    file1 = io.open("file1.bin",rb)
    file2 = io.open("file2.bin",wb)
    file2:seek("set",tonumber("HEXADDRESS",16))
    file2:write(file1:read("*a"))
    file1:close()
    file2:close()

  13. #8743
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Ok, for some reason i cant get this to work, Could someone help me?
    Code:
    --Script
    
    --Colours
    red = Color.new(255,0,0)
    black = Color.new(0,0,0)
    blue = Color.new(0,0,255)
    
    --Images
    col = Image.load("images/col.png")
    background = Image.load("images/lvl-1.png")
    
    --Player
    player = { x = 200, y = 50, img = Image.load("images/play.png") }
    
    while true do
    oldx = player.x
    oldy = player.y
    screen:clear()
    pad = Controls.read()
    
    --Blit images
    screen:blit(0,0,col)
    screen:blit(0,0,background) 
    screen:blit(player.x, player.y, player.img)
    
    colour = col:pixel(player.x + 2, player.y + 15)
    
    if colour == red then 
    player.y = oldy 
    player.x = oldx
    end
    
    And Blah (movement ) 
    
    screen.flip()
    screen.waitVblankStart()
    end
    For some reason the oldx, oldy isnt working??
    i just walk right through,
    Note: the colour on the image has the same RGB so its not that

  14. #8744
    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

    What does the collision image look like?

  15. #8745
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Understand your program's flow, instead of just using examples. At the beginning of the loop, you are setting the oldx and oldy to your players position. Then, if a a colision, you are setting the players position to oldx and oldy. At that point they are already the same, so if a collision, nothing will happen.

  16. #8746
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    EDIT: Double Post (TPG's squid proxy is screwy, so my internet is screwed up)

  17. #8747
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    heres the image

  18. #8748
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Question

    Zitat Zitat von Nielkie Beitrag anzeigen
    Understand your program's flow, instead of just using examples. At the beginning of the loop, you are setting the oldx and oldy to your players position. Then, if a a colision, you are setting the players position to oldx and oldy. At that point they are already the same, so if a collision, nothing will happen.
    Ok, i understand. Though i still dont get how i'd change the script to work?

  19. #8749
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Do you know the purpose of oldx and oldy?

  20. #8750
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    oldx and oldy are for storing your player's position in the previous loop and then if the player collides with something that cannot be walked through, then roll the player back to where he was before (oldx and oldy)
    However, for the player's x and y to change to get him into a spot in which he might need to be rolled back, he needs to move first. Right now you are checking if he has moved into a bad spot and resetting him BEFORE HE EVEN GETS TO MOVE. You need to let him move and THEN check if he has moved into something he can't move into. If you can't figure out how to do that on your own then you need to start over learning lua and take it in smaller bits rather than trying to jump into a game.

  21. #8751
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    I'm using denzeff osk, and I've completed modifying it, but I still need to fix this:

    (What you type in the osk is the "typingstring")
    Code:
    *if typingstring = "" you can't press delete
    Code:
    *you can't press period when:
     typingstring = ""
     or, when there is already one period in the number.
    (that's 3 if's in total that I need for the osk)

    here's the code of the osk if needed: (not the original one, it's the one I made)
    Code:
    displaykeyboard = false
    keyboard = {x = 0, y = 0, mode = 1, key = 5, buffer = "", key_img = Image.load("danzeff/keys1.png"), key_img2 = Image.load("danzeff/keys2.png")}
    keyboard.key_values = {
    	"a,bc","d.ef","g!hi",
    	"j-kl","m\001 n","o?pq",
    	"r(st","u:vw","x)yz",
    					  
    	"A^BC","[email protected]","G*HI",
    	"J_KL","M\001 N",'O"PQ',
    	"R=ST","U;VW","X/YZ",
    					  
    	"\0\0\0001","\0\0\0002","\0\0\0003",
    	"\0\0\0004","\0\001.5","\0\0\0006",
    	"\0\0\0007","\0\0\0008","\0\00009",
    					  
    	"(,.)","<\"'>","[-_]",
    	"{!?}","\0\001 \0","\\+=/",
    	"@:;#","$~`%","^"..string.char(15)..string.char(22).."&"
    }
    
    function keyboard.process(x,y,ctrldata,oldctrldata)
    	keyboard.mode = 5
    
    	if ctrldata:up() or ctrldata:down() then
    		if inputtimer > 20 then inputtimer = 15 end
    		inputtimer = inputtimer + 1
    	else
    		inputtimer = 0
    	end
    
    	local tx = math.floor((ctrldata:analogX()+128)/86)
    	local ty = math.floor((ctrldata:analogY()+128)/86)+1
    	keyboard.key = ty*3-(2-tx)
    
    	if keyboard.mode == 7 then
    		screen:blit(x,y,keyboard.key_img2,0,0,150,150)
    	else
    		screen:blit(x,y,keyboard.key_img,((keyboard.mode+1)/2-1)*150,0,150,150)
    	end
    	local tx = math.mod(keyboard.key,3)
    	if tx == 0 then tx = 2 else tx = tx - 1 end
    	local ty = math.floor(keyboard.key/10*3)
    	if keyboard.mode > 4 then
    		screen:blit(x+tx*43,y+ty*43,keyboard.key_img2,tx*64 + ((keyboard.mode+1-4)/2-1)*192,ty*64+150,64,64)
    	else
    		screen:blit(x+tx*43,y+ty*43,keyboard.key_img,tx*64 + ((keyboard.mode+1)/2-1)*192,ty*64+150,64,64)
    	end
    
    	
    	local t = 0
    	if ctrldata:square() and not oldctrldata:square() then
    		t = 1
    	elseif ctrldata:triangle() and not oldctrldata:triangle() then
    		t = 2
    	elseif ctrldata:cross() and not oldctrldata:cross() then
    		t = 3
    	elseif ctrldata:circle() and not oldctrldata:circle() then
    		t = 4
    	end
    	if t ~= 0 then
    		t = string.sub(keyboard.key_values[((keyboard.mode+1)/2-1)*9+keyboard.key],t,t)
    		if t ~= "\r" then
    			keyboard.buffer = t
    		end
    	end
    end
    
    function keyboard.typeToString(str)
    	if not displaykeyboard then displaykeyboard = true end
    	if keyboard.buffer == "\001" and str ~= "" then
    		str = string.sub(str,1,-2)
    	elseif keyboard.buffer ~= "\000" then
    		str = str..keyboard.buffer
    	end
    	keyboard.buffer = ""
    	return str
    end

  22. #8752
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    ok, i understand thanks TurtlesPWN

  23. #8753
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    YOU made that OSK but you can't figure out how to incorporate some more simple logic into it? BS

    But whatever. Replace the typeToString function:
    Code:
    function keyboard.typeToString(str)
    	if not displaykeyboard then displaykeyboard = true end
    	if keyboard.buffer == "\001" and str ~= "" then
    		str = string.sub(str,1,-2)
    	else 
    		if keyboard.buffer == "." then
    			if str ~= "" and not string.find(str,".") then
    				str = str..keyboard.buffer
    			end
    		elseif keyboard.buffer ~= "\000" then
    			str = str..keyboard.buffer
    		end
    	end
    	keyboard.buffer = ""
    	return str
    end

  24. #8754
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    YOU made that OSK but you can't figure out how to incorporate some more simple logic into it? BS

    But whatever. Replace the typeToString function:
    Code:
    function keyboard.typeToString(str)
    	if not displaykeyboard then displaykeyboard = true end
    	if keyboard.buffer == "\001" and str ~= "" then
    		str = string.sub(str,1,-2)
    	else 
    		if keyboard.buffer == "." then
    			if str ~= "" and not string.find(str,".") then
    				str = str..keyboard.buffer
    			end
    		elseif keyboard.buffer ~= "\000" then
    			str = str..keyboard.buffer
    		end
    	end
    	keyboard.buffer = ""
    	return str
    end
    Made the osk?
    Man I said i've modified it lol
    (your the one that sent me the original remember?)

    can you go to msn?

  25. #8755
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Yes, I know, but read your post:
    "
    here's the code of the osk if needed: (not the original one, it's the one I made)"

  26. #8756
    QJ Gamer Green
    Points: 3.810, Level: 39
    Level completed: 7%, Points required for next Level: 140
    Overall activity: 0%

    Registriert seit
    May 2008
    Beiträge
    246
    Points
    3.810
    Level
    39
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    Yes, I know, but read your post:
    "
    here's the code of the osk if needed: (not the original one, it's the one I made)"
    and also...

    "and I've completed modifying it"

  27. #8757
    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

    Zitat Zitat von CoMbiNa Beitrag anzeigen
    and also...

    "and I've completed modifying it"
    So you made it then modify it?
    Or you modify it then made it?

  28. #8758
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Wink

    Zitat Zitat von Anti-QuickJay Beitrag anzeigen
    So you made it then modify it?
    Or you modify it then made it?
    No, i think someone else made it he modified it lol

  29. #8759
    QJ Gamer Bronze
    Points: 5.092, Level: 45
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    169
    Points
    5.092
    Level
    45
    Downloads
    0
    Uploads
    0

    Standard

    Hey,

    I need some help modifying a string (containing a filename). Every space found should be replaced with a "+".

    Code:
    string.gsub(filename," ","+")
    doesn't work

  30. #8760
    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

    string.gsub returns the new string with the " " replaced with "+", it doesn't modify the string passed to it. Are you assigning it to anything?
    Code:
    new_filename = string.gsub(original_filename, " ", "+")
    If you have been doing this then make sure original_filename does in fact contain spaces.

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



 

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 08:58 PM Uhr.

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