Page 5 of 12 FirstFirst 123456789 ... LastLast
Results 41 to 50 of 116

Thread: Help with Lua

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

    Default

    Quote Originally Posted by fg-54
    i told you shadowblind! my computer sucks! so what;s wrong with it?
    That comment wasn't aimed at you, it was at Shadowblind.
    Your problem here is that you dont have a problem or not describing well enough.

    What are you trying to do?

  2. #42
    DCEmu Reviewer fg-54's Avatar
    Join Date
    Jun 2006
    Location
    gainesville
    Age
    33
    Posts
    726
    Rep Power
    73

    Default

    oOOOooohhh.....so what do i do with the blank text again? by the way, here is a pic of that "test" looks like on my computer "the blue thunder looking thing"


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

    Default

    shadow i had the same problem thats why i just used my psp

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

    Default

    I know full well what it looks like. I dont understand what the hell is your problem that you are trying to convey. Are you trying to run your own Lua script?

    @Shadow: Is the .cmd or .bat file in any other program besides notepad?

  5. #45
    DCEmu Reviewer fg-54's Avatar
    Join Date
    Jun 2006
    Location
    gainesville
    Age
    33
    Posts
    726
    Rep Power
    73

    Default

    That comment wasn't aimed at you, it was at Shadowblind.
    Your problem here is that you dont have a problem or not describing well enough.

    What are you trying to do?
    .....i'm trying to make a game....but first i want to start up that lua thing i need to make it.

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

    Default

    You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

    Here is an example of a lua script/program that you run WITH LuaPlayer VIA batch files:
    -- 2006-07-03
    -- Added a pause and reset animation functions

    -- 2006-07-02
    -- Very quick and hacky animation test by yaustar
    -- Note there are some REALLY bad practices here.

    -- Preload some colours
    GREEN = Color.new(0, 255, 0);
    WHITE = Color.new(255, 255, 255);
    BLACK = Color.new(0, 0, 0);

    -- Constants for the various animations
    Int_Standing = 1;
    Int_Walking = 2;
    Int_Attacking = 3;

    -- Load the images
    Image_Ken = {};
    Image_Ken[Int_Standing] = Image.load("./KenStanding.png");
    Image_Ken[Int_Walking] = Image.load("./KenWalking.png");
    Image_Ken[Int_Attacking] = Image.load("./KenDragonPunch.png");

    -- Properties for the Ken Sprite
    KenSprite = {
    Int_XPosition = 30,
    Int_YPosition = 30,
    Int_FrameWidth = 40,
    Int_FrameHeight = 117,
    Int_NumberOfFrames = 6,
    Int_CurrentFrame = 0,
    Int_FrameDelayInMs = 120,
    Int_CurrentFrameTimerLapseInMs = 0,
    Bool_Pause = false,
    Int_State = Int_Standing,
    Int_NumberOfTimesLooped = 0;
    };

    -- The update function for a sprite. Regulates the time between each frame and loops the animation
    function UpdateGraphic(Sprite, Int_DeltatimeMs)
    -- Check if the animation is paused
    if not Sprite.Bool_Pause then
    -- Update the timer lapse
    Sprite.Int_CurrentFrameTimerLapseInMs = Sprite.Int_CurrentFrameTimerLapseInMs + Int_DeltatimeMs;

    -- Check if the lapse is more then the Frame Delay
    if Sprite.Int_CurrentFrameTimerLapseInMs > Sprite.Int_FrameDelayInMs then
    -- If so, move to the next frame
    Sprite.Int_CurrentFrame = Sprite.Int_CurrentFrame + 1;
    -- Reset the Lapse
    Sprite.Int_CurrentFrameTimerLapseInMs = Sprite.Int_CurrentFrameTimerLapseInMs - Sprite.Int_FrameDelayInMs;
    end

    -- Check if the current frame is the last one
    if Sprite.Int_CurrentFrame == Sprite.Int_NumberOfFrames then
    -- If so, loop back to 0
    Sprite.Int_CurrentFrame = 0;
    -- Increment the loop counter
    Sprite.Int_NumberOfTimesLooped = Sprite.Int_NumberOfTimesLooped + 1;
    end
    end
    end

    -- Function to stop and resume the animation of a sprite
    function PauseResume(Sprite)
    Sprite.Bool_Pause = not Sprite.Bool_Pause;
    end

    -- Function to reset the animation of a sprite
    function ResetAnimation(Sprite)
    Sprite.Int_CurrentFrame = 0;
    Sprite.Int_NumberOfTimesLooped = 0;
    end

    -- Function to check if the animation has finished
    function CheckIfAnimationHasFinshed (Sprite)
    if Sprite.Int_NumberOfTimesLooped > 0 then
    return true;
    else
    return false;
    end
    end

    -- Modify the state of the sprite
    function ModifyState(Sprite, Int_IntendedAction)
    -- If the Sprite is standing, then it can go to walking or standing
    if Sprite.Int_State == Int_Standing and Int_IntendedAction ~= Int_Standing then
    ResetAnimation(Sprite);
    Sprite.Int_State = Int_IntendedAction;
    return true;
    end
    -- If the Sprite is walking, then it can go to attack or standing
    if Sprite.Int_State == Int_Walking and Int_IntendedAction ~= Int_Walking then
    ResetAnimation(Sprite);
    Sprite.Int_State = Int_IntendedAction;
    return true;
    end
    -- If the Sprite is attacking, then do nothing
    if Sprite.Int_State == Int_Attacking then
    -- Do nothing
    return false;
    end

    return false;
    end

    -- Update the sprite state
    function UpdateState(Sprite)
    -- If the Sprite is Attacking
    if Sprite.Int_State == Int_Attacking then
    -- If the Sprite has finsihed the attacking animation then go back to standing
    if CheckIfAnimationHasFinshed(Sprite) then
    ResetAnimation(Sprite);
    Sprite.Int_State = Int_Standing;
    end
    end
    end

    -- Move the sprite by X and Y amount
    function MoveSprite(Sprite, Int_X, Int_Y)
    Sprite.Int_XPosition = Sprite.Int_XPosition + Int_X;
    Sprite.Int_YPosition = Sprite.Int_YPosition + Int_Y;
    end

    -- Create a Timer Object
    Clock = Timer.new();

    -- Get the number of milliseconds since last call
    function GetDeltatime()
    local Int_Dtime = Clock:time();
    Clock:reset();
    Clock:start();
    return Int_Dtime;
    end

    -- A Deley function to regulate FPS
    function Delay(Int_NumberOfMsDelay)
    -- Variable to keep count of the accumlated deltatime
    local Int_CurrentTimePassed = 0;
    -- Reset deltatime
    GetDeltaTime();
    -- While the accumlated deltatime is lower then Int_NumberOfMsDelay
    while ( Int_CurrentTimePassed < Int_NumberOfMsDelay ) do
    -- Loop
    Int_CurrentTimePassed = Int_CurrentTimePassed + GetDeltaTime();
    end
    end

    -- List of bools to store the last state of the Key
    Bool_PadDLeftLastState = true;
    Bool_PadDRightLastState = true;
    Bool_PadDUpLastState = true;
    Bool_PadDDownLastState = true;
    Bool_PadDLbutLastState = true;
    Bool_PadDRbutLastState = true;
    Bool_PadDSqaureLastState = true;
    Bool_PadDTriangleLastState = true;
    Bool_PadDCrossLastState = true;
    Bool_PadDCircleastState = true;
    Bool_PadDSelectLastState = true;
    Bool_PadDStartLastState = true;

    -- true for Key Up, false for Key Down for readability
    Bool_KeyUp = true;
    Bool_KeyDown = false;

    -- Main 'game' loop
    while true do
    -- Local move variables
    Int_MoveX = 0;
    Int_MoveY = 0;

    -- Check if the dpad was pressed
    Bool_DPadPressed = false;

    -- Get the pad state
    PspPadState = Controls.read();

    -- Move the player
    if PspPadState:up() then
    ModifyState(KenSprite, Int_Walking);
    if KenSprite.Int_State == Int_Walking then
    Int_MoveY = -3;
    Bool_DPadPressed = true;
    end
    end

    if PspPadState:down() then
    ModifyState(KenSprite, Int_Walking);
    if KenSprite.Int_State == Int_Walking then
    Int_MoveY = 3;
    Bool_DPadPressed = true;
    end
    end

    if PspPadState:left() then
    ModifyState(KenSprite, Int_Walking);
    if KenSprite.Int_State == Int_Walking then
    Int_MoveX = -3;
    Bool_DPadPressed = true;
    end
    end

    if PspPadState:right() then
    ModifyState(KenSprite, Int_Walking);
    if KenSprite.Int_State == Int_Walking then
    Int_MoveX = 3;
    Bool_DPadPressed = true;
    end
    end

    -- If the dpad was not pressed, go to standing state
    if Bool_DPadPressed == false then
    ModifyState(KenSprite, Int_Standing);
    end

    -- If the player has pressed start, exit the loop and end the 'game'
    if PspPadState:start() then
    break;
    end

    -- Pause / Resume the animation
    if PspPadState:square() then
    if Bool_PadDSqaureLastState == Bool_KeyUp then
    PauseResume(KenSprite);
    end
    Bool_PadDSqaureLastState = Bool_KeyDown;
    else
    Bool_PadDSqaureLastState = Bool_KeyUp;
    end

    -- Restart the Animation
    if PspPadState:triangle() then
    if Bool_PadDTriangleLastState == Bool_KeyUp then
    ResetAnimation(KenSprite);
    end
    Bool_PadDTriangleLastState = Bool_KeyDown;
    else
    Bool_PadDTriangleLastState = Bool_KeyUp;
    end

    -- Attacking button
    if PspPadState:cross() then
    if Bool_PadDCrossLastState == Bool_KeyUp then
    -- Update the state of the sprite
    ModifyState(KenSprite, Int_Attacking);
    end
    Bool_PadDCrossLastState = Bool_KeyDown;
    else
    Bool_PadDCrossLastState = Bool_KeyUp;
    end

    -- Update the Ken Sprite
    UpdateState(KenSprite);

    -- Get the deltatime
    local Int_DeltatimeInMs = GetDeltatime();

    -- Update the Ken sprite
    MoveSprite(KenSprite, Int_MoveX, Int_MoveY);
    UpdateGraphic(KenSprite, Int_DeltatimeInMs);

    -- Blank the screen
    screen:clear(WHITE);

    -- Draw Ken to the screen
    screen:blit(
    KenSprite.Int_XPosition, -- X position of sprite
    KenSprite.Int_YPosition, -- Y position of sprite
    Image_Ken[KenSprite.Int_State], -- Image to blit
    KenSprite.Int_CurrentFrame * KenSprite.Int_FrameWidth, -- X position in the Image to start blitting from
    0, -- Y position in the Image to start blitting from
    KenSprite.Int_FrameWidth, -- Width of the frame (clipping frame)
    KenSprite.Int_FrameHeight -- Height of the frame (clipping frame)
    );

    -- Debug text
    String_Display = "Current Frame: " .. KenSprite.Int_CurrentFrame;
    screen:print(1, 1, String_Display, BLACK);
    String_Display = "Deltatime: " .. Int_DeltatimeInMs;
    screen:print(1, 9, String_Display, BLACK);

    -- Wait for Vblank
    screen.waitVblankStart(1);
    -- Flip the buffers
    screen.flip();
    end

  7. #47
    DCEmu Reviewer fg-54's Avatar
    Join Date
    Jun 2006
    Location
    gainesville
    Age
    33
    Posts
    726
    Rep Power
    73

    Default

    i'm trying to run luaplayer.exe.

  8. #48
    DCEmu Reviewer fg-54's Avatar
    Join Date
    Jun 2006
    Location
    gainesville
    Age
    33
    Posts
    726
    Rep Power
    73

    Default

    You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

    Here is an example of a lua script/program that you run WITH LuaPlayer VIA batch files:
    .....huh?

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

    Default

    *breathes*
    I try this another way. What are you expecting LuaPlayer to be?
    I repeat: You do realise that LuaPlayer is NOT like GameMaker, Games Factory or Click and Play. You have to program for it like BASIC, Pascal, C/C++ etc.

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

    Default

    screen:print just so u know its not smilies lol

    @fg: u code in the notepad silly

Page 5 of 12 FirstFirst 123456789 ... 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
  •