gnembon / scarpet

Public Repository of scarpet programs for Minecraft
Creative Commons Zero v1.0 Universal
359 stars 161 forks source link

cam.sc does not load pre-/cam location. #377

Closed Notoriousi closed 8 months ago

Notoriousi commented 9 months ago

Describe the bug When entering /cam all seems normal, however when you leave /cam it just changes your gamemode. see video: https://youtu.be/a6AkfL-PmV0

Video was taken with a fresh install of the /cam script.

Carpet settings: image

Mods running on the server: image

petersv5 commented 8 months ago

Same issue here with fewer mods installed as well. The issue seems not to be present in 1.20.2 and definitly present in 1.20.4.

petersv5 commented 8 months ago

This is strange. A command like /script run modify(player(), 'pos', [100, 100, 100]) takes effect as expected. However, when I add print('at end of restore_player); modify(player(), 'pos', [100, 100, 100]); at the end of __restore_player_params() I get the printout but the player does not move. I am at a loss why they work differently. Is this a bug in the carpet script engine itself?

petersv5 commented 8 months ago

It is the "run('execute in minecraft:'+config:'dimension'+' run tp @s ~ ~ ~');" command that inhibits / overwrites subsequent pos updates.

Even if the tp is executed after the pos update it still uses the old coordinates.

petersv5 commented 8 months ago

As a workaround I removed 'pos' from the for loop in __restore_player_params() and modified the teleport line to read: [x, y, z] = config:'pos'; run('execute in minecraft:'+config:'dimension'+' run tp @s '+x+' '+y+' '+z);

This made the script work again.

Notoriousi commented 8 months ago

As a workaround I removed 'pos' from the for loop in __restore_player_params() and modified the teleport line to read: [x, y, z] = config:'pos'; run('execute in minecraft:'+config:'dimension'+' run tp @s '+x+' '+y+' '+z);

This made the script work again.

Could you maybe make a pull request? Idk what to edit myself but I'd love to try your method