Skip to content

Variable dropdown for unofficial extensions? #5387

@RixInGithub

Description

@RixInGithub

Hello, scratch-vm developers. I have come here a long time ago to get help on my RixxyX project, however, I request help for a secret newer extension I'm making.

I want to have a block that has a variable dropdown, something similar to the set [var v] to [value] block.

I have created a makeshift dropdown that lists the current sprite's variables, however it doesnt have the fancy "Rename variable" or "Delete variable" options. Sure, I could probably add those in, but the reason I said "probably" is because I have no idea how to trigger the actual things it does and then force the dropdown input to read a different value.

EDIT: here's the makeshift dropdown code (sorry, i have the tendency to golf my code in a way that it doesnt have spaces, hence the Reflect.construct(...) (yes, i know, i could have used null or something like it))

		getVars(targetId){ // note: only works when unsandboxed
			var idfk1 = function(a){return(Scratch.vm.runtime.targets.find)(a).variables}
			return(Object).entries(Object.assign(idfk1(function(a){return(a.id)==targetId}),idfk1(function(a){return(a.isStage)}))).map(function([_,{name}]){return""+name}).sort(function(a,b){return(a.toLowerCase()<b.toLowerCase())?-1:((a.toLowerCase()<b.toLowerCase())?0:Reflect.construct(Function,[""])())})
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions