Seite 136 von 342 ErsteErste ... 36 86 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 186 236 ... LetzteLetzte
Zeige Ergebnis 4.051 bis 4.080 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; 0,o0 is the top left. x and y are not the width and height and I have no idea what ...

  
  1. #4051
    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

    0,o0 is the top left. x and y are not the width and height and I have no idea what this is trying to do
    Code:
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 25 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 29 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x == 30 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x < 40 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 12 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x == 30 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x < 40 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 12 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x < 40 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 12 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x < 40 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 12 then
    enemy[1].y = enemy[1].y + 3
    end
    X represents a position on the X-axis and Y represents a position on the Y axis.



  2. #4052
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    Any help to my question, #4050

  3. #4053
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    yah head 54us it should look like this sorry i was mixing my self up with so many different comparison variables i should have just used one didnt know why i had different ones
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    if enemy[1].x > 20 then
    enemy[1].y = enemy[1].y + 3
    and thats my code on making the guy patrol. once i have made him walk as far as i want i will then make him walk backwards by subtracting
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

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

    It still is 'wrong' as you are doing the same comparision several times per loop.

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

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

    Standard

    Zitat Zitat von GuitarGod1134
    yah head 54us it should look like this sorry i was mixing my self up with so many different comparison variables i should have just used one didnt know why i had different ones

    and thats my code on making the guy patrol. once i have made him walk as far as i want i will then make him walk backwards by subtracting
    dude, why are you donig the same thing ten times?? look on the last page, head_54us has a good example.
    --------------------------------------------------------------------------------------

  6. #4056
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    I desperatly need help with my problem: #4050

    Lua Programming Help Thread

  7. #4057
    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 azy_xbox123
    I desperatly need help with my problem: #4050
    It is hard to help you with your problem if you don't state WHAT the problem is in the post.

  8. #4058
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    It is hard to help you with your problem if you don't state WHAT the problem is in the post.
    I did, the problem is you cannot change the "part" of the password (p1, p2, p3, p4, p5) to the digit you want so you can exit the program:

    Lua Programming Help Thread

    I also would appreciate it if you could giveme the snippet that allows me to disable the HOME button.

    Thanks in advance

  9. #4059
    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

    I did a revamp of an existing code snippet a while back: http://forums.evilmana.com/index.php?topic=244.0

    You can't disable the HOME button in Lua as it's functionality is in LuaPlayer. So unless you feel like editing the source code of LuaPlayer, you can't.

  10. #4060
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    Thanks man, that really helped. And is anyone willing to edit the source for me, I'm getting premium soon. Most likely for christmas so I will donate 1,000 points to you if you did this! :)

  11. #4061
    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

    Your error is here:
    Code:
    if "p1" == "p1f" and "p2" == "p2f" and "p3" == "p3f" and "p4" == "p4f" and "p5" == "p5f" then
    Something()
    end
    Why are they in speech marks?

  12. #4062
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Question

    I tried removing them and it makes no difference.

    But I used your code and now have it the way I want it but when I execute it I get:

    ERRORindex.lua:75: '=' expected near 'end'


    Spoiler for Code:
    System.usbDiskModeActivat e()
    red = Color.new(255, 0, 0)
    black = Color.new( 0, 0, 0)
    pfile = io.open("./password.txt", "r")
    pf = p1file:read("*n")
    pfile:close()
    PasswordEntry = { 0, 0, 0, 0, 0}
    CurrentPasswordNumber = 1
    TextGap = 20
    TextStart = 174
    LastPadState = Controls.read()
    while true do
    CurrentPadState = Controls.read()
    if CurrentPadState:right() and not LastPadState:right()then
    CurrentPasswordNumber = CurrentPasswordNumber + 1
    if CurrentPasswordNumber > 5 then
    CurrentPasswordNumber = 1
    end
    end
    if CurrentPadState:left() and not LastPadState:left() then
    CurrentPasswordNumber = CurrentPasswordNumber - 1
    if CurrentPasswordNumber < 0 then
    CurrentPasswordNumber = 5
    end
    end
    if CurrentPadState:up() and not LastPadState:up() then
    PasswordEntry[CurrentPasswordNumber] = PasswordEntry[CurrentPasswordNumber] + 1
    if PasswordEntry[CurrentPasswordNumber] > 9 then
    PasswordEntry[CurrentPasswordNumber] = 0
    end
    end
    if CurrentPadState:down() and not LastPadState:down() then
    PasswordEntry[CurrentPasswordNumber] = PasswordEntry[CurrentPasswordNumber] - 1
    if PasswordEntry[CurrentPasswordNumber] < 0 then
    PasswordEntry[CurrentPasswordNumber] = 9
    end
    end
    local password = ""
    for i=1,table.getn(PasswordEn try) do
    password = password .. PasswordEntry[i]
    end
    LastPadState = CurrentPadState
    background = Image.load("./background.png")
    screen:blit(0, 0, background, false)
    screenrint(164,89,"Enter your password",red)
    for i=1,table.getn(PasswordEn try) do
    if i == CurrentPasswordNumber then
    screenrint(TextStart+i*20, 109, PasswordEntry[i], red)
    else
    screenrint(TextStart+i*20, 109, PasswordEntry[i], black)
    end
    end
    if password == pf then
    os.exit
    end
    screen.waitVblankStart()
    scr
    end


    I don't have a clue what to do but I have narrowed the error down to the second from last 'end' in the code, this is highlighted.

    I also don't understand the line: 'local password = ""' which is also highlighted, what is this line used for?

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

    os.exit should be os.exit(). Its a function call.

  14. #4064
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    I still get the same error and I edited my previous post with another question.
    -= Double Post =-
    One more question, when making other apps I have encountered errors stating '<eof>', what is this '<eof>'?
    Geändert von AZeyC (11-12-2006 um 09:05 AM Uhr) Grund: Automerged Doublepost

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

    Hmm... looks like some of my code got cut off at the end.

    os.exit should be os.exit()
    scr should be screen.flip()
    local password = "" is to declare a variable of that name in the correct scope for it to be used later.
    <eof> is end of file

  16. #4066
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Question

    It's works, but here is the code:

    System.usbDiskModeActivat e()

    red = Color.new(255, 0, 0)
    black = Color.new( 0, 0, 0)

    file = io.open("password.txt","r ")
    PasswordLine = file:lines()
    file:close()

    PasswordEntry = { 0, 0, 0, 0, 0}

    CurrentPasswordNumber = 1

    TextGap = 20
    TextStart = 174

    LastPadState = Controls.read()

    while true do
    CurrentPadState = Controls.read()

    if CurrentPadState:right() and not LastPadState:right()then
    CurrentPasswordNumber = CurrentPasswordNumber + 1
    if CurrentPasswordNumber > 5 then
    CurrentPasswordNumber = 1
    end
    end

    if CurrentPadState:left() and not LastPadState:left() then
    CurrentPasswordNumber = CurrentPasswordNumber - 1
    if CurrentPasswordNumber < 0 then
    CurrentPasswordNumber = 5
    end
    end

    if CurrentPadState:up() and not LastPadState:up() then
    PasswordEntry[CurrentPasswordNumber] = PasswordEntry[CurrentPasswordNumber] + 1

    if PasswordEntry[CurrentPasswordNumber] > 9 then
    PasswordEntry[CurrentPasswordNumber] = 0
    end
    end

    if CurrentPadState:down() and not LastPadState:down() then
    PasswordEntry[CurrentPasswordNumber] = PasswordEntry[CurrentPasswordNumber] - 1

    if PasswordEntry[CurrentPasswordNumber] < 0 then
    PasswordEntry[CurrentPasswordNumber] = 9
    end
    end

    local password = ""

    for i=1,table.getn(PasswordEn try) do
    password = password .. PasswordEntry[i]
    end

    LastPadState = CurrentPadState

    background = Image.load("background.pn g")
    screen:blit(0, 0, background, false)



    screenrint(164,89,"Enter your password",red)

    for i=1,table.getn(PasswordEn try) do
    if i == CurrentPasswordNumber then
    screenrint(TextStart+i*20, 109, PasswordEntry[i], red)
    else
    screenrint(TextStart+i*20, 109, PasswordEntry[i], black)
    end
    end

    if password == PasswordLine then
    os.exit()
    elseif password == "34903" then
    os.exit()
    end


    screen.waitVblankStart()
    screen.flip()
    end
    I changed the file reading technique, which makes the memory stick flash like crazy, this doesn't work aswell because when I put the code that is in password.txt it doesn't do anything but when I put in the code which is built in it crashes the PSP any idea why?
    -=Double Post Merge=-
    God, talk about long-winded. I changed back the file reading code and now it still, flashes like crazy but it reads the file properly allowing the input of the code from password.txt to shutdown the psp, which is what I DON'T want. I believe there is something wrong with os.exit(), is this the correct command to exit to the XMB.

    One more thing, this code creates several lines in the botom-right-hand corner:



    Codefor i=0,20 do
    x0 = i/20*479
    y1 = 271-i/20*271
    screen:drawLine(x0, 271, 479, y1, green)
    end


    How can I make this draw these lines in the top-left-hand coner?
    Geändert von AZeyC (11-12-2006 um 09:57 AM Uhr) Grund: Automerged Doublepost

  17. #4067
    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

    Code:
    for i=0,20 do
    x0 = i/20*479
    y1 = 279-i/20*271
    screen:drawLine(x0, 0, 0, y1, green)
    end
    -= Double Post =-
    Try using break instead of os.exit()/
    Geändert von yaustar (11-12-2006 um 11:34 AM Uhr) Grund: Automerged Doublepost

  18. #4068
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    so is break just:

    break

    or is it:

    break()

    and how do you draw that line in the top-left hand corner!

  19. #4069
    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

    Code:
    System.usbDiskModeActivat  e()
    This should be
    Code:
    System.usbDiskModeActivate()
    Its a minor error, But its still an error.....

  20. #4070
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    That is correct in the code but that is a posting glitch in the forum, and you havn't donated to me yet!

  21. #4071
    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

    I cant donate, Today, But tommarow, Jake is fixing my account, Even tough i have developer status, I can only do what regular members can do

  22. #4072
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    When I changed os.exit() for break, it comes up with an error when the password is input correctly:

    ERROR(null)


    I don't know what to do!
    -= Double Post =-
    Could I use the exit() command?
    Geändert von AZeyC (11-12-2006 um 12:56 PM Uhr) Grund: Automerged Doublepost

  23. #4073
    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 azy_xbox123
    and how do you draw that line in the top-left hand corner!
    I already gave you it.

  24. #4074
    QJ Gamer Green
    Points: 12.085, Level: 72
    Level completed: 9%, Points required for next Level: 365
    Overall activity: 0%

    Registriert seit
    Aug 2005
    Ort
    a
    Beiträge
    545
    Points
    12.085
    Level
    72
    Downloads
    0
    Uploads
    0

    Standard

    I just release this!

  25. #4075
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    dude, why are you donig the same thing ten times?? look on the last page, head_54us has a good example.
    but i want him to walk the whole distance i want not just
    +1 then -1 that gives my dude no time at all to run past him. what should i do?
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

  26. #4076
    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

    It really isnt a protection program....

  27. #4077
    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 GuitarGod1134
    but i want him to walk the whole distance i want not just
    +1 then -1 that gives my dude no time at all to run past him. what should i do?
    Someone didn't understand my code :/ . Use a lower speed if the enemy is moving to fast.

  28. #4078
    Ponies and Unicorns
    Points: 5.778, Level: 49
    Level completed: 14%, Points required for next Level: 172
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Pelennor Fields
    Beiträge
    547
    Points
    5.778
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Someone didn't understand my code :/ . Use a lower speed if the enemy is moving to fast.
    OOOOOOOOOOOOOOO
    ok I got it now. thanks.
    EDIT: O AND BIG yay im at 200 posts
    EDIT AGAIN okay just to make sure i get it im gonna post my WIP source
    --//maze of doom
    --loads the map
    grass = Image.load("grass.png")
    --loads the player and enemies
    player = Image.load("player.png")
    enemy1 = Image.load("enemy1.png")
    enemy2 = Image.load("enemy2.png")
    --screen width and height
    screenwidth = 480 - player:width()
    screenheight = 272 - player:width()
    --player table
    Player = {}
    Player[1]= {x=0, y=0}
    -- enemy table
    enemy = {}
    enemy[1]= {x=0, y=40)
    --first loop
    while true do
    pad = Controls.read()
    for a = 0, 14 do
    for b = 0, 8 do
    screen:blit (32*a, 32*b, grass)
    end
    end
    -- print the player to the screen
    screen:blit(Player[1].x,Player[1].y,player)
    -- now lets make him move
    if pad:left() and Player[1].x > 0 then
    Player[1].x = Player[1].x - 3
    end
    if pad:right() and Player[1].x < screenwidth then
    Player[1].x = Player[1].x + 3
    end

    if pad:up() and Player[1].y > 0 then
    Player[1].y = Player[1].y - 3
    end

    if pad:down() and Player[1].y < screenheight then
    Player[1].y = Player[1].y + 3
    end
    --x=width and y= height
    -- this prints the enemy1 to screen
    screen:blit(enemy[1].x,enemy[1].y,enemy1)
    -- now lets try to get him patrolling
    Speed = 2
    if enemy[1].x < 10 then
    enemy[1].x = enemy[1].x + 3
    end
    if enemy[1].x > 2 then
    enemy[1].x = enemy[1].x - 3
    end
    enemy[1].x = enemy[1].x + (Speed * enemy[1].x)



    screen.waitVblankStart()
    screen.flip()
    end
    Geändert von GuitarGod1134 (11-12-2006 um 02:38 PM Uhr)
    If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
    Gold donations are highly appreciated!

  29. #4079
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    hey ive got the basic engine for my game running but i want it so that when you come out of a house you end up at the front door instead of the middle of the map. I have managed to acheive this mostly. Because when i start inside the house and go outside i end up at the front door but when you start outside and go in then out again you end up in the middle of the map.

    Spoiler for outside lua file:
    black = Color.new(0,0,0)
    shadow = Color.new(50,50,50)
    dofile("scripts/animation.lua")
    --Load all the images
    down1 = Image.load("mc-walk/mc-down1.png")
    down2 = Image.load("mc-walk/mc-down2.png")
    down3 = Image.load("mc-walk/mc-down3.png")
    up1 = Image.load("mc-walk/mc-up1.png")
    up2 = Image.load("mc-walk/mc-up2.png")
    up3 = Image.load("mc-walk/mc-up3.png")
    left1 = Image.load("mc-walk/mc-left1.png")
    left2 = Image.load("mc-walk/mc-left2.png")
    left3 = Image.load("mc-walk/mc-left3.png")
    right1 = Image.load("mc-walk/mc-right1.png")
    right2 = Image.load("mc-walk/mc-right2.png")
    right3 = Image.load("mc-walk/mcr-right3.png")
    rdown1 = Image.load("mc-walk/mcr-down1.png")
    rdown2 = Image.load("mc-walk/mcr-down2.png")
    rdown3 = Image.load("mc-walk/mcr-down3.png")
    rup1 = Image.load("mc-walk/mcr-up1.png")
    rup2 = Image.load("mc-walk/mcr-up2.png")
    rup3 = Image.load("mc-walk/mcr-up3.png")
    rleft1 = Image.load("mc-walk/mcr-left1.png")
    rleft2 = Image.load("mc-walk/mcr-left2.png")
    rleft3 = Image.load("mc-walk/mcr-left3.png")
    rright1 = Image.load("mc-walk/mcr-right1.png")
    rright2 = Image.load("mc-walk/mcr-right2.png")
    rright3 = Image.load("mc-walk/mcr-right3.png")
    area = Image.load("maps/rt-1.png")
    textbox = Image.load("objects/textbox.png")
    startmenu = Image.load("objects/startmenu.png")
    pointer = Image.load("objects/pointer.png")

    --set player variables
    file = io.open("scripts/oldarea.txt","r")
    oldarea = file:read()
    file:close()
    playerX = 230
    playerY = 130
    playerimage = down1
    playeranimation = 0
    playerHeight = 19
    playerWidth = 15
    playerFace = down
    playerOldArea = true
    oldx = 230
    oldy = 13
    menu = false
    screenWidth = 480
    screenHeight = 272

    --make the variables for all the collision check items
    item = {}
    --player house
    item[1] = {x = 32, y = 64, height = 70, width = 80}
    --civilian house 1
    item[2] = {x = 208, y = 32, height = 54, width = 80}
    --civilian house 2
    item[3] = {x = 304, y = 176, height = 54, width = 80}
    --fence left
    item[4] = {x = 0, y = 0, height = 272, width = 10}
    --fence top
    item[5] = {x = 0, y = -1, height = 13, width = 480}
    --fence right 1
    item[6] = {x = 464, y = 0, height = 120, width = 16}
    --fence right 2
    item[7] = {x = 464, y = 144, height = 120, width = 16}
    --fence bottom 1
    item[8] = { x = 4, y = 254, height = 16, width = 216}
    --fence bottom 2
    item[9] = { x = 240, y = 254, height = 16, width = 224}
    --fence post
    item[10] = {x = 470, y = 254, height = 14, width = 7}
    --rainbow town sign
    item[11] = {x = 384, y = 48, height = 16, width = 16, text = 0}
    --player house postbox
    item[12] = {x = 34, y = 134, height = 23, width = 12, text = 0}
    --civilian house 1 postbox
    item[13] = {x = 240, y = 86, height = 23, width = 12}
    --civilian house 2 postbox
    item[14] = {x = 290, y = 205, height = 23, width = 12}
    --pointer for menus or choices
    item[15] = {x = 460, y = 10}
    --flowers left of town sign
    item[16] = {x = 368, y = 32, height = 48, width = 16}
    --flowers above town sign
    item[17] = {x = 370, y = 32, height = 16, width = 48}
    --flowers right of town sign
    item[18] = {x = 402, y = 32, height = 48, width = 16}
    --flowers outside civilian house
    item[19] = {x = 336, y = 424, height = 16, width = 48}


    -- function for conversations
    function collisionCheckText()
    if (playerX >= item[11].x - 4) and (playerX <= item[11].x + item[11].width + 4) and (playerY >= item[11].y + item[11].height) and (playerY <= item[11].y + 24) and pad:cross() then
    item[11].text = 1
    end
    if (playerX >= item[13].x - 4) and (playerX <= item[13].x + item[13].width + 4) and (playerY >= item[13].y + item[13].height) and (playerY <= item[13].y + 24) and pad:cross() then
    item[13].text = 1
    end
    end

    --function for text
    function blitText()
    if item[11].text == 1 then
    screen:blit(0,222,textbox )
    screenrint(13,237," Welcome to Rainbow Town, The home of the Professor",black)
    if pad:down() or pad:analogY() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:up() or pad:analogY() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:left() or pad:analogX() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:right() or pad:analogX() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:circle() then
    item[11].text = 0
    end
    end
    if item[13].text == 1 then
    screen:blit(0,222,textbox )
    screenrint(13,237," Peter Pewter's House",black)
    if pad:down() or pad:analogY() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:up() or pad:analogY() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:left() or pad:analogX() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:right() or pad:analogX() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:circle() then
    item[13].text = 0
    end
    end
    end

    --function for going into playerhouse
    function PHouse()
    if playerX >= 44 and (playerX + playerWidth <= 68) and playerY >= 128 and (playerY + playerHeight <= 160) and pad:cross() and oldpad:cross()~= pad:cross() then
    dofile("./scripts/player-house.lua")
    end
    end

    --function for start menu
    function Smenu()
    if pad:start() then
    menu = true
    end
    if menu == true then
    screen:blit(380,0,startme nu)
    screen:blit(item[15].x,item[15].y,pointer)
    if pad:circle() then
    menu = false
    end
    end
    end


    function oldareacheck()
    if oldarea == 1 and playerOldarea == true then
    playerX = 48
    playerY = 134
    playerOldarea = false
    end
    end

    --main loop
    while true do
    oldpad = pad

    -- store the player position at the start of each loop
    oldx = playerX
    oldy = playerY

    screen:clear()

    --declare all functions
    dpad()
    oldareacheck()
    PHouse()

    collisionCheck(item[1])
    collisionCheck(item[2])
    collisionCheck(item[3])
    collisionCheck(item[4])
    collisionCheck(item[5])
    collisionCheck(item[6])
    collisionCheck(item[7])
    collisionCheck(item[8])
    collisionCheck(item[9])
    collisionCheck(item[10])
    collisionCheck(item[11])
    collisionCheck(item[12])
    collisionCheck(item[13])
    collisionCheck(item[14])
    collisionCheck(item[16])
    collisionCheck(item[17])
    collisionCheck(item[18])
    collisionCheck(item[19])

    --paste all images to screen
    screen:blit(0,0,area)
    screen:blit(playerX,playe rY,playerimage)

    collisionCheckText()
    blitText()
    Smenu()

    file = io.open("scripts/oldarea.txt","w")
    file:write(2)
    file:close()



    Spoiler for inside lua file:
    black = Color.new(0,0,0)
    shadow = Color.new(50,50,50)
    dofile("scripts/animation.lua")
    --Load all the images
    down1 = Image.load("mc-walk/mc-down1.png")
    down2 = Image.load("mc-walk/mc-down2.png")
    down3 = Image.load("mc-walk/mc-down3.png")
    up1 = Image.load("mc-walk/mc-up1.png")
    up2 = Image.load("mc-walk/mc-up2.png")
    up3 = Image.load("mc-walk/mc-up3.png")
    left1 = Image.load("mc-walk/mc-left1.png")
    left2 = Image.load("mc-walk/mc-left2.png")
    left3 = Image.load("mc-walk/mc-left3.png")
    right1 = Image.load("mc-walk/mc-right1.png")
    right2 = Image.load("mc-walk/mc-right2.png")
    right3 = Image.load("mc-walk/mcr-right3.png")
    rdown1 = Image.load("mc-walk/mcr-down1.png")
    rdown2 = Image.load("mc-walk/mcr-down2.png")
    rdown3 = Image.load("mc-walk/mcr-down3.png")
    rup1 = Image.load("mc-walk/mcr-up1.png")
    rup2 = Image.load("mc-walk/mcr-up2.png")
    rup3 = Image.load("mc-walk/mcr-up3.png")
    rleft1 = Image.load("mc-walk/mcr-left1.png")
    rleft2 = Image.load("mc-walk/mcr-left2.png")
    rleft3 = Image.load("mc-walk/mcr-left3.png")
    rright1 = Image.load("mc-walk/mcr-right1.png")
    rright2 = Image.load("mc-walk/mcr-right2.png")
    rright3 = Image.load("mc-walk/mcr-right3.png")
    area = Image.load("maps/player-1.png")
    textbox = Image.load("objects/textbox.png")
    startmenu = Image.load("objects/startmenu.png")
    pointer = Image.load("objects/pointer.png")


    --set player variables
    file = io.open("scripts/oldarea.txt","r")
    oldarea = file:read("*n")
    file:close()
    playerX = 230
    playerY = 130
    playerimage = down1
    playeranimation = 0
    playerHeight = 19
    playerWidth = 15
    playerFace = down
    playerOldarea = true
    oldx = 230
    oldy = 13
    menu = false
    screenWidth = 480
    screenHeight = 272

    --make the variables for all the collision check items
    item = {}
    --black area top
    item[1] = {x = 0, y = 0, height = 80, width = 480}
    --black area left
    item[2] = {x = 0, y = 0, height = 272, width = 128}
    --black area right
    item[3] = {x = 352, y = 0, height = 272, width = 112}
    --black area bottom
    item[4] = {x = 0, y = 192, height = 80, width = 480}
    --fence top
    item[5] = {x = 0, y = -1, height = 13, width = 480}
    --fence right 1
    item[6] = {x = 464, y = 0, height = 120, width = 16}
    --fence right 2
    item[7] = {x = 464, y = 144, height = 120, width = 16}
    --fence bottom 1
    item[8] = { x = 4, y = 254, height = 16, width = 216}
    --fence bottom 2
    item[9] = { x = 240, y = 254, height = 16, width = 224}
    --fence post
    item[10] = {x = 470, y = 254, height = 14, width = 7}
    --rainbow town sign
    item[11] = {x = 384, y = 48, height = 16, width = 16, text = 0}
    --player house postbox
    item[12] = {x = 34, y = 134, height = 23, width = 12, text = 0}
    --civilian house 1 postbox
    item[13] = {x = 240, y = 86, height = 23, width = 12}
    --civilian house 2 postbox
    item[14] = {x = 290, y = 205, height = 23, width = 12}
    --pointer for menus or choices
    item[15] = {x = 460, y = 10}
    --flowers left of town sign
    item[16] = {x = 368, y = 32, height = 48, width = 16}
    --flowers above town sign
    item[17] = {x = 370, y = 32, height = 16, width = 48}
    --flowers right of town sign
    item[18] = {x = 402, y = 32, height = 48, width = 16}
    --flowers outside civilian house
    item[19] = {x = 336, y = 424, height = 16, width = 48}



    -- function for conversations
    function collisionCheckText()
    if (playerX >= item[11].x - 4) and (playerX <= item[11].x + item[11].width + 4) and (playerY >= item[11].y + item[11].height) and (playerY <= item[11].y + 24) and pad:cross() then
    item[11].text = 1
    end
    if (playerX >= item[13].x - 4) and (playerX <= item[13].x + item[13].width + 4) and (playerY >= item[13].y + item[13].height) and (playerY <= item[13].y + 24) and pad:cross() then
    item[13].text = 1
    end
    end

    --function for text
    function blitText()
    if item[11].text == 1 then
    screen:blit(0,222,textbox )
    screenrint(13,237," Welcome to Rainbow Town, The home of the Professor",black)
    if pad:down() or pad:analogY() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:up() or pad:analogY() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:left() or pad:analogX() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:right() or pad:analogX() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:circle() then
    item[11].text = 0
    end
    end
    if item[13].text == 1 then
    screen:blit(0,222,textbox )
    screenrint(13,237," Peter Pewter's House",black)
    if pad:down() or pad:analogY() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:up() or pad:analogY() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:left() or pad:analogX() <= -127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:right() or pad:analogX() >= 127 then
    playerX = oldx
    playerY = oldy
    end
    if pad:circle() then
    item[13].text = 0
    end
    end
    end

    --function for going to rt1
    function Rt1()
    if playerX >= 208 and (playerX + playerWidth <= 256) and playerY >= 160 and (playerY + playerHeight <= 208) and pad:cross() and oldpad:cross()~= pad:cross() then
    dofile("./scripts/rt1.lua")
    end
    end

    --function for start menu
    function Smenu()
    if pad:start() then
    menu = true
    end
    if menu == true then
    screen:blit(380,0,startme nu)
    screen:blit(item[15].x,item[15].y,pointer)
    if pad:circle() then
    menu = false
    end
    end
    end

    --function for determining whe player is from last area he was in
    function oldareacheck()
    if oldarea == 2 and playerOldarea == true then
    playerX = 240
    playerY = 170
    playerOldarea = false
    end
    end

    --main loop
    while true do
    oldpad = pad

    -- store the player position at the start of each loop
    oldx = playerX
    oldy = playerY

    screen:clear()
    --declare all functions
    dpad()
    Rt1()
    oldareacheck()

    collisionCheck(item[1])
    collisionCheck(item[2])
    collisionCheck(item[3])
    collisionCheck(item[4])

    --paste all images to screen
    screen:blit(0,0,area)
    screen:blit(playerX,playe rY,playerimage)

    blitText()
    Smenu()

    file = io.open("scripts/oldarea.txt","w")
    file:write(1)
    file:close()

    screen.flip()
    end

  30. #4080
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von mark.sparky
    hey ive got the basic engine for my game running but i want it so that when you come out of a house you end up at the front door instead of the middle of the map. I have managed to acheive this mostly. Because when i start inside the house and go outside i end up at the front door but when you start outside and go in then out again you end up in the middle of the map.
    if (player touches door) then
    player.x = (edge of map)
    player.y = (edge of map)
    end


 

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 .