hex programs were originally introduced as a general framework for extending declarative logic programming, under the stable model semantics, with the possibility of bidirectionally accessing external sources of knowledge and/or computation. The original framework, however, does not deal satisfactorily with stateful external environments: the possibility of predictably influencing external environments has thus not yet been considered explicitly. This paper lifts hex programs to acthex programs: acthex programs introduce the notion of action atoms, which are associated to corresponding functions capable of actually changing the state of external environments. The execution of specific sequences of action atoms can be declaratively programmed. Furthermore, acthex programs allow for selecting preferred actions, building on weights and corresponding cost functions. We introduce syntax and semantics of acthex programs; acthex programs can successfully be exploited as a general purpose l...