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

why? #3262

Closed
yzxnwj opened this issue Oct 16, 2019 · 2 comments
Closed

why? #3262

yzxnwj opened this issue Oct 16, 2019 · 2 comments

Comments

@yzxnwj
Copy link

yzxnwj commented Oct 16, 2019

Blockly.Blocks['setpeople'] = {
init: function() {
this.appendDummyInput()
.appendField("新建")
.appendField(new Blockly.FieldDropdown([["猫","cat"], ["",""], ["",""]]), "people");
this.appendDummyInput()
.appendField("命名为")
.appendField(new Blockly.FieldVariable("my_first_dance"), "peopleName")
.appendField(",位置位于")
.appendField(new Blockly.FieldDropdown([["顶部","top"], ["底部","bttom"], ["中间","center"]]), "location");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(0);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.JavaScript['setpeople'] = function(block) {
var dropdown_people = block.getFieldValue('people');
var variable_peoplename = Blockly.JavaScript.variableDB_.getName(block.getFieldValue('peopleName'), Blockly.Variables.NAME_TYPE);
var dropdown_location = block.getFieldValue('location');
var code = 'makeNewDance('+dropdown_people+','+variable_peoplename+','+dropdown_location+')\n';
return code;
};

var runcode='';
$('.run').on('click',function(){
runcode= Blockly.JavaScript.workspaceToCode(workspace)

console.log(runcode)

})

Content unavailable of return

@yzxnwj yzxnwj added issue: triage Issues awaiting triage by a Blockly team member issue: docs Describes missing or incorrect documentation labels Oct 16, 2019
@NeilFraser
Copy link
Contributor

Two things jump out at me.

One, you spelled 'bottom' wrong in your location dropdown options.

Second, the code is probably going to look like this:
makeNewDance(cat,my_first_dance,top)
whereas I'm guessing you probably want this:
makeNewDance("cat", my_first_dance, "top");
If that's the case, then you want this line:
var code = 'makeNewDance("'+dropdown_people+'", '+variable_peoplename+', "'+dropdown_location+'");\n';

There may be more issues, but your bug report doesn't actually say what the problem is, so I'm not sure what we should be looking for.

@samelhusseini samelhusseini added type: question and removed issue: triage Issues awaiting triage by a Blockly team member issue: docs Describes missing or incorrect documentation labels Oct 16, 2019
@RoboErikG
Copy link
Contributor

Please ask for help on our forums, not on the issue tracker. If you've found a bug in Blockly fill out the bug template, but we generally won't debug your code here.

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

No branches or pull requests

4 participants