# Cycling interface. # Rooms: cycle through this.cycle_gallery # Objects: cycle through this.cycle_gallery cyclelink = (content) -> return "#{content}" cycle = (responses, name, character) -> if typeof responses == "function" responses = responses() character.sandbox.cycle_index ?= [] # initialize with empty array character.sandbox.cycle_index[name] ?= 0 # initialize with 0 response = responses[character.sandbox.cycle_index[name]] character.sandbox.cycle_index[name]++ if character.sandbox.cycle_index[name] == responses.length character.sandbox.cycle_index[name] = 0 return cyclelink(response) module.exports = cycle