7 Replies - 1099 Views - Last Post: 03 April 2013 - 12:05 PM Rate Topic: -----

#1 WxDarklingxW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-March 13

A* Pathing in lua/corona SDK

Posted 20 March 2013 - 02:57 PM

So I am trying to do an A* pathing that will accept a change in the path after a path has been run i.e select start node and end node, run path and while it is running select a new end and update the start node to the current position of the NPC.

I will also attach all the needed files to run if you guys so happen to want them.

The area I am working with is




    -- run A* --
    local path = pathfinder.pathFind(level, kLevelCols, kLevelRows + 1, startCell.col, startCell.row, endCell.col, endCell.row)
    pprint("Path", path)
     
    if path ~= false then
        -- color the path --
        local currentCell = {x=startCell.col, y=startCell.row}
    
        for k = 0, #path do
            local cellDirectionX = path[k].dx
            local cellDirectionY = path[k].dy
            local count = path[k].count
    
            for l = 1, count do
                currentCell.x = currentCell.x + cellDirectionX
                currentCell.y = currentCell.y + cellDirectionY
                if currentCell.x ~= endCell.col or currentCell.y ~= endCell.row then
                    colorCell(cells[currentCell.x][currentCell.y], 255, 255, 0)
                end
            end
        end
        
        -- create a moving object
       if firstRun == 0 then 
        walker = newWalker(path)
        firstRun = 1
        end
       walker:go()
       
       if currentCell ~= endCell then
        curGameFunction = function(event) onendCellSelected(event) end
        startCell.col = walker.x
        startCell.row = walker.y
        --firstRun = 0
--        walker:go()
        --curGameFunction = function(event) onDetermineAStar(event)end
        
        
        
    end
        
      
        
        if currentCell == endCell then
        curGameFunction = function(event) onend(event) end
        
        end
    
    else
        displayInstructions("Suitable path not found")
        curGameFunction = function(event) onend(event) end
    end
end



Is This A Good Question/Topic? 0
  • +

Replies To: A* Pathing in lua/corona SDK

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: A* Pathing in lua/corona SDK

Posted 20 March 2013 - 03:46 PM

Why are you doing the pathfinding in Lua?
Was This Post Helpful? 0
  • +
  • -

#3 WxDarklingxW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-March 13

Re: A* Pathing in lua/corona SDK

Posted 21 March 2013 - 03:17 PM

I' ding it for a game for my senior project in school. My team leader wanted to make the game in Corona SDK which is Lua based, so yeah.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: A* Pathing in lua/corona SDK

Posted 23 March 2013 - 10:01 AM

Look what I found on the Corona site. It took me about a minute, you should have found that yourself.
Was This Post Helpful? 1
  • +
  • -

#5 WxDarklingxW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-March 13

Re: A* Pathing in lua/corona SDK

Posted 27 March 2013 - 11:00 AM

View PostButchDean, on 23 March 2013 - 10:01 AM, said:

Look what I found on the Corona site. It took me about a minute, you should have found that yourself.


That is the code I am using I'm trying to modify it to except a new end node mid path.
Was This Post Helpful? 0
  • +
  • -

#6 Kainyu  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 14-March 13

Re: A* Pathing in lua/corona SDK

Posted 28 March 2013 - 02:57 AM

I see the problem but as butch said the answer to your problem is there and if you cant find it you should talk to your team not post on some site and hope someone does your work for you or your team. if they dont know then you're all a bit dim to use a language none of you are familiar with also i feel you're completely missing the point of a the team exercise which is the only reason i am replying to this, You have a team for a reason otherwise you'd be doing it alone. If you cant work in a team (assuming your in games development course of some kind) you chose the wrong line of work and really need to work on communication if you want to be able to work in most (if not all) programming positions these days.
Was This Post Helpful? 1
  • +
  • -

#7 WxDarklingxW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 20-March 13

Re: A* Pathing in lua/corona SDK

Posted 03 April 2013 - 11:30 AM

View PostKainyu, on 28 March 2013 - 02:57 AM, said:

I see the problem but as butch said the answer to your problem is there and if you cant find it you should talk to your team not post on some site and hope someone does your work for you or your team. if they dont know then you're all a bit dim to use a language none of you are familiar with also i feel you're completely missing the point of a the team exercise which is the only reason i am replying to this, You have a team for a reason otherwise you'd be doing it alone. If you cant work in a team (assuming your in games development course of some kind) you chose the wrong line of work and really need to work on communication if you want to be able to work in most (if not all) programming positions these days.


Look I don't know who you think you are but to just insult someone because they are looking for some guidance not for someone to do their work for them. Look I have been referencing the walker's position and aking that the new start node but I get an error, about indexing a value that is nil. And like I had said I'm not asking for someone to the work for me I am asking for guidance.
Was This Post Helpful? 0
  • +
  • -

#8 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: A* Pathing in lua/corona SDK

Posted 03 April 2013 - 12:05 PM

Calm down. It is true about you needing to talk to your team.

Can you also post the exact error you are getting?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1