Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //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.
- //for each piece
- int numberOfRooms = 0;
- int maxLoungeSize = 0;
- int minBathroomSize = 100;
- int loungeID = 0;
- int bathroomID = 0;
- int hallID = 0;
- int kitchenID = 0;
- int bedroomIDs[]; //IDs of rooms that are not halls, lounges or bathrooms.
- 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
- /*structure
- //set min, max
- //set Room IDs
- //set rooms into groups based on ID -- might be able to condesne the end down here.
- */
- //this runs on the assumption the connectivity node is always sorted (replacement code at end)
- numberOfRooms = primattrib(0,"class",(@numprim -1),0);
- //loop through each piece, initally setting max & min
- for(int i = 0; i <= numberOfRooms; i++){
- int curRoomSize = 0;
- string curRoomVal = "S ";
- int isHall = 0;
- //loop through
- for(int j = 0; j < @numprim; j++){
- //get size
- if(primattrib(0,"class",j,0) == i){
- append(curRoomVal, sprintf("%i ",j));
- curRoomSize = curRoomSize + 1;
- //check if hallway
- if(inprimgroup(0,"HallGroup",j) == 1){
- isHall = 1;
- }
- }
- }
- //set largest room to lounge
- if((curRoomSize > maxLoungeSize) && (isHall == 0)){
- maxLoungeSize = curRoomSize;
- loungeID = i;
- }
- //not an else because of edge case where bathroom is 1st room encountered
- if((curRoomSize < minBathroomSize) && (isHall == 0)){
- minBathroomSize = curRoomSize;
- bathroomID = i;
- }
- if(isHall == 1){
- hallID = i;
- }
- append(allRooms,curRoomVal);
- }
- //make array of remaning rooms
- for(int i = 0; i <= numberOfRooms; i++){
- if(i != loungeID && i != bathroomID && i != hallID){
- append(bedroomIDs,i);
- // printf("bedroom: % i", i);
- }
- }
- //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.
- if(len(bedroomIDs) != 1){
- kitchenID = pop(bedroomIDs);
- }else{
- kitchenID = loungeID;
- }
- printf("\n bathroom = %i, Lounge = %i, Hall = %i Kitchen = %i Bedrooms = %i",bathroomID,loungeID,hallID,kitchenID,bedroomIDs);
- //set groups through loops again
- for(int i = 0; i <= numberOfRooms; i++){
- for(int j = 0; j < @numprim; j++){
- //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.
- if(primattrib(0,"class",j,0) == kitchenID){
- setattrib(0,"prim","roomType",j,0,"kitchen","set");
- //setprimgroup(0,"g_kitchen",j,1,"set");
- }else if(primattrib(0,"class",j,0) == hallID){
- setattrib(0,"prim","roomType",j,0,"hall","set");
- //setprimgroup(0,"g_hall",j,1,"set");
- }else if(primattrib(0,"class",j,0) == loungeID){
- setattrib(0,"prim","roomType",j,0,"lounge","set");
- //setprimgroup(0,"g_lounge",j,1,"set");
- }else if(primattrib(0,"class",j,0) == bathroomID){
- setattrib(0,"prim","roomType",j,0,"bathroom","set");
- //setprimgroup(0,"g_bathroom",j,1,"set");
- }else{
- setattrib(0,"prim","roomType",j,0,"bedroom","set");
- //setprimgroup(0,"g_bedroom",j,1,"set");
- }
- }
- }
- /* ------------------------------------------ */
- /*
- for(int i = 0; i <= @numprim; i++){
- if(primattrib(0,"class",i,0) > numberOfRooms){
- numberOfRooms = primattrib(0,"class",(@numprim -1),0);
- }
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement