Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. //README: to any poor sod who has to read through this I apologize for the absolute horror below, I should really have done this in python.
  2.  
  3. //for each piece
  4.  
  5. int numberOfRooms = 0;
  6. int maxLoungeSize = 0;
  7. int minBathroomSize = 100;
  8.  
  9. int loungeID = 0;
  10. int bathroomID = 0;
  11. int hallID = 0;
  12. int kitchenID = 0;
  13. int bedroomIDs[]; //IDs of rooms that are not halls, lounges or bathrooms.
  14.  
  15. string allRooms[]; //encoded string containing room vals. Syntax for a 2x2 room of prims 3,4,5,6: "S 3 4 5 6 " might not need start and end tags
  16.  
  17. /*structure
  18. //set min, max
  19. //set Room IDs
  20. //set rooms into groups based on ID -- might be able to condesne the end down here.
  21.  
  22. */
  23.  
  24. //this runs on the assumption the connectivity node is always sorted (replacement code at end)
  25. numberOfRooms = primattrib(0,"class",(@numprim -1),0);
  26.  
  27.  
  28.  
  29. //loop through each piece, initally setting max & min
  30. for(int i = 0; i <= numberOfRooms; i++){
  31.  
  32. int curRoomSize = 0;
  33. string curRoomVal = "S ";
  34. int isHall = 0;
  35.  
  36.  
  37. //loop through
  38. for(int j = 0; j < @numprim; j++){
  39. //get size
  40. if(primattrib(0,"class",j,0) == i){
  41. append(curRoomVal, sprintf("%i ",j));
  42. curRoomSize = curRoomSize + 1;
  43.  
  44. //check if hallway
  45. if(inprimgroup(0,"HallGroup",j) == 1){
  46. isHall = 1;
  47. }
  48. }
  49. }
  50.  
  51. //set largest room to lounge
  52. if((curRoomSize > maxLoungeSize) && (isHall == 0)){
  53. maxLoungeSize = curRoomSize;
  54. loungeID = i;
  55. }
  56. //not an else because of edge case where bathroom is 1st room encountered
  57. if((curRoomSize < minBathroomSize) && (isHall == 0)){
  58. minBathroomSize = curRoomSize;
  59. bathroomID = i;
  60. }
  61. if(isHall == 1){
  62. hallID = i;
  63. }
  64. append(allRooms,curRoomVal);
  65. }
  66.  
  67. //make array of remaning rooms
  68. for(int i = 0; i <= numberOfRooms; i++){
  69. if(i != loungeID && i != bathroomID && i != hallID){
  70. append(bedroomIDs,i);
  71. // printf("bedroom: % i", i);
  72. }
  73. }
  74.  
  75. //make the last item a kitchen.if the array is 1 long then set the lounge to a kitchen. Randomising this would be nice but I dont think its possible in vex without serious spaghetti.
  76. if(len(bedroomIDs) != 1){
  77. kitchenID = pop(bedroomIDs);
  78. }else{
  79. kitchenID = loungeID;
  80. }
  81.  
  82. printf("\n bathroom = %i, Lounge = %i, Hall = %i Kitchen = %i Bedrooms = %i",bathroomID,loungeID,hallID,kitchenID,bedroomIDs);
  83.  
  84.  
  85. //set groups through loops again
  86. for(int i = 0; i <= numberOfRooms; i++){
  87. for(int j = 0; j < @numprim; j++){
  88.  
  89.  
  90. //Loop Through matching all single existance rooms, this means we can then just assume anything else is a bedroom, so we dont need to loop through.
  91. if(primattrib(0,"class",j,0) == kitchenID){
  92. setattrib(0,"prim","roomType",j,0,"kitchen","set");
  93. //setprimgroup(0,"g_kitchen",j,1,"set");
  94. }else if(primattrib(0,"class",j,0) == hallID){
  95. setattrib(0,"prim","roomType",j,0,"hall","set");
  96. //setprimgroup(0,"g_hall",j,1,"set");
  97. }else if(primattrib(0,"class",j,0) == loungeID){
  98. setattrib(0,"prim","roomType",j,0,"lounge","set");
  99. //setprimgroup(0,"g_lounge",j,1,"set");
  100. }else if(primattrib(0,"class",j,0) == bathroomID){
  101. setattrib(0,"prim","roomType",j,0,"bathroom","set");
  102. //setprimgroup(0,"g_bathroom",j,1,"set");
  103. }else{
  104. setattrib(0,"prim","roomType",j,0,"bedroom","set");
  105. //setprimgroup(0,"g_bedroom",j,1,"set");
  106. }
  107. }
  108. }
  109.  
  110.  
  111.  
  112. /* ------------------------------------------ */
  113.  
  114.  
  115. /*
  116. for(int i = 0; i <= @numprim; i++){
  117. if(primattrib(0,"class",i,0) > numberOfRooms){
  118. numberOfRooms = primattrib(0,"class",(@numprim -1),0);
  119. }
  120. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement