MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / io_input

Function io_input

aiscript-vm/src/stdlib/io.rs:137–154  ·  view source on GitHub ↗
(state: &mut State<'gc>, args: Vec<Value<'gc>>)

Source from the content-addressed store, hash-verified

135}
136
137fn io_input<'gc>(state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {
138 // Optional input
139 if let Some(value) = args.first() {
140 let input = value.as_string()?.to_string();
141 print!("{}", input);
142 io::stdout()
143 .flush()
144 .map_err(|e| VmError::RuntimeError(format!("Failed to flush stdout: {}", e)))?;
145 }
146
147 let mut input = String::new();
148 io::stdin()
149 .read_line(&mut input)
150 .map_err(|e| VmError::RuntimeError(format!("Failed to read input: {}", e)))?;
151
152 // Trim the trailing newline
153 Ok(Value::IoString(Gc::new(state, input.trim_end().to_owned())))
154}
155
156// File/directory operations
157fn io_exists<'gc>(_state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {

Callers

nothing calls this directly

Calls 2

RuntimeErrorClass · 0.85
as_stringMethod · 0.80

Tested by

no test coverage detected