Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pair with runtime entity not working #14

Open
bortantle opened this issue Dec 4, 2024 · 1 comment
Open

Pair with runtime entity not working #14

bortantle opened this issue Dec 4, 2024 · 1 comment

Comments

@bortantle
Copy link

bortantle commented Dec 4, 2024

import { add, Pair, query, spawn, Tag, target } from "@rbxts/flamecs";
const a = spawn();
const b = spawn();

interface likes extends Tag {}

add<Pair<likes>>(a, b);

print("start query"); 
for (const [e] of query<[Pair<likes>]>()) {
    print(`${e} likes ${target<likes>(e)}`); // NEVER PRINTS
}
print("end query");
@maeriil
Copy link

maeriil commented Dec 4, 2024

Not sure how useful this would be for anyone debugging but It seems for now, a syntax like this seems to be working

for (const [e] of query<[]>().pair<likes>(b)) {
	print(`${e} likes ${target<likes>(e)}`); // Okay, prints 269 likes 270
}

Here is the difference in code generation in Luau

for e in query({ {
	obj = "@rbxts/flamecs:out/registry@Wildcard",
	pred = "server/runtime.server@likes",
} }) do
	print(`{e} likes {target(e, "server/runtime.server@likes")}`)
end
for e in query():pair(b, "server/runtime.server@likes") do
	print(`{e} likes {target(e, "server/runtime.server@likes")}`)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants