MCPcopy Index your code
hub / github.com/RustOtomeLab/RustEng / parse_script

Method parse_script

src/parser/script_parser.rs:130–151  ·  view source on GitHub ↗
(&mut self, text: &str)

Source from the content-addressed store, hash-verified

128 use Commands::*;
129
130 let mut block_commands = Vec::new();
131
132 for (index, (line_num, line)) in lines.iter().enumerate() {
133 if let Some(line) = line.strip_prefix('@') {
134 if let Some((cmd, arg)) = line.split_once(' ') {
135 let cmd = match cmd {
136 "bg" | "cg" => {
137 let mut parts = arg.split('|').map(str::trim);
138 let bg = Background {
139 name: parts.next().unwrap_or("").to_string(),
140 x_offset: parts.next().and_then(|s| s.parse::<f32>().ok()),
141 y_offset: parts.next().and_then(|s| s.parse::<f32>().ok()),
142 zoom: parts.next().and_then(|s| s.parse::<f32>().ok()),
143 is_cg: cmd == "cg",
144 };
145 self.insert_background(*block_index, bg.clone());
146 bg
147 }
148 "bgm" => {
149 self.insert_bgm(*block_index, arg.to_string());
150 PlayBgm(arg.to_string())
151 }
152 "choose" => {
153 let num = arg.parse::<usize>().map_err(ScriptError::from)?;
154 let mut choose_branch = HashMap::with_capacity(num);

Callers 1

with_nameMethod · 0.80

Calls 2

parse_blockMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected