Calculate the sum of cabinets assigned in all rooms
10 REM Program to calculate the sum of cabinets assigned in all rooms20 LET totalRooms = RoomCount()30 LET sumOfCabinets = 040 FOR roomIndex = 0 TO totalRooms - 150 LET roomNameFromIndex = RoomGetName(roomIndex)60 LET assignedCabinetsInRoom = CabDBCountInRoom(roomNameFromIndex)70 LET sumOfCabinets = sumOfCabinets + assignedCabinetsInRoom80 NEXT roomIndex90 PRINT 0,0, "Sum of Cabinets Assigned: " + STR(sumOfCabinets)100 END
Replace each cabinet in all rooms with a random cabinet
5 call DebugMode(1)10 REM Replace each cabinet in all rooms with a random cabinet20 LET totalRooms = RoomCount()30 LET totalCabinetsDB = CabDbCount()35 LET cont = 037 LET playerRoom = RoomName()40 REM Loop through each room50 FOR roomIndex = 0 TO totalRooms - 160 LET currentRoomName = RoomGetName(roomIndex)65 LET countReplaced = 070 gosub 50080 REM there is no way to know how many cabinets can hold a room, so it assumes 60 max.81 rem obviously it will assing more than the room capacity.90 FOR cabinetIndex = 0 TO 5995 print 20,3, "#" + str(cabinetIndex)100 REM is a cabinet assigned? we need one to proceed to change it.110 if CabDBGetAssigned(currentRoomName, cabinetIndex) = "" then goto 170120 LET randomIndex = INT(RND(1, totalCabinetsDB)) - 1121 LET newCabinetName = CabDbGetName(randomIndex)122 if newCabinetName = "" then goto 170130 rem change the database by assigning the cabinet to the old position140 if CabDBAssign(currentRoomName, cabinetIndex, newCabinetName) = 0 then goto 990145 LET countReplaced = countReplaced + 1146 print 0, 4 + MOD(countReplaced, 10), "#" + str(cabinetIndex) + " by DB #" + str(randomIndex) + ": " + str(newCabinetName) + " "149 rem change in current Room if it is the same to see it inmediatly150 if playerRoom = currentRoomName then call CabRoomReplace(cabinetIndex, newCabinetName)160 let cont=cont+1170 NEXT cabinetIndex180 NEXT roomIndex190 CALL CabDBSave()200 goto 10000500 REM show main info510 CLS520 print 0,1, "Rooms: " + str(totalRooms), 0, 0530 print 0,2, "Cabinets in DB:" + str(totalCabinetsDB), 0, 0540 print 0,3, "room:" + currentRoomName, 1, 0550 show560 return990 print 0,19, "assignment error", 1995 print 0,20, "room:" + currentRoomName + "#" + str(cabinetIndex) + "cab:" + newCabinetName10000 print 0, 23, "replaced: " + str(cont)10010 print 0, 24, "PRESS B to end", 110050 IF ControlActive("JOYPAD_B") THEN END10060 goto 10050
Randomize two cabinets in a room
10 REM Cabinet Randomizer20 LET numCabinets = CabRoomCount()30 IF (numCabinets < 2) THEN GOTO 7040 LET index1 = INT(RND(0, numCabinets))50 LET index2 = INT(RND(0, numCabinets))60 IF (index1 = index2) THEN GOTO 4070 LET cabinet1 = CabRoomGetName(index1)80 LET cabinet2 = CabRoomGetName(index2)90 CALL CabRoomReplace(index1, cabinet2)100 CALL CabRoomReplace(index2, cabinet1)110 END