Page 11 of 12 FirstFirst ... 789101112 LastLast
Results 101 to 110 of 116

Thread: Help with Lua

                  
   
  1. #101
    DCEmu Old Pro BL4Z3D247's Avatar
    Join Date
    Jun 2006
    Location
    BL4Z3D 24/7 in CT
    Posts
    1,970
    Rep Power
    83

    Default

    shadow my understanding of tables is they give information about the chacacter(s), like health, weapons, ect...correct me if i'm wrong yaustar

  2. #102

  3. #103
    DCEmu Old Pro BL4Z3D247's Avatar
    Join Date
    Jun 2006
    Location
    BL4Z3D 24/7 in CT
    Posts
    1,970
    Rep Power
    83

    Default

    yo dtothabreezy screen:blit(player.x,player.y,playerimage) what exactly does that do?

  4. #104
    PSP User dtothabreezy's Avatar
    Join Date
    Apr 2006
    Location
    the netherer realm
    Posts
    308
    Rep Power
    71

    Default

    player .x is where your charcter is relative to x of the psp like a graph its the one that goes out y is the one that goes up if you were to minus or plus x it would give the illosion of movment ahhh you get it

    playerimage is what i use so it will blit all of the images i want in what way i want like if i would want playerimage to be him walking when you press right it would say playerimage=walk or something like that in my new animation system it runs off functions but i still keep that as a defualt to make it easier

  5. #105
    DCEmu Old Pro BL4Z3D247's Avatar
    Join Date
    Jun 2006
    Location
    BL4Z3D 24/7 in CT
    Posts
    1,970
    Rep Power
    83

    Default

    Quote Originally Posted by Shadowblind
    hmmm... would a standard table be

    green = Color.new(19, 20, 21)
    red = Color.new(22, 23, 24)
    orange = Color.new(25, 26, 27)
    yellow = Color.new(28, 29, 30)
    i don't think so, i mean i'm just lookin at the tuts at evilmana i used a different site before(shoulda use evilmana ) but i think thats just creating colour for the script to use, tables are used to store information about the character, like health, weapons, ammo, ect.

  6. #106
    PSP User dtothabreezy's Avatar
    Join Date
    Apr 2006
    Location
    the netherer realm
    Posts
    308
    Rep Power
    71

    Default

    you could do something like that but you would be going out of your way to make that becuz most pepole just put those in at the top yall r the fastest posters ive seen in my life

    o and so u know the colors when you put them in are like

    the c in the color.new most be capatalized
    color=Color.new(red,green,blue)
    just remeber that so like to make green youd
    green=Color.new(0,255,0) 255 is the most you can put in
    dont worry itll come quickly after a while youll get yoused to it

  7. #107
    DCEmu Old Pro BL4Z3D247's Avatar
    Join Date
    Jun 2006
    Location
    BL4Z3D 24/7 in CT
    Posts
    1,970
    Rep Power
    83

    Default

    lol i know i do post fast

  8. #108
    DCEmu Old Pro BL4Z3D247's Avatar
    Join Date
    Jun 2006
    Location
    BL4Z3D 24/7 in CT
    Posts
    1,970
    Rep Power
    83

    Default

    shadow heres a table:

    green = Color.new(0, 255, 0)
    Enemy = { }
    Enemy[1] = { type = "gargoyle", health = 100 }
    Enemy[2] = { type = "vampire", health = 100 }
    Enemy[3] = { type = "goomba", health = 100 }
    Enemy[4] = { type = "ghost", health = 100 }
    Enemy[5] = { type = "zombie", health = 100 }

    Player = { }
    Player[1] = { weapon = "sword", health = 100 }
    Player[2] = { weapon = "knife", health = 100 }

    while true do
    pad = Controls.read()

    screen:clear()

    screenrint(5,10,"Player 1 Health: " .. Player[1].health,green)
    screenrint(5,20,"Player 1 Weapon: " .. Player[1].weapon,green)

    screenrint(250,10,"Enemy Health: " .. Enemy[1].health,green)
    screenrint(250,20,"Enemy Type: " .. Enemy[1].type,green)

    if pad:cross() then
    Enemy[1].health = Enemy[1].health - 5
    end

    screen.waitVblankStart()
    screen.flip()
    end

    oldpad = Controls.read()

    if pad:cross() and oldpad:cross() ~= pad:cross() then

    oldpad = pad

    if pad:cross() and oldpad:cross() ~= pad:cross() and Enemy[1].health > 0 then

    ...thats right off of evilmana, i think this is concidered the tabels(arrays)

  9. #109
    GP2X Coder/Moderator
    Join Date
    Jan 2006
    Posts
    1,678
    Rep Power
    87

    Default

    I have a shot at explaining the concept of a table.
    Think of a variable as a storage box. The box can be empty (nil) or it can have something in it. Eg, value, image, text etc.

    Now a table is a stack of these boxes and you can refer to them as Box 1, Box 2 etc. You can remove or insert boxes into/out of this stack and you can refer the stack of boxes as a group under one name.

    That's the concept, the syntax in Lua can be cofusing so I let the Wiki deal with that.
    http://lua-users.org/wiki/TablesTutorial

    Note that tables are also refered to as arrays in places.

    Enemy = { }
    Enemy[1] = { type = "gargoyle", health = 100 }
    Enemy[2] = { type = "vampire", health = 100 }
    Enemy[3] = { type = "goomba", health = 100 }
    Enemy[4] = { type = "ghost", health = 100 }
    Enemy[5] = { type = "zombie", health = 100 }
    What you have done here is created a table called 'Enemy' and for each entry/storage box in 'Enemy' created another table that has two entries; 'type' and 'health'.

  10. #110
    DCEmu Reviewer Shadowblind's Avatar
    Join Date
    Apr 2006
    Location
    PR:SB End
    Posts
    3,796
    Rep Power
    115

    Default

    fg-54 is having this problem: He has script.lua and script.cmd in the same file, when he runs script.cmd it says no lua file in the directory. Whats wrong?

    BTW, can you make a simple game using a table? Thats what evilmana wants me to do...

    Therefore, I can open your code and see how its placed.

Page 11 of 12 FirstFirst ... 789101112 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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