player.script 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. function init(self)
  2. msg.post(".", "acquire_input_focus")
  3. model.play_anim("#model", "T-Pose", go.PLAYBACK_LOOP_FORWARD)
  4. -- enabled and disable meshes to get the correct look
  5. -- weapons
  6. model.set_mesh_enabled("#model", "1H_Sword", true)
  7. model.set_mesh_enabled("#model", "1H_Sword_Offhand", false)
  8. model.set_mesh_enabled("#model", "2H_Sword", false)
  9. -- equipment
  10. model.set_mesh_enabled("#model", "Knight_Helmet", true)
  11. model.set_mesh_enabled("#model", "Knight_Cape", true)
  12. -- different shields
  13. model.set_mesh_enabled("#model", "Spike_Shield", true)
  14. model.set_mesh_enabled("#model", "Round_Shield", false)
  15. model.set_mesh_enabled("#model", "Rectangle_Shield", false)
  16. model.set_mesh_enabled("#model", "Badge_Shield", false)
  17. end
  18. function on_input(self, action_id, action)
  19. if action_id == hash("key_1") then
  20. model.play_anim("#model", "Idle", go.PLAYBACK_LOOP_FORWARD)
  21. elseif action_id == hash("key_2") then
  22. model.play_anim("#model", "Walking_A", go.PLAYBACK_LOOP_FORWARD)
  23. elseif action_id == hash("key_3") then
  24. model.play_anim("#model", "1H_Melee_Attack_Chop", go.PLAYBACK_LOOP_FORWARD)
  25. elseif action_id == hash("key_4") then
  26. model.play_anim("#model", "Block", go.PLAYBACK_LOOP_FORWARD)
  27. elseif action_id == hash("key_5") then
  28. model.play_anim("#model", "Cheer", go.PLAYBACK_LOOP_FORWARD)
  29. end
  30. end