Advertisement
lavalevel

code to study

Feb 9th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. local function whateverTheLoopDoes(M)
  2. print ("Monster PSYCH:" .. currentMap.monsterList[M].npcPsych)
  3. y = ( math.floor(currentMap.monsterList[M].npcXY / currentMapWidth ))
  4. x = ( currentMap.monsterList[M].npcXY ) - (y * currentMapWidth)
  5. y = y - 1
  6.  
  7. MonsterXY = currentMap.monsterList[M].npcXY
  8. -- is monster Next to player? And is player facing monster
  9. print (MonsterXY)
  10. if playerData.playerInfo.playerXY == (MonsterXY+1) then
  11. determineDirection = { "left", "back", "right", "front"}
  12. NextTo= true;currentMap.monsterList[M].npcAction = "attack"
  13. currentMap.monsterList[M].npcLocation = determineDirection[playerData.playerInfo.playerFacing]
  14.  
  15. elseif playerData.playerInfo.playerXY == (MonsterXY-1) then
  16. determineDirection = { "right", "front", "left", "back"}
  17. NextTo= true;currentMap.monsterList[M].npcAction = "attack"
  18. currentMap.monsterList[M].npcLocation = determineDirection[playerData.playerInfo.playerFacing]
  19.  
  20. elseif playerData.playerInfo.playerXY == (MonsterXY+currentMapWidth) then
  21. determineDirection = { "front", "left", "back", "right"}
  22. NextTo= true;currentMap.monsterList[M].npcAction = "attack"
  23. currentMap.monsterList[M].npcLocation = determineDirection[playerData.playerInfo.playerFacing]
  24.  
  25. elseif playerData.playerInfo.playerXY == (MonsterXY-currentMapWidth) then
  26. determineDirection = { "back", "right", "front", "left"}
  27. NextTo= true;currentMap.monsterList[M].npcAction = "attack"
  28. currentMap.monsterList[M].npcLocation = determineDirection[playerData.playerInfo.playerFacing]
  29. else
  30. if currentMap.monsterList[M].npcPsych == "seek" then
  31. currentMap.monsterList[M].npcAction = "find"
  32. end
  33. end
  34.  
  35.  
  36. print ("Monster " .. M .. " is " .. currentMap.monsterList[M].npcLocation )
  37. print ("Monster Will:" .. currentMap.monsterList[M].npcAction)
  38. if currentMap.monsterList[M].npcPsych == "seek" then
  39.  
  40. print ("THIS IS MY THAT FUNCTION FOR MONSTER:" .. y)
  41.  
  42. end
  43.  
  44. -- monsterMove()-- This is where I process the data set up above. perhaps I could move this out.
  45. if currentMap.monsterList[1].npcAction == "attack" then
  46. print ("Attack Rolled...")
  47. print ("Npc in front of is:" .. M .. "and" .. "npcInFrontOf is :" )
  48. -- MonsterAttack()
  49. media.playEventSound ( "snd/sound_coolSplosion.caf" )
  50. if currentMap.monsterList[M].npcLocation == "front" then
  51. animateMonster()
  52. end
  53. end
  54.  
  55. end
  56.  
  57.  
  58. for M=1, #currentMap.monsterList do
  59. local function wtgdClosure()
  60. return whateverTheLoopDoes(M)
  61. end
  62. timer.performWithDelay(2000*M,wtgdClosure,1)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement