Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
801 B

  1. PEntity <- {
  2. name="noname"
  3. pos={x=0,y=0,z=0}
  4. type="entity"
  5. //methamethod
  6. _typeof=function()
  7. {
  8. return type;
  9. }
  10. }
  11. function PEntity::PrintPos()
  12. {
  13. ::print("x="+pos.x+" y="+pos.y+" z="+pos.z+"\n");
  14. }
  15. function PEntity::new(name,pos)
  16. {
  17. local newentity=clone ::PEntity;
  18. if(name)
  19. newentity.name=name;
  20. if(pos)
  21. newentity.pos=pos;
  22. return newentity;
  23. }
  24. PPlayer <- {
  25. model="warrior.mdl"
  26. weapon="fist"
  27. health=100
  28. armor=0
  29. //overrides the parent type
  30. type="player"
  31. }
  32. function PPlayer::new(name,pos)
  33. {
  34. local newplayer=delegate ::PEntity.new(name,pos) : clone ::PPlayer;
  35. return newplayer;
  36. }
  37. local player=PPlayer.new("godzilla",{x=10,y=20,z=30});
  38. ::print("PLAYER NAME"+player.name+"\n");
  39. ::print("ENTITY TYPE"+typeof player+"\n");
  40. player.PrintPos();
  41. player.pos.x=123;
  42. player.PrintPos();