Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2215,8 +2215,15 @@ def overall_block_builder_node_2(state: GameState):
|
|
| 2215 |
return state
|
| 2216 |
|
| 2217 |
# Initialize offsets for script placement on the Scratch canvas
|
| 2218 |
-
script_y_offset = {}
|
| 2219 |
-
script_x_offset_per_sprite = {name: 0 for name in sprite_map.keys()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2220 |
|
| 2221 |
# This handles potential variations in the action_plan structure.
|
| 2222 |
if action_plan.get("action_overall_flow", {}) == {}:
|
|
@@ -2245,8 +2252,8 @@ def overall_block_builder_node_2(state: GameState):
|
|
| 2245 |
if "blocks" not in current_sprite_target:
|
| 2246 |
current_sprite_target["blocks"] = {}
|
| 2247 |
|
| 2248 |
-
if sprite_name not in script_y_offset:
|
| 2249 |
-
|
| 2250 |
|
| 2251 |
for plan_entry in sprite_actions_data.get("plans", []):
|
| 2252 |
logic_sequence = str(plan_entry["logic"])
|
|
@@ -2266,11 +2273,17 @@ def overall_block_builder_node_2(state: GameState):
|
|
| 2266 |
generated_blocks = generated_blocks["blocks"]
|
| 2267 |
|
| 2268 |
# Update block positions for top-level script
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2269 |
for block_id, block_data in generated_blocks.items():
|
| 2270 |
if block_data.get("topLevel"):
|
| 2271 |
-
block_data["x"] =
|
| 2272 |
block_data["y"] = script_y_offset[sprite_name]
|
| 2273 |
-
script_y_offset[sprite_name] += 150
|
| 2274 |
|
| 2275 |
current_sprite_target["blocks"].update(generated_blocks)
|
| 2276 |
print(f"[current_sprite_target block updated]: {current_sprite_target['blocks']}")
|
|
|
|
| 2215 |
return state
|
| 2216 |
|
| 2217 |
# Initialize offsets for script placement on the Scratch canvas
|
| 2218 |
+
# script_y_offset = {}
|
| 2219 |
+
# script_x_offset_per_sprite = {name: 0 for name in sprite_map.keys()}
|
| 2220 |
+
# --- Set initial fixed position ---
|
| 2221 |
+
INITIAL_X = 382
|
| 2222 |
+
INITIAL_Y = -1089
|
| 2223 |
+
|
| 2224 |
+
# Initialize offsets for script placement on the Scratch canvas
|
| 2225 |
+
script_y_offset = {name: INITIAL_Y for name in sprite_map.keys()}
|
| 2226 |
+
script_x_offset_per_sprite = {name: INITIAL_X for name in sprite_map.keys()}
|
| 2227 |
|
| 2228 |
# This handles potential variations in the action_plan structure.
|
| 2229 |
if action_plan.get("action_overall_flow", {}) == {}:
|
|
|
|
| 2252 |
if "blocks" not in current_sprite_target:
|
| 2253 |
current_sprite_target["blocks"] = {}
|
| 2254 |
|
| 2255 |
+
# if sprite_name not in script_y_offset:
|
| 2256 |
+
# script_y_offset[sprite_name] = 0
|
| 2257 |
|
| 2258 |
for plan_entry in sprite_actions_data.get("plans", []):
|
| 2259 |
logic_sequence = str(plan_entry["logic"])
|
|
|
|
| 2273 |
generated_blocks = generated_blocks["blocks"]
|
| 2274 |
|
| 2275 |
# Update block positions for top-level script
|
| 2276 |
+
# for block_id, block_data in generated_blocks.items():
|
| 2277 |
+
# if block_data.get("topLevel"):
|
| 2278 |
+
# block_data["x"] = script_x_offset_per_sprite.get(sprite_name, 0)
|
| 2279 |
+
# block_data["y"] = script_y_offset[sprite_name]
|
| 2280 |
+
# script_y_offset[sprite_name] += 150 # Increment for next script
|
| 2281 |
+
# Update block positions for top-level script
|
| 2282 |
for block_id, block_data in generated_blocks.items():
|
| 2283 |
if block_data.get("topLevel"):
|
| 2284 |
+
block_data["x"] = INITIAL_X
|
| 2285 |
block_data["y"] = script_y_offset[sprite_name]
|
| 2286 |
+
script_y_offset[sprite_name] += 150 # increment only Y
|
| 2287 |
|
| 2288 |
current_sprite_target["blocks"].update(generated_blocks)
|
| 2289 |
print(f"[current_sprite_target block updated]: {current_sprite_target['blocks']}")
|