Skip to content

Fetching component values in script only works in const expression #1719

@KenthJohan

Description

@KenthJohan

Describe the bug
Using example from https://www.flecs.dev/flecs/md_docs_2FlecsScript.html#component-values

To Reproduce

struct Level {
	width = i32
	depth = i32
}

struct Grid {
	x = i32
	y = i32
}

Game {
	Level : {5, 7}
}

const level: Game[Level]

grid1 {
	Grid: { $level.width, $level.depth }
}

/*
A script can use the value of a component that is looked up on a specific entity. 
The following example fetches the width and depth members from the Level component, that is fetched from the Game entity:

error: script1.flecs: 22: cannot cast identifier 'Game' to flecs.meta.i32
  Grid: { Game[Level].width, Game[Level].depth }
*/
grid2 {
	Grid: { Game[Level].width, Game[Level].depth }
}

Expected behavior
In grid2 entity it should evaluate component value of width and depth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions