Skip to content

Vector2 springs error #56

Description

@rniraclefire

Repro:

local source = Fluid.source(Vector2.zero)
Fluid.spring(source, 15, 1)
source(Vector2.one)

Stack trace:

[UI Labs]: Generic story errored when called.


err: tried tweening Vector2, trace: [string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.anim.spring.spring_file"]:63 function pack_type
[string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.anim.spring.spring_file"]:164 function create
[string "ReplicatedStorage.Internal.UI.Title.components.title.test.story"]:8 function render
[string "ReplicatedStorage.Internal.Shared.Core.fluid.createFluidStory"]:34
[string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.reactive.root"]:24
[string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.result"]:34 function call
[string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.reactive.graph"]:163 function run_as
[string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.reactive.root"]:23 function root
[string "ReplicatedStorage.Internal.Shared.Core.fluid.createFluidStory"]:23

[string "ReplicatedStorage.Packages..pesde.ffrostfall_fluid@0.6.4.fluid.reactive.root"]:30 function root
[string "ReplicatedStorage.Internal.Shared.Core.fluid.createFluidStory"]:23

Full repro if needed:

local Fluid = require "@roblox_packages/Fluid"
local createFluidStory = require "@core/shared/fluid/createFluidStory"

return createFluidStory {
	controls = {},
	render = function()
		local source = Fluid.source(Vector2.zero)
		Fluid.spring(source, 15, 1)
		source(Vector2.one)

		return Fluid.create "Frame" {}
	end,
}

-- createFluidStory

local Fluid = require "@roblox_packages/Fluid"
local UILabs = require "@roblox_packages/UILabs"

type function Controls(controls: type)
	assert(controls.tag == "table", "expected controls to be a table")
	for key, values in controls:properties() do
		if values.read then
			controls:setreadproperty(key, types.newfunction({}, { head = { values.read } }))
		end

		if values.write then
			controls:setwriteproperty(key, types.newfunction({}, { head = { values.write } }))
		end
	end
	return controls
end

local function createFluidStory<C>(storyProps: {
	controls: C,
	render: ({ controls: Controls<C> }) -> Instance,
})
	return UILabs.CreateGenericStory({ controls = storyProps.controls }, function(props: UILabs.GenericProps): () -> ()
		return Fluid.root(function()
			local states = UILabs.CreateControlStates(props.converted, props.controls, function(value)
				return Fluid.source(value)
			end)

			props.subscribe(function(values)
				UILabs.UpdateControlStates(states, props.converted, values, function(state, value)
					state(value)
				end)
			end)

			local rendered = storyProps.render { controls = states :: Controls<C> }
			UILabs.Environment.SetStoryHolder(rendered)
			rendered.Parent = props.target
		end)
	end)
end

return createFluidStory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions