Skip to content

Commit

Permalink
Added more functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangmeyers committed Feb 6, 2021
1 parent f42fff0 commit 6c55741
Show file tree
Hide file tree
Showing 23 changed files with 213 additions and 1 deletion.
1 change: 0 additions & 1 deletion Sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ function killPreviousPlugin()
}))
success = true
end)
print(success)
if not success then
return success
end
Expand Down
Binary file modified bloxblocks.rbxl
Binary file not shown.
1 change: 1 addition & 0 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ func main() {
})
})
r.Static("/ui", "./static")
r.Static("/media", "./media")
http.ListenAndServe(":9080", r)
}
Binary file added server/media/1x1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/media/click.mp3
Binary file not shown.
Binary file added server/media/click.ogg
Binary file not shown.
Binary file added server/media/click.wav
Binary file not shown.
Binary file added server/media/delete.mp3
Binary file not shown.
Binary file added server/media/delete.ogg
Binary file not shown.
Binary file added server/media/delete.wav
Binary file not shown.
Binary file added server/media/disconnect.mp3
Binary file not shown.
Binary file added server/media/disconnect.ogg
Binary file not shown.
Binary file added server/media/disconnect.wav
Binary file not shown.
1 change: 1 addition & 0 deletions server/media/dropdown-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/media/handclosed.cur
Binary file not shown.
Binary file added server/media/handdelete.cur
Binary file not shown.
Binary file added server/media/handopen.cur
Binary file not shown.
Binary file added server/media/pilcrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/media/quote0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/media/quote1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added server/media/sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions server/media/sprites.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions server/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ <h1>Roblox Block Coding Prototype</h1>
<block type="text_length"></block>
<block type="text_print"></block>
</category>
<category name="Variables" custom="VARIABLE" colour="%{BKY_VARIABLES_HUE}">
</category>
<category name="Functions" custom="PROCEDURE" colour="%{BKY_PROCEDURES_HUE}">
</category>
<category name="Control">
<block type="wait"></block>
</category>
<category name="Workspace">
<block type="workspace_find_first_child"></block>
</category>
<category name="Instance">
<block type="instance_destroy"></block>
<block type="instance_is_a_part"></block>
</category>
<category name="Part">
<block type="part_set_brickcolor"></block>
</category>
</xml>

<script>
Expand All @@ -78,6 +95,126 @@ <h1>Roblox Block Coding Prototype</h1>
// Blockly.Xml.domToWorkspace(document.getElementById('startBlocks'),
// demoWorkspace);

// define custom blocks
Blockly.Blocks['workspace_find_first_child'] = {
init: function () {
this.appendDummyInput()
.appendField("workspace:FindFirstChild")
.appendField(new Blockly.FieldTextInput("<name>"), "name");
this.setOutput(true, "Instance");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Lua['workspace_find_first_child'] = function (block) {
var text_name = block.getFieldValue('name');
// TODO: Assemble Lua into code variable.
var code = `workspace:FindFirstChild("` + text_name + `")`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Lua.ORDER_NONE];
};

Blockly.Blocks['instance_destroy'] = {
init: function () {
this.appendDummyInput()
.appendField("Instance:destroy");
this.appendValueInput("INSTANCE")
.setCheck("Instance")
.appendField("instance");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['instance_is_a_part'] = {
init: function () {
this.appendDummyInput()
.appendField("is a Part")
.appendField(new Blockly.FieldVariable("item"), "INSTANCE");
this.setOutput(true, "Boolean");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
}

Blockly.Lua['instance_is_a_part'] = function (block) {
var variable_instance = Blockly.Lua.variableDB_.getName(block.getFieldValue('INSTANCE'), Blockly.Variables.NAME_TYPE);
// TODO: Assemble Lua into code variable.
var code = `${variable_instance}:isA("Part")`;
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.Lua.ORDER_NONE];
};

Blockly.Blocks['part_set_brickcolor'] = {
init: function () {
this.appendDummyInput()
.appendField("set brick color")
.appendField(new Blockly.FieldVariable("item"), "INSTANCE")
.appendField("R")
.appendField(new Blockly.FieldNumber(0, 0, 1), "R")
.appendField("G")
.appendField(new Blockly.FieldNumber(0, 0, 1), "G")
.appendField("B")
.appendField(new Blockly.FieldNumber(0, 0, 1), "B");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Lua['part_set_brickcolor'] = function (block) {
var variable_instance = Blockly.Lua.variableDB_.getName(block.getFieldValue('INSTANCE'), Blockly.Variables.NAME_TYPE);
var number_r = block.getFieldValue('R');
var number_g = block.getFieldValue('G');
var number_b = block.getFieldValue('B');
var code = `${variable_instance}.BrickColor = BrickColor.new(${number_r}, ${number_g}, ${number_b})\n`;
return code;
};

Blockly.Blocks['wait'] = {
init: function () {
this.appendDummyInput()
.appendField("wait")
.appendField(new Blockly.FieldNumber(0, 0), "AMOUNT");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Lua['wait'] = function (block) {
var number_amount = block.getFieldValue('AMOUNT');
var code = `wait(${number_amount})\n`;
return code;
};

/*
*Blockly.Python['variables_get'] = function(block) {
// Variable getter.
var code = Blockly.Python.variableDB_.getName(block.getFieldValue('VAR'),
Blockly.Variables.NAME_TYPE);
return [code, Blockly.Python.ORDER_ATOMIC];
};
*/

Blockly.Lua['instance_destroy'] = function (block) {
var value_instance = Blockly.Lua.valueToCode(block, 'INSTANCE', Blockly.Lua.ORDER_ATOMIC);
console.log(value_instance)
// TODO: Assemble Lua into code variable.
var code = `${value_instance}:Destroy()\n`
return code;
};

function showCode() {
// Generate Lua code and display it.
Blockly.Lua.INFINITE_LOOP_TRAP = null;
Expand Down

0 comments on commit 6c55741

Please sign in to comment.