Seite 341 von 342 ErsteErste ... 241 291 331 332 333 334 335 336 337 338 339 340 341 342 LetzteLetzte
Zeige Ergebnis 10.201 bis 10.230 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 realize how this would be done in theory, however, don'thave the knowledge to actually program the code. (How would ...

  
  1. #10201
    Points: 1.369, Level: 20
    Level completed: 69%, Points required for next Level: 31
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Dec 2009
    Ort
    east brunswick
    Beiträge
    7
    Points
    1.369
    Level
    20
    Downloads
    0
    Uploads
    0

    Standard

    I realize how this would be done in theory, however, don'thave the knowledge to actually program the code.

    (How would i do this code-wise?)



  2. #10202
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von Creek Beitrag anzeigen
    I realize how this would be done in theory, however, don'thave the knowledge to actually program the code.

    (How would i do this code-wise?)
    mousex = mousex-1; //move left

    pick up a book, google basic programming logic, u've alot to learn
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  3. #10203
    Points: 1.369, Level: 20
    Level completed: 69%, Points required for next Level: 31
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Dec 2009
    Ort
    east brunswick
    Beiträge
    7
    Points
    1.369
    Level
    20
    Downloads
    0
    Uploads
    0

    Standard

    I think you're misunderstanding me, i understand the mousex = mousex - 1 part. (Funny that you used a C++ comment. ^^) What i don't, however, is how to connect the "mouse" variable to the actual analog.

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

    if pad:analogX() > 99 then
    --moving right
    end

    if pad:analogX() <-99 then
    --moving left;
    end

    That is if you using LP or LPE or LPHM.
    Pge would be:
    if pge.controls.analogx() > 99 then

    if pge.controls.analogx() < -99 then

    The range is 128 to -128

  5. #10205
    Points: 1.369, Level: 20
    Level completed: 69%, Points required for next Level: 31
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Dec 2009
    Ort
    east brunswick
    Beiträge
    7
    Points
    1.369
    Level
    20
    Downloads
    0
    Uploads
    0

    Standard

    My problem is the actual
    --moving right
    part.

  6. #10206
    Lua Coder
    Points: 18.915, Level: 87
    Level completed: 13%, Points required for next Level: 435
    Overall activity: 99,0%

    Registriert seit
    Jan 2008
    Ort
    Iowa
    Beiträge
    834
    Points
    18.915
    Level
    87
    My Mood
    Busy
    Downloads
    2
    Uploads
    0

    Standard

    heres some example code in lua
    Code:
    cursor = {
    x = 0,
    y = 0,
    img = Image.load("img.png")
    }
    
    while true do
    pad = controls.read()
    if pad:analogX() > 90 then
    cursor.x = cursor.x + 1
    end
    if pad:analogX() < -90 then
    cursor.x = cursor.x - 1
    end
    end
    id try working your way through these tutorials linky

  7. #10207
    PSPInstaller Developer
    Points: 12.184, Level: 72
    Level completed: 34%, Points required for next Level: 266
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    _
    Beiträge
    130
    Points
    12.184
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard [PGELua] Search Function Help

    Ok, I am looking to finally implement the search function in PSPInstaller.

    I have a master list of all repo's eg;
    Code:
    srclist[1] = {ho = "MeqSoft" , ha = "The PSPInstaller Default Repository", hd = "http://in.rsparrow.co.uk/MEQSOFT.LUA", hf="MEQSOFT.LUA"}
    srclist[2] = {ho = "Repo 1", ha = "REPO 1 Description", hd="http://www.domain.co.uk/REPO.LUA", hf="REPO1.LUA"}
    srclist[3] = {ho = "Repo 2", ha = "REPO 2 Description", hd="http://www.domain.co.uk/REPO.LUA", hf="REPO2.LUA"}
    and each repo contains the following (with there own files ofc) :

    Code:
    last_update=1262908073
    directory_to_repo="http://repoprep.pspinstaller.lan/download.php?file="
    gl[1]={i=8,n="Dummy Game 2",d="This is a dummy Game",f="Game2.zip"}
    gl[2]={i=9,n="Dummy Game 3",d="This is a dummy Game",f="Game3.zip"}
    gl[3]={i=10,n="Dummy Game 4",d="This is a dummy Game",f="Game4.zip"}
    gl[4]={i=11,n="Dummy Game 5",d="This is a dummy Game",f="Game5.zip"}
    al[1]={i=12,n="Dummy App 2",d="This is a dummy App",f="App2.zip"}
    al[2]={i=13,n="Dummy App 3",d="This is a dummy App",f="App3.zip"}
    al[3]={i=14,n="Dummy App 4",d="This is a dummy App",f="App4.zip"}
    al[4]={i=15,n="Dummy App 5",d="This is a dummy App",f="App5.zip"}
    al[5]={i=1,n="Dummy Application",d="This is a dummy app.",f="app.zip"}
    tl[1]={i=4,n="Dummy Theme 2",d="This is a dummy theme",f="theme2.zip"}
    tl[2]={i=5,n="Dummy Theme 3",d="This is a dummy theme",f="theme3.zip"}
    tl[3]={i=6,n="Dummy Theme 4",d="This is a dummy theme",f="theme4.zip"}
    tl[4]={i=7,n="Dummy Theme 5",d="This is a dummy theme",f="theme5.zip"}
    tl[5]={i=3,n="Dummy Theme",d="This is a dummy theme",f="theme.zip"}
    ol[1]={i=16,n="Dummy Other 2",d="This is a dummy Other",f="Other2.zip"}
    ol[2]={i=17,n="Dummy Other 3",d="This is a dummy Other",f="Other3.zip"}
    ol[3]={i=18,n="Dummy Other 4",d="This is a dummy Other",f="Other4.zip"}
    ol[4]={i=19,n="Dummy Other 5",d="This is a dummy Other",f="Other5.zip"}
    ol[5]={i=2,n="Dummy Other",d="This is a dummy file for other.",f="other.zip"}
    using the srclist.hf[ x ] in a loop, how would I find all the diffrent tables with a certain search keyword in it?

    something like (PSEUDO CODE) (Sorry for incorrect spelling of Pseudo :P)
    Code:
    for k,1 to #srclist do
     open srclist.hf[k] as reading
       for g,1 to #gl do
        search string
        insert into new table all found results
       end
       for a,1 to #al do
        search string
        insert into new table all found results
       end
       for t,1 to #tl do
        search string
        insert into new table all found results
       end
       for o,1 to #ol do
        search string
        insert into new table all found results
       end
     close.file
    end
    Something like that... help?!
    _

  8. #10208
    PSPInstaller Developer
    Points: 12.184, Level: 72
    Level completed: 34%, Points required for next Level: 266
    Overall activity: 0%

    Registriert seit
    Jan 2007
    Ort
    _
    Beiträge
    130
    Points
    12.184
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    ok, I have :

    Code:
    	if state == 3 then
    		img_sear:activate()
    		img_sear:draweasy(0,0)
    		arial:activate()
    		arial:print(120,55,white,"Please press (X) to start a search")
    		searchstr=""
    		if not pge.utils.oskinit("Enter Search String", "") then
    			error("Error on osk init.")
    		end
    
    		
    		while pge.running() do
    			pge.gfx.enddrawing()
    			pge.gfx.swapbuffers()
    			pge.controls.update()
    			pge.gfx.startdrawing()
    			img_sear:activate()
    			img_sear:draweasy(0,0)
    			pge.gfx.enddrawing()
    			result, searchstr = pge.utils.oskupdate()
    			if result then
    				state = 31
    				break
    			end
    			pge.gfx.swapbuffers()
    			pge.gfx.startdrawing()
    		end
    		if pge.controls.pressed(PGE_CTRL_LTRIGGER) then
    			state=2
    		end
    		if pge.controls.pressed(PGE_CTRL_RTRIGGER) then
    			state=4
    		end
    	end
    
    	if state == 31 then
    		sr = {}
    		q=1
    		while srclist[scan] do
    			dofile(srclist[scan].hf)
    			sglm = #gl
    			for sg,1 to sglm then
    				sgn = gl.n[sg]
    				sgd = gl.d[sg]
    				sgf = gl.f[sg]
    				sgi = gl.i[sg]
    				if string.find(sgn, searchstr) or string.find(sgd, searchstr) or string.find(sgf,searchstr) then
    					sr[q] = { i = sgi, n = sgn, d = sgd, f = sgf, l = srclist[scan].hf, h=srclist[scan].ho }
    					q = q + 1
    				else
    				end
    			end
    			salm = #al
    			for sa,1 to salm then
    				san = al.n[sa]
    				sad = al.d[sa]
    				saf = al.f[sa]
    				sai = al.i[sa]
    				if string.find(san, searchstr) or string.find(sad, searchstr) or string.find(saf,searchstr) then
    					sr[q] = { i = sai, n = san, d = sad, f = saf, l = srclist[scan].hf, h=srclist[scan].ho }
    					q = q + 1
    				else
    				end
    			end
    			stlm = #tl
    			for st,1 to stlm then
    				stn = tl.n[st]
    				std = tl.d[st]
    	stf = tl.f[st]
    				sti = tl.i[st]
    				if string.find(stn, searchstr) or string.find(std, searchstr) or string.find(stf,searchstr) then
    					sr[q] = { i = sti, n = stn, d = std, f = stf, l = srclist[scan].hf, h=srclist[scan].ho }
    					q = q + 1
    				else
    				end
    			end
    			solm = #ol
    			for so,1 to solm then
    				son = ol.n[so]
    				sod = ol.d[so]
    				sof = ol.f[so]
    				soi = ol.i[so]
    				if string.find(son, searchstr) or string.find(sod, searchstr) or string.find(sof,searchstr) then
    					sr[q] = { i = soi, n = son, d = sod, f = sof, l = srclist[scan].hf, h=srclist[scan].ho }
    					q = q + 1
    				else
    				end
    			end
    
    
    		end
    		if #sr then
    			state = 32
    		else
    			state = 33
    		end
    	end
    But I keep getting an error on line 970:
    Code:
    '<name>' expected near '1'
    line 970 is offset from the rest but just to make clear line 970 is :
    Code:
    stf = tl.f[st]
    _

  9. #10209
    QJ Gamer Green
    Points: 2.236, Level: 28
    Level completed: 58%, Points required for next Level: 64
    Overall activity: 0%

    Registriert seit
    Nov 2008
    Beiträge
    35
    Points
    2.236
    Level
    28
    Downloads
    0
    Uploads
    0

    Standard

    i need help with making a truncated number in LPHMv2

    here's my code for it:

    Code:
    freespace1 = System.getFreeSpace("ms0:/")/1024^2
    freespace2 = string.format("%.2f", freespace1)
    totalspace1 = System.getTotalSize("ms0:/")/1024^2
    totalspace2 = string.format("%.2f", totalspace1)
    
    screen.startDraw()
    screen.clear(0)
    Image.blit(0, 0, bg)
    Font.print(Arial, 295, 120, "" .. freespace2 .. " MB/" .. totalspace2 .. " MB", black)
    screen.endDraw()
    screen.flipscreen()
    Everything shows and it's truncated with into hundredths the way i want it but the problem is that the number that appears is 0.00 MB/0.00 MB even though it's supposed to be the spaces on the memory stick.
    please help.

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

    thatoneguy - Try printing System.getFreeSpace("ms0:/") and System.getTotalSize("ms0:/") as a test to see if they are returning > 0 values. Odds are its another dodgey LPHM function that doesn't work properly.

    ...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. #10211
    QJ Gamer Green
    Points: 2.236, Level: 28
    Level completed: 58%, Points required for next Level: 64
    Overall activity: 0%

    Registriert seit
    Nov 2008
    Beiträge
    35
    Points
    2.236
    Level
    28
    Downloads
    0
    Uploads
    0

    Standard

    sg57 - it does work, i made sure of that before i posted the code. it's probably just another function that doesn't work like its supposed to.

  12. #10212
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Hello I'm brand new to programming. I'm trying to develop a way simulate the Multi-Tap key press style found in many cellphones where you can input text by pressing the numpad multiple times. Instead I want to map the letters onto the PSP pad.

    As I said I'm still very new to programming, I'm just following a lot of tutorials online. So sorry if my code is really sloppy or nonsensical:

    Code:
    white = Color.new(255,255,255)
    red = Color.new(255,0,0) 
    
    characters = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", " " } 
    crap = { "x", "y", "z", "v", "w", "x", "y", "z", " " }
    
    
    selector = Image.createEmpty(10,10)
    selector:clear(red) 
    
    charX = 100
    charY= 100 
    
    currentX = 107
    currentY = 98 
    
    currentLetter = 1 
    
    
    uppercase = false
    name = ""
    oldpad = Controls.read() 
    
    addX = 0
    addY = -10
    addRow = -9 
    
    function drawLetters()
    for a = 1, 3 do
    addX = 0
    addY = addY + 10
    addRow = addRow + 9
    for b = 1, 9 do
    addX = addX + 10
    if uppercase == false then
    screen:print(charX + addX,charY + addY, characters[b + addRow],white)
    else
    screen:print(charX + addX,charY + addY,string.upper(characters[b + addRow]),white)
    end
    end
    end
    addX = 0
    addY = -10
    addRow = -9
    end 
    
    while true do
    pad = Controls.read()
    
    screen:clear()
    
    screen:print(10,10,"Enter Name: "..name,white)
    screen:blit(currentX,currentY, selector)
    
    drawLetters() 
    
    
    if pad:cross() and oldpad:cross() ~= pad:cross() then
    if uppercase == false then
    name = string.sub(name, 1, string.len(name) - 1)
    name = name .. characters[currentLetter]
    currentLetter = currentLetter + 1
    currentX = 107
    if currentLetter == 4 then
    currentLetter = currentLetter - 3
    
    end
    end 
    end
    
    
    
    
    
    if pad:right() and oldpad:right() ~= pad:right() then
    if uppercase == false then
    
    name = name .. crap[currentLetter]
    
    end
    end 
    
    
    
    
    
    
    screen.flip()
    screen.waitVblankStart()
    oldpad = pad
    end

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

    ponlork - And what's your problem exactly? I don't think many of us willing to help are willing to DL luaplayer and run that script (and I for one won't even read through it without indentation)

    Zitat Zitat von slicer4ever Beitrag anzeigen
    mousex
    hawt.

    ...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. #10214
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen
    hawt.
    indeed
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  15. #10215
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von SG57 Beitrag anzeigen
    ponlork - And what's your problem exactly? I don't think many of us willing to help are willing to DL luaplayer and run that script (and I for one won't even read through it without indentation)


    hawt.

    Hello, my apologies for the previous post I was still getting my feet wet in lua. Well I spent the other night tinkering around some more and have a better understanding. So I made a new script to try to explain what I'm trying to achieve better:

    Code:
    blue = Color.new(0, 0, 255) 
    pink = Color.new(255, 0 , 153)
    abc = { "a", "b", "c" } -- I want the X button to display letters "ABC"
    def = { "d", "e", "f" } -- I want the Triangle button to display letters "DEF"
    
    oldpad = pad
    name = ""
    currentLetter = 1
    
    while true do
    pad = Controls.read()
    
    screen:clear()
    screen:print(100,100,""..name,pink)
    
    if pad:cross() and oldpad:cross() ~=pad:cross() 
    then name = string.sub(name, 1, string.len(name) - 1)
    name = name .. abc[currentLetter]
    currentLetter = currentLetter + 1
    if currentLetter == 4 then currentLetter = currentLetter - 3
    end
    end
    
    if pad:triangle() and oldpad:triangle() ~=pad:triangle() then 
    name = name .. def[currentLetter]
    currentLetter = currentLetter + 1
    if currentLetter == 4 then currentLetter = currentLetter - 3
    end
    end
    
    
    
    screen.flip()
    screen.waitVblankStart()
    oldpad = pad
    end
    Now for the section in the code where I press pad:cross(), I used the code "name = string.sub(name, 1, string.len(name) - 1)" in order for the text entry to stay stationary. Then I add "name = name .. abc[currentLetter]" and "currentLetter = currentLetter + 1" so when I tap X it should alternate between ABC. Finally I included "if currentLetter == 4 then currentLetter = currentLetter - 3" so it would go back to A once it goes beyond letter C.

    Now how would I make it so when I press triangle, that the letters def would show up in the same effect, and if I press X it will go back to ABC. It seems when I tap X again it will just erase my previous entry from def & start on the letter according to what value the currentLetter is at. Also I would like the currentLetter to start back at 1 whenever I press a new button so it can goto the first string of the letter.

    I'm trying to make it so it can emulate the style of a multiTap keyboard found in cell phones. Can anybody give me some advice?

  16. #10216
    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

    Interesting, i see what your trying to do.
    You want a menu system to move through your sets of characters though there's another issue. Your character sets should be in one table as elements rather than individual tables like you have now.
    i.e
    Code:
    characterSets = {}
    characterSets[1] = {"a", "b", "c"};
    characterSets[2] = {"d", "e", "f"};
    Instead of what you have:
    Code:
    abc = {"a", "b", "c"};
    def = {"d", "e", "f"};
    Two reasons, one it's generally bad and two not enough buttons to go through your system and even if there is (i haven't counted cba, probably not though) you won't have any room for your planned features i see, i.e uppercase, numbers etc.
    Every time you'd move your set would move via a variable so for example:
    pseudo:
    Code:
    if right then
        characterSet[currentSet] = ++;
    elseif left and currentSet > 1 then 
        characterSet[currentSet] = --;
    end
    Then instead of:
    Code:
    name = name .. abc[currentLetter]
    It would be:
    Code:
    name = name ..  characterSet[currentSet][currentLetter]
    Here your just reference a table within a table, so if your currentSet is 1 and so is your currentLetter then you'd render A and the rest is etc.

  17. #10217
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    ah I see, thanks for the tip dan369. Good to know in the future. Well I tried implementing your code but it seems to produce the same result. How about this, is there a way where to have a letter print according to how many button presses? For instance, 1 press for letter A, double press for letter B, and three presses for letter C?

    I'm really just trying to make a simple OSK with the letters mapped onto the PSP buttons. Numbers and Caps I probably won't be using as I'm trying to make a trivia game where the users have to input text

  18. #10218
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    u need 2 serperate counters, for 2 seperate tables, otherwise using the same counter for both well point to the wrong letter in the other table
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  19. #10219
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von slicer4ever Beitrag anzeigen
    u need 2 serperate counters, for 2 seperate tables, otherwise using the same counter for both well point to the wrong letter in the other table
    Oh yes thank you for pointing that out, I realized that earlier so I added another counter for the table DEF and named it currentLetter2. So that part is solved, but now I have a problem with the counter not returning back to 1 after I press a different button. Like if I press X for letter A, then triangle for letter D, if I hit X again the counter will still add + 1 and print letter B instead of reverting back to A. If anybody can help me on that I'll be very thankful

  20. #10220
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    when u hit triangle, simple reset currentletter back to it's starting value, same for currentletter2 when u hit x
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  21. #10221
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von slicer4ever Beitrag anzeigen
    when u hit triangle, simple reset currentletter back to it's starting value, same for currentletter2 when u hit x

    OMG something so simple and I missed it haha. Ok I almost got it, now one final problem is the code "name = string.sub(name, 1, string.len(name) - 1)". When I put that line of code in for the Triangle button, The letters DEF also stays stationary in the same position with ABC. Is there a way to have the letters DEF move over to the next when I press the triangle button?

    Hey man I really appreciate your help

  22. #10222
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Woo Hoo! I finally figured out a way to achieve the effect I was aiming for. I know the code is tedious but **** I'm just glad it works
    here's the code I used:

    Code:
    white = Color.new(255, 255, 255) 
    blue = Color.new(100, 149, 237)
    pink = Color.new(255, 0 , 153)
    abc = { "a", "b", "c", "a" }
    def = { "d", "e", "f", "d" }
    space = { "" }
    
    oldpad = pad
    name = ""
    currentLetter = 1
    currentLetter2 = 1
    
    
    while true do
    pad = Controls.read()
    
    screen:clear()
    screen:print(130,56,"Type dead & press Start",white)
    screen:print(200,86,""..name,blue)
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter ~= 7
    then name = name .. abc[1]
    currentLetter = currentLetter + 1
    currentLetter2 = 1
    end
    
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter == 3
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. abc[2]
    currentLetter = currentLetter + 1
    currentLetter2 = 1
    end
    
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter == 5
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. abc[3]
    currentLetter = currentLetter + 1
    currentLetter2 = 1
    end
    
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter == 7
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. abc[4]
    currentLetter = currentLetter - 5
    currentLetter2 = 1
    end
    
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 ~= 7
    then name = name .. def[1]
    currentLetter2 = currentLetter2 + 1
    currentLetter = 1
    end
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 == 3
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. def[2]
    currentLetter2 = currentLetter2 + 1
    currentLetter = 1
    end
    
    
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 == 5
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. def[3]
    currentLetter2 = currentLetter2 + 1
    currentLetter = 1
    end
    
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 == 7
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. def[4]
    currentLetter2 = currentLetter2 - 5
    currentLetter = 1
    end
    
    
    if pad:r() and oldpad:r() ~=pad:r() 
    then name = name .. space[1]
    currentLetter = 1
    currentLetter2 = 1
    end
    
    
    
    if pad:start() and oldpad:start() ~=pad:start()
    then
    currentLetter = 1
    currentLetter2 = 1
    if name == "dead" then screen:print(180,110,"Correct!",pink)
    screen.flip()
    screen.waitVblankStart(200)
    else screen:print(180,110,"WRONG!",pink)
    screen.flip()
    name = ""
    screen.waitVblankStart(50)
    end
    end
    
    
    screen.flip()
    screen.waitVblankStart()
    oldpad = pad
    end
    I don't need my High School Diploma Anymore! time to get cracking on my game. I'll probably be back again
    Geändert von ponlork (04-13-2010 um 10:07 PM Uhr)

  23. #10223
    QJ Gamer Bronze
    Points: 5.583, Level: 48
    Level completed: 17%, Points required for next Level: 167
    Overall activity: 0%

    Registriert seit
    May 2007
    Beiträge
    127
    Points
    5.583
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von ponlork Beitrag anzeigen
    Code:
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter ~= 7
    then name = name .. abc[1]
    currentLetter = currentLetter + 1
    currentLetter2 = 1
    end
    
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter == 3
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. abc[2]
    currentLetter = currentLetter + 1
    currentLetter2 = 1
    end
    
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter == 5
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. abc[3]
    currentLetter = currentLetter + 1
    currentLetter2 = 1
    end
    
    
    if pad:right() and oldpad:right() ~=pad:right() and currentLetter == 7
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. abc[4]
    currentLetter = currentLetter - 5
    currentLetter2 = 1
    end
    
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 ~= 7
    then name = name .. def[1]
    currentLetter2 = currentLetter2 + 1
    currentLetter = 1
    end
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 == 3
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. def[2]
    currentLetter2 = currentLetter2 + 1
    currentLetter = 1
    end
    
    
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 == 5
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. def[3]
    currentLetter2 = currentLetter2 + 1
    currentLetter = 1
    end
    
    
    if pad:left() and oldpad:left() ~=pad:left() and currentLetter2 == 7
    then name = string.sub(name, 1, string.len(name) - 2)
    name = name .. def[4]
    currentLetter2 = currentLetter2 - 5
    currentLetter = 1
    end
    Look at this from 10 feet from your screen. All this code is identical except for some very minor things... Make it functional or think how you can reduce it to just one function or two. It has a pattern/smell and they can be optmised out
    -- Code Monkey : Sarien, Fishguts, Cracks and Crevices --

    "Did IQ's just drop sharply while I was away?" (Ripley)

  24. #10224
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von _df_ Beitrag anzeigen
    Look at this from 10 feet from your screen. All this code is identical except for some very minor things... Make it functional or think how you can reduce it to just one function or two. It has a pattern/smell and they can be optmised out

    I tried my best with the limited knowledge I have, but since no one was willing to help me or had an answer I said screw it, I'll do it. Sometimes it's not about how long the code is but if you can understand it. And by golly I do understand it even though I'm still a noob.

    Down the line when I improve I will optimize it though. But hey if you got a suggestion or a better method then I'll gladly utilize it but I'm not spending anymore time on it. No offense but It's easy to come after the fact and say you can do better but where were you the past 5 days when I was pleading for help? haha I say that with no disrespect, right now I'm just glad it works so....moving on, I got a project to Finnish. can't sit around experimenting all day, I got a full time job also. Time is everything. Thanks for the advice though, you are right, I'm doing too much. Fall back, fall back

  25. #10225
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    Zitat Zitat von ponlork Beitrag anzeigen
    I tried my best with the limited knowledge I have, but since no one was willing to help me or had an answer I said screw it, I'll do it. Sometimes it's not about how long the code is but if you can understand it. And by golly I do understand it even though I'm still a noob.

    Down the line when I improve I will optimize it though. But hey if you got a suggestion or a better method then I'll gladly utilize it but I'm not spending anymore time on it. No offense but It's easy to come after the fact and say you can do better but where were you the past 5 days when I was pleading for help? haha I say that with no disrespect, right now I'm just glad it works so....moving on, I got a project to Finnish. can't sit around experimenting all day, I got a full time job also. Time is everything. Thanks for the advice though, you are right, I'm doing too much. Fall back, fall back
    what are you talking about?, 2 others including myself took time to answer most every question you asked here, it's funny how you complain about having a job and can't sit around then complain to someone whom most likly has a job and things to do then visit this forum everyday and answer your questions, _df_ simply pointed out that it could be optimized not that you had to optimize it

    attitude like this makes me want to not help you in the future, claiming you got no help, that's pretty disrespectful to everyone that helped you
    Geändert von slicer4ever (04-14-2010 um 04:17 PM Uhr)
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  26. #10226
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von slicer4ever Beitrag anzeigen
    what are you talking about?, 2 others including myself took time to answer most every question you asked here, it's funny how you complain about having a job and can't sit around then complain to someone whom most likly has a job and things to do then visit this forum everyday and answer your questions, _df_ simply pointed out that it could be optimized not that you had to optimize it

    attitude like this makes me want to not help you in the future, claiming you got no help, that's pretty disrespectful to everyone that helped you

    Hey look I'm sorry alright? I'm just BSing. Maybe I'll shout ya'll out in my first release this weekend (hopefully). I do appreciate your guys help even though I may come across as a dicc

    Edit: Snarky response
    Geändert von ponlork (04-14-2010 um 05:52 PM Uhr)

  27. #10227
    QJ Gamer Green
    Points: 3.419, Level: 36
    Level completed: 46%, Points required for next Level: 81
    Overall activity: 31,0%

    Registriert seit
    Apr 2010
    Ort
    E/S LBC
    Beiträge
    51
    Points
    3.419
    Level
    36
    Downloads
    0
    Uploads
    0

    Standard

    Man I was in the process of posting a new thread for my release but I got a message saying my post count was insufficient by just 1 haha I hate to post just for the sake of getting 10 but hey let me describe my game, it's called Learn Japanese. Basically it's a trivia game designed to help people memorize Japanese words. I feel typing the words will help people remember better.

    It was a great learning experience, I feel more confident at tackling bigger projects now. I just want to say thanks to everybody for helping me out.

    -- I can't Post Links or Pictures Either?! oh well after this post I should be able to...

  28. #10228
    Points: 1.048, Level: 17
    Level completed: 48%, Points required for next Level: 52
    Overall activity: 0%
    Achievements:
    Got three Friends First 1000 Experience Points

    Registriert seit
    Jan 2011
    Ort
    iPhone 4-BootRom
    Beiträge
    53
    Points
    1.048
    Level
    17
    My Mood
    Fine
    Downloads
    1
    Uploads
    0

    Standard

    please go look at my post i need help bad

  29. #10229
    QJ Gamer Green
    Points: 2.521, Level: 30
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Mar 2009
    Beiträge
    48
    Points
    2.521
    Level
    30
    Downloads
    0
    Uploads
    0

    Standard

    Hi!

    I started programming Lua with Euphoria V8, but there is one thing with file reading I cannot get to work or it's a bug with Euphoria. Here is some code:

    Spoiler for code:


    -- Program starts
    stringArray = {};
    i = 1;
    file = io.open("myfile.ini", "r");
    for line in file:lines() do
    stringArray[i] = line; -- for example stores: folder/a.txt and folder/b.txt. These files exist! Are there some problems with format?
    i = i + 1;
    end
    file:close();

    file2 = io.open(stringArray[1], "r") -- try to open the file. Note: If I simply write io.open("folder/a.txt", "r") this works. So is the file looked from a wrong folder for some reason? I made further testing and if I use that array, tostring(file2) is nil. Then again if I prnt (stringArray[1], I get folder/a.txt. I don't understand...

    -- Then we want to read the file
    for line in file2:lines() do -- Then I get this error: "Attemp to index global 'file2' (a nil value)
    -- do something
    end
    Am I doing something wrong? I am pretty sure this works with normal Lua.
    Geändert von batanen (02-22-2011 um 11:18 AM Uhr) Grund: Simplified example code / further testing results.

  30. #10230
    Lua Coder
    Points: 18.915, Level: 87
    Level completed: 13%, Points required for next Level: 435
    Overall activity: 99,0%

    Registriert seit
    Jan 2008
    Ort
    Iowa
    Beiträge
    834
    Points
    18.915
    Level
    87
    My Mood
    Busy
    Downloads
    2
    Uploads
    0

    Standard

    thats weird, just tried it and it worked for me:
    Code:
    stringArray = {};
    i = 1;
    file = io.open("myfile.ini", "r");
    for line in file:lines() do
    stringArray[i] = line;
    i = i + 1;
    end
    file:close();
    file2 = io.open(stringArray[1], "r")
    for line in file2:lines() do -- Then I get this error: "Attemp to index global 'file2' (a nil value)
    var = line
    end
    while true do
    	screen:print(0,0,"var: "..var,Color.new(255,255,255))
    	if Controls.read():start() then
    		System.quit()
    	end
    	screen:flip()
    end
    it displays the text that i put in my folder/a.txt, and i dont get any errors at all

    EDIT

    for some reason its adding a ♪ to the end of the line...

    EDIT2
    firgured out how to remove the ♪ from the line, just replace the stuff you have in the for loop with this:
    Code:
    stringArray[i] = line:gsub(string.char(13),"")
    the gsub() will look for ♪ (known as string.char(13) by the psp) and replace it with nothing. If you want to know how i figured that out just replace the string.char(13) with "folder/a.txt". That way you all that is left is the ♪, then use string.byte(stringArray[1]) in a print function to show the byte value of the ♪. Then using the gsub function again replace "folder/a.txt" with string.char(value). The string.char will turn a number into a character, and then you just replace it with nothing
    Geändert von cmbeke (02-22-2011 um 07:14 PM 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 07:52 AM Uhr.

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