I also just tried this:
def sprite_item_touched(identifier):
loaded = sprite_item_load_image(identifier)
print "sprite_item_load_image(\"" + identifier + "\") -> " + str(loaded)
if loaded:
# Pick up the item
sprite_item_pickup(identifier)
# Delete the room type
map_roomtype_delete(room_x(),room_y())
# Store that this item was picked up, and refresh inventory
savegame_set_key('Collected Items',str(room_x())+','+str(room_y())+' '+identifier,"Collected")
savegame_set_key('Inventory',identifier,savegame_value('Inventory',identifier)+1)
inventory_refresh(True)
# Store the player position so the player will start from here after death
savegame_set_key('General','X Room',room_x())
savegame_set_key('General','Y Room',room_y())
savegame_set_key('General','X Position',player_x_tile())
savegame_set_key('General','Y Position',player_y_tile())
savegame_set_key('General','Direction',player_direction())
This at least prevents me from screwing up my saved game when I touch an invisible item.
One thing I've noticed is that if the sprite didn't load when I entered the room, this never seems to succeed in loading it, which is consistent with the infinite loop I had earlier.