Carpet

Carpet

2M Downloads

[Scarpet] Issue with trying to combine a string and list.

Desynq opened this issue ยท 2 comments

commented

I'm trying to create a command using scarpet that allows you to teleport to a dimension with exact coordinates within said dimension.

Whenever I try running the command, it errors saying that there are not enough arguments for %f.

I've tried debugging the code by excluding the execute in dimension part and only utilizing the pos argument, and it works. It's just that whenever I try combining the string with the list of floats, it errors.

__config() -> {
	'stay_loaded' -> true,
	'scope' -> 'global',
	'command_permission' -> 'ops',
	'commands' -> {
		'<dimension> <position>' ->         _(dim, pos) -> run(str('execute in %s run tp %f %f %f', dim, pos))
	},
	'arguments' -> {
		'dimension' -> {'type' -> 'dimension'},
		'position' -> {'type' -> 'location'}
	}
};
commented

That's because you are effectively providing only 2 arguments to str, a string and a list. To fix use the ... operator: str('execute in %s run tp %f %f %f', dim, ...pos)

commented

Thanks, I didn't know that I had to use a ... operator and tried other methods like splice() and join() to no avail.