The selling mechanic is directly tied to the $slave_room number, but there's nothing to move the slaves into a lower $slave_room number, but it's coded like it does.
So when:
REMOVE SLAVE
<<switch _i>>
<<case 0>>
<<set $pc_bedroom.type to "Empty">>
<<case 1>>
<<set $slave_room_1 to $empty_cell>>
<<case 2>>
<<set $slave_room_2 to $empty_cell>>
(etc)
triggers:
"set $slave_room_1 to $empty_cell" removes the contents of $slave_room_1.
"set $slave_room_2 to $empty_cell" is empty, end <<switch _i>>
BUT THEN:
triggers:
"set $slave_room_1 to $empty_cell" is empty, end <<switch _i>>
Does not trigger at all:
"set $slave_room_2 to $empty_cell" removes the contents of $slave_room_2.
It also doesn't matter who you sell, it always triggers <<set $slave_room_1 to $empty_cell>> first, so $slave_room_1 is who always gets removed.
So if you buy a Worthless Bum ($slave_room_1)
and then buy a Mythic Princess ($slave_room_2)
then realize you really needed that money, and
try to sell Mythic Princess ($slave_room_2)
You get Mythic Princess' sell value, and Worthless Bum ($slave_room_1) gets emptied.
Mythic Princess ($slave_room_2) remains unmoved...
try to sell Mythic Princess ($slave_room_2)
You get Mythic Princess' sell value, and empty ($slave_room_1) gets emptied.