added new CCTurtle library (not not finish yet)

This commit is contained in:
dharm pimsen 2024-07-16 23:38:54 +07:00
parent 962ada36f0
commit ee1efb360e
16 changed files with 673 additions and 36 deletions

View File

@ -1 +1 @@
{"usedlibrary":["IDE"],"content":{"blocks":{"languageVersion":0,"blocks":[{"type":"sys_start","id":"o[Cw/cGpoIP_gX=[qr#;","x":330,"y":210,"inputs":{"DO":{"block":{"type":"ide_addcode","id":"4rulxmAG~hzUkD5l(5yF","inputs":{"CODE":{"block":{"type":"text","id":"(o[.P`~(.T7p_[l_^Hl#","fields":{"TEXT":"turtle.refuel()"}}}},"next":{"block":{"type":"ide_addcode","id":"/5%!yEWtyS/E=wR/m*Xm","inputs":{"CODE":{"block":{"type":"text","id":"%wbX8A-7RhI2ZgV=lFhV","fields":{"TEXT":"turtle.digDown()"}}}},"next":{"block":{"type":"ide_addcode","id":"*(^6fQ{j/V.kg,ho=|:N","inputs":{"CODE":{"block":{"type":"text","id":"7hY96DknnQ/t#Xq?Q`dz","fields":{"TEXT":"turtle.down()"}}}},"next":{"block":{"type":"controls_repeat_ext","id":"$%Y?,,|7H1k$t+Jn)I}r","inputs":{"TIMES":{"shadow":{"type":"math_number","id":"s.U14p%aW!FTHv{Re%tn","fields":{"NUM":10}}},"DO":{"block":{"type":"ide_addcode","id":"]{qn$;Fr@4:nCTC%VK@d","inputs":{"CODE":{"block":{"type":"text","id":"*h}KRP|Z|Z8~bz+}Lb|S","fields":{"TEXT":"turtle.forward()"}}}},"next":{"block":{"type":"ide_addcode","id":"4*u|eIRv$3l8gVAe-#G6","inputs":{"CODE":{"block":{"type":"text","id":"vJr{;31CY5XLpno1G1l`","fields":{"TEXT":"turtle.dig()"}}}}}}}}},"next":{"block":{"type":"ide_addcode","id":"MYaWPpTW,*Sbr$qHdP;X","inputs":{"CODE":{"block":{"type":"text","id":"4yq!yCVpT7zAkbgx|e}?","fields":{"TEXT":"turtle.up()"}}}},"next":{"block":{"type":"ide_addcode","id":"}oNps@eRjo{j6Mt*y[M(","inputs":{"CODE":{"block":{"type":"text","id":"Pp6jDe[JkcY^`5J3FtzJ","fields":{"TEXT":"turtle.forward()"}}}},"next":{"block":{"type":"ide_addcode","id":"GBsH+H_G).Or7Jg#Z/HM","inputs":{"CODE":{"block":{"type":"text","id":"I39UB3G^1g|#PXmIK~/8","fields":{"TEXT":"turtle.forward()"}}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"fuellevel","id":"v3Vu$~B8ol()F*#n?^)B"}]}}
{"usedlibrary":["IDE"],"content":{"blocks":{"languageVersion":0,"blocks":[{"type":"ide_start","id":"o[Cw/cGpoIP_gX=[qr#;","x":330,"y":210,"inputs":{"DO":{"block":{"type":"ide_addcode","id":"4rulxmAG~hzUkD5l(5yF","inputs":{"CODE":{"block":{"type":"text","id":"(o[.P`~(.T7p_[l_^Hl#","fields":{"TEXT":"turtle.refuel()"}}}},"next":{"block":{"type":"ide_addcode","id":"/5%!yEWtyS/E=wR/m*Xm","inputs":{"CODE":{"block":{"type":"text","id":"%wbX8A-7RhI2ZgV=lFhV","fields":{"TEXT":"turtle.digDown(\"left\")"}}}},"next":{"block":{"type":"ide_addcode","id":"*(^6fQ{j/V.kg,ho=|:N","inputs":{"CODE":{"block":{"type":"text","id":"7hY96DknnQ/t#Xq?Q`dz","fields":{"TEXT":"turtle.down()"}}}},"next":{"block":{"type":"controls_repeat_ext","id":"$%Y?,,|7H1k$t+Jn)I}r","inputs":{"TIMES":{"shadow":{"type":"math_number","id":"s.U14p%aW!FTHv{Re%tn","fields":{"NUM":10}}},"DO":{"block":{"type":"ide_addcode","id":"]{qn$;Fr@4:nCTC%VK@d","inputs":{"CODE":{"block":{"type":"text","id":"*h}KRP|Z|Z8~bz+}Lb|S","fields":{"TEXT":"turtle.forward()"}}}},"next":{"block":{"type":"ide_addcode","id":"4*u|eIRv$3l8gVAe-#G6","inputs":{"CODE":{"block":{"type":"text","id":"vJr{;31CY5XLpno1G1l`","fields":{"TEXT":"turtle.dig(\"left\")"}}}}}}}}},"next":{"block":{"type":"ide_addcode","id":"MYaWPpTW,*Sbr$qHdP;X","inputs":{"CODE":{"block":{"type":"text","id":"4yq!yCVpT7zAkbgx|e}?","fields":{"TEXT":"turtle.up()"}}}},"next":{"block":{"type":"ide_addcode","id":"}oNps@eRjo{j6Mt*y[M(","inputs":{"CODE":{"block":{"type":"text","id":"Pp6jDe[JkcY^`5J3FtzJ","fields":{"TEXT":"turtle.forward()"}}}},"next":{"block":{"type":"ide_addcode","id":"GBsH+H_G).Or7Jg#Z/HM","inputs":{"CODE":{"block":{"type":"text","id":"I39UB3G^1g|#PXmIK~/8","fields":{"TEXT":"turtle.forward()"}}}}}}}}}}}}}}}}}}}}]},"variables":[{"name":"fuellevel","id":"v3Vu$~B8ol()F*#n?^)B"}]}}

View File

@ -0,0 +1,383 @@
{
"turtle_move_operation": {
"message0": "Move %1 for %2 blocks",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Forward", "FORWARD"],
["Back", "BACK"],
["Up", "UP"],
["Down", "DOWN"]
]
},
{
"type": "input_value",
"name": "FOR",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Move the turtle."
},
"turtle_turn_operation": {
"message0": "Turn %1 for %2 round",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Left", "LEFT"],
["Right", "RIGHT"]
]
},
{
"type": "input_value",
"name": "ROUND",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Turn the turtle."
},
"turtle_dig_operation": {
"message0": "Dig in %1 of turtle with %2 side",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
},
{
"type": "field_dropdown",
"name": "SIDE",
"options": [
["Left", "LEFT"],
["Right", "RIGHT"]
]
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Attempt to break the block in direction of the turtle."
},
"turtle_attack_operation": {
"message0": "Attack in %1 of turtle with %2 side",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
},
{
"type": "field_dropdown",
"name": "SIDE",
"options": [
["Left", "LEFT"],
["Right", "RIGHT"]
]
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Attack the entity in direction of the turtle."
},
"turtle_place_operation": {
"message0": "Use/Place in %1 of turtle",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Place a block or item into the world in direction of the turtle."
},
"turtle_drop_operation": {
"message0": "Drop item in %1 of turtle for %2 items",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
},
{
"type": "input_value",
"name": "COUNT",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Drop the currently selected stack into the inventory in the turtle, or as an item into the world if there is no inventory."
},
"turtle_select_item": {
"message0": "Select item in slot %1",
"args0": [
{
"type": "input_value",
"name": "SLOT",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Change the currently selected slot."
},
"turtle_get_item_count": {
"message0": "Get item count in slot %1",
"args0": [
{
"type": "input_value",
"name": "SLOT",
"check": "Number"
}
],
"inputsInline": true,
"output": "Number",
"colour": 215,
"tooltip": "Get the number of items in the given slot."
},
"turtle_get_slot_free": {
"message0": "Get free space in slot %1",
"args0": [
{
"type": "input_value",
"name": "SLOT",
"check": "Number"
}
],
"inputsInline": true,
"output": "Number",
"colour": 215,
"tooltip": "Get the remaining number of items which may be stored in this stack."
},
"turtle_detect_block": {
"message0": "Detect solid block in %1 of turtle",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
}
],
"inputsInline": true,
"output": "Boolean",
"colour": 215,
"tooltip": "Check if there is a solid block in direction of the turtle."
},
"turtle_compare_item": {
"message0": "Compare block in %1 of turtle is equal current item slot",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
}
],
"inputsInline": true,
"output": "Boolean",
"colour": 215,
"tooltip": "Check if the block in direction of the turtle is equal to the item in the currently selected slot."
},
"turtle_collect_item": {
"message0": "Collect %1 items in %2 of turtle",
"args0": [
{
"type": "input_value",
"name": "COUNT",
"check": "Number"
},
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Collect an item from the inventory in direction of the turtle, or from an item floating in the world. If count is 0 it collect all item."
},
"turtle_get_fuel_level": {
"message0": "Get current fuel level",
"inputsInline": true,
"output": "Number",
"colour": 215,
"tooltip": "Get the maximum amount of fuel this turtle currently holds."
},
"turtle_refuel": {
"message0": "Refuel turtle for %1",
"args0": [
{
"type": "input_value",
"name": "COUNT",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Refuel this turtle. If 0 it refuel unlimit from current item."
},
"turtle_compare_to": {
"message0": "Compare item to slot %1",
"args0": [
{
"type": "input_value",
"name": "SLOT",
"check": "Number"
}
],
"inputsInline": true,
"output": "Boolean",
"colour": 215,
"tooltip": "Compare the item in the currently selected slot to the item in another slot."
},
"turtle_transfer_to": {
"message0": "Transfer item to slot %1 for %2 items",
"args0": [
{
"type": "input_value",
"name": "SLOT",
"check": "Number"
},
{
"type": "input_value",
"name": "COUNT",
"check": "Number"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"colour": 215,
"tooltip": "Move an item from the selected slot to another one."
},
"turtle_get_selected_slot": {
"message0": "Get current selected slot",
"inputsInline": true,
"output": "Number",
"colour": 215,
"tooltip": "Get the currently selected slot."
},
"turtle_get_fuel_limit": {
"message0": "Get fuel limit",
"inputsInline": true,
"output": "Number",
"colour": 215,
"tooltip": "Get the maximum amount of fuel this turtle can hold."
},
"turtle_equip": {
"message0": "Equip item on %1 side",
"args0": [
{
"type": "field_dropdown",
"name": "SIDE",
"options": [
["Left", "LEFT"],
["Right", "RIGHT"]
]
}
],
"inputsInline": true,
"output": "Multiple",
"colour": 215,
"tooltip": "Equip (or unequip) an item on the side of this turtle."
},
"turtle_inspect": {
"message0": "Inspect block on %1 side",
"args0": [
{
"type": "field_dropdown",
"name": "OPERATION",
"options": [
["Front", "FRONT"],
["Up", "UP"],
["Down", "DOWN"]
]
}
],
"inputsInline": true,
"output": "Multiple",
"colour": 215,
"tooltip": "Get information about the block in direction of the turtle."
},
"turtle_get_item_detail": {
"message0": "Get Item detail in slot %1",
"args0": [
{
"type": "input_value",
"name": "SLOT",
"check": "Number"
}
],
"inputsInline": true,
"output": "Array",
"colour": 215,
"tooltip": "Get detailed information about the items in the given slot."
},
"turtle_craft": {
"message0": "Craft Item with limit %1",
"args0": [
{
"type": "input_value",
"name": "LIMIT",
"check": "Number"
}
],
"inputsInline": true,
"output": "Multiple",
"colour": 215,
"tooltip": "Craft a recipe based on the turtle's inventory."
}
}

View File

@ -0,0 +1,58 @@
const { luaGenerator } = require('blockly/lua');
// Check if luaGenerator.forBlock is defined and initialize if necessary
if (!luaGenerator.forBlock) {
luaGenerator.forBlock = {};
}
// Math operation block
luaGenerator.forBlock['math_operation'] = function(block, generator) {
var operator = block.getFieldValue('OPERATOR');
var num1 = generator.valueToCode(block, 'NUM1', generator.ORDER_ATOMIC);
var num2 = generator.valueToCode(block, 'NUM2', generator.ORDER_ATOMIC);
var operatorSymbol = '';
switch (operator) {
case 'ADD':
operatorSymbol = '+';
break;
case 'SUBTRACT':
operatorSymbol = '-';
break;
case 'MULTIPLY':
operatorSymbol = '*';
break;
case 'DIVIDE':
operatorSymbol = '/';
break;
default:
operatorSymbol = '+';
break;
}
var code = `${num1} ${operatorSymbol} ${num2}`;
return [code, generator.ORDER_ATOMIC];
};
// Print text block
luaGenerator.forBlock['text_print'] = function(block, generator) {
var text = generator.valueToCode(block, 'TEXT', generator.ORDER_NONE) || '\'\'';
var code = `print(${text})\n`;
return code;
};
// If condition block
luaGenerator.forBlock['controls_if'] = function(block, generator) {
var condition = generator.valueToCode(block, 'IF0', generator.ORDER_NONE) || 'false';
var branch = generator.statementToCode(block, 'DO0');
var code = `if ${condition} then\n${branch}\nend\n`;
return code;
};
// Set variable block
luaGenerator.forBlock['variables_set'] = function(block, generator) {
var variable = generator.nameDB_.getName(block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
var value = generator.valueToCode(block, 'VALUE', generator.ORDER_NONE) || '0';
var code = `${variable} = ${value}\n`;
return code;
};

View File

@ -0,0 +1,22 @@
{
"name": "CC: Turtle",
"author": "DPSoftware Foundation",
"description": "Library for control turtle",
"version": "0.1",
"category": "turtle",
"keyword": "turtle",
"license": "GPL-3.0-or-later",
"peripherals": false,
"library": true,
"require_network": false,
"dependencies": {},
"design_for_computer": {
"basic": false,
"adv": false,
"command": false,
"pocket": false,
"advpocket": false,
"turtle": true,
"advturtle": true
}
}

View File

@ -0,0 +1,97 @@
<xml id="toolbox" style="display: none;">
<category name="Turtle" colour="215">
<block type="turtle_move_operation">
<value name="FOR">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="turtle_turn_operation">
<value name="ROUND">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="turtle_dig_operation"></block>
<block type="turtle_attack_operation"></block>
<block type="turtle_place_operation"></block>
<block type="turtle_drop_operation">
<value name="COUNT">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="turtle_select_item">
<value name="SLOT">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="turtle_get_item_count">
<value name="SLOT">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="turtle_get_slot_free">
<value name="SLOT">
<shadow type="math_number">
<field name="NUM">1</field>
</shadow>
</value>
</block>
<block type="turtle_detect_block"></block>
<block type="turtle_compare_item"></block>
<block type="turtle_collect_item">
<value name="COUNT">
<shadow type="math_number">
<field name="NUM">0</field> <!-- If 0 it collect all item-->
</shadow>
</value>
</block>
<block type="turtle_get_fuel_level"></block>
<block type="turtle_refuel">
<value name="COUNT">
<shadow type="math_number">
<field name="NUM">0</field> <!-- If 0 it refuel unlimit from current item-->
</shadow>
</value>
</block>
<block type="turtle_compare_to">
<value name="SLOT">
<shadow type="math_number">
<field name="NUM">1</field> <!-- If 0 it refuel unlimit from current item-->
</shadow>
</value>
</block>
<block type="turtle_transfer_to">
<value name="SLOT">
<shadow type="math_number">
<field name="NUM">1</field> <!-- If 0 it refuel unlimit from current item-->
</shadow>
</value>
<value name="COUNT">
<shadow type="math_number">
<field name="NUM">64</field> <!-- If 0 it refuel unlimit from current item-->
</shadow>
</value>
</block>
<block type="turtle_get_selected_slot"></block>
<block type="turtle_get_fuel_limit"></block>
<block type="turtle_equip"></block>
<block type="turtle_inspect"></block>
<block type="turtle_get_item_detail"></block>
<block type="turtle_craft">
<value name="LIMIT">
<shadow type="math_number">
<field name="NUM">64</field>
</shadow>
</value>
</block>
</category>
</xml>

View File

@ -13,5 +13,14 @@
"colour": 150,
"tooltip": "Add Code for some code is not in IDE",
"helpUrl": ""
},
"ide_start": {
"message0": "When Code Start",
"message1": "do %1",
"args1": [
{"type": "input_statement", "name": "DO"}
],
"colour": 150,
"tooltip": "Not require but make your code easy to read."
}
}

View File

@ -13,3 +13,17 @@ luaGenerator.forBlock['ide_addcode'] = function(block, generator) {
const cleanedStr = codefromuser.replace(/[']/g, '');
return cleanedStr+"\n";
};
luaGenerator.forBlock['ide_start'] = function(block, generator) {
var docode = generator.statementToCode(block, 'DO');
var code =
`
function main()
${docode}
end
main()
`
return code;
};

View File

@ -2,5 +2,6 @@
<category name="IDE" colour="150">
<!-- Define your custom blocks here -->
<block type="ide_addcode"></block>
<block type="ide_start"></block>
</category>
</xml>

Binary file not shown.

View File

@ -208,6 +208,19 @@ app.whenReady().then(() => {
}
},
{ type: 'separator' },
{
label: 'Export',
submenu: [
{
label: "Export Lua",
accelerator: 'CmdOrCtrl+Shift+L',
click: () => {
win.webContents.send('export-lua-request');
}
}
]
},
{ type: 'separator' },
{
label: 'Exit',
accelerator: 'CmdOrCtrl+Q',
@ -373,6 +386,28 @@ app.whenReady().then(() => {
}
});
ipc.on('export-lua', (event, data) => {
dialog.showSaveDialog(win, {
title: 'Save Project',
defaultPath: path.join(app.getPath('documents'), 'main.lua'),
filters: [
{ extensions: ['lua'] }
]
}).then(result => {
if (!result.canceled) {
fs.writeFile(result.filePath, data, (err) => {
if (err) {
console.error('Error exporting lua from project:', err);
dialog.showErrorBox("Export Lua Error", err.message)
}
});
}
}).catch(err => {
console.error('Error exporting lua from project:', err);
dialog.showErrorBox("Export Lua Error", err.message)
});
});
ipc.on('workspace-notsave', (event) => {
win.setTitle(`${currentprojectname}* | ccIDE`)
currentworkspacechange = true;
@ -383,7 +418,6 @@ app.whenReady().then(() => {
})
app.on("close", function(e) {
console.log("Close event triggered");
if (currentprojectopen) {

View File

@ -26,6 +26,15 @@ class CCRemote {
});
}
isClientConnect() {
for (const client of this.socket.clients) {
if (client.readyState === WebSocket.OPEN) {
return true;
}
}
return false;
}
sendCommand(command) {
// Iterate over each connected client and send the command
this.socket.clients.forEach((client) => {
@ -41,7 +50,6 @@ class CCRemote {
if (client.readyState === WebSocket.OPEN) {
client.send("sendcode");
setTimeout(() => {
console.log(Code)
client.send(Code);
return true
}, 500);
@ -62,6 +70,14 @@ class CCRemote {
});
}
disconnectAllClients() {
this.socket.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
client.close();
}
});
}
}
module.exports = { CCRemote };

View File

@ -38,7 +38,13 @@ const uploadUpdateProgress = () => {
function clientexit() {
ccInstance.sendCommand("exit")
ccInstance.disconnectAllClients();
}
function gencodeonly() {
return luaGenerator.workspaceToCode(workspace);
}
async function gencode() {
document.getElementById('upload-popup').style.display = 'block';
upcurrentActive = 1;
@ -60,18 +66,25 @@ async function gencode() {
return
}
// upload to computercraft with remote
document.getElementById('upload-status').textContent = "Uploading code to machine";
upcurrentActive++;
uploadUpdateProgress();
ccInstance.sendCode(code);
await delay(500)
if (ccInstance.isClientConnect()) {
// upload to computercraft with remote
document.getElementById('upload-status').textContent = "Uploading code to machine";
ccInstance.sendCode(code);
await delay(500)
// execute with remote
document.getElementById('upload-status').textContent = "Executing code";
upcurrentActive++;
uploadUpdateProgress();
ccInstance.runCode();
// execute with remote
document.getElementById('upload-status').textContent = "Executing code";
upcurrentActive++;
uploadUpdateProgress();
ccInstance.runCode();
} else {
uploadError = true;
uploadUpdateProgress();
document.getElementById('upload-status').innerHTML = `Please Connect Computer to IDE.\nInstruction: <a href="https://github.com/DPSoftware-Foundation/ccIDE#install-remote-code-into-computercraft">Install Remote code into computercraft</a> in github.`;
return
}
// done!
document.getElementById('upload-status').textContent = "Done!";

View File

@ -1,13 +1,4 @@
{
"sys_start": {
"message0": "When Code Start",
"message1": "do %1",
"args1": [
{"type": "input_statement", "name": "DO"}
],
"colour": 45,
"tooltip": "Not require but make your code easy to read."
},
"sys_sleep": {
"message0": "Sleep For %1 Second",
"args0": [

View File

@ -12,17 +12,3 @@ luaGenerator.forBlock['sys_sleep'] = function(block, generator) {
var code = `sleep(${sleepfor})\n`;
return code;
};
luaGenerator.forBlock['sys_start'] = function(block, generator) {
var docode = generator.statementToCode(block, 'DO');
var code =
`
function main()
${docode}
end
main()
`
return code;
};

View File

@ -46,7 +46,7 @@
<block type="controls_flow_statements"></block>
</category>
<category name="Events" colour="45">
<block type="sys_start"></block>
</category>
<category name="Math" colour="230">
<block type="math_number" gap="32">

View File

@ -39,6 +39,15 @@ var workspace = Blockly.inject('blocklyDiv', {
length: 3,
colour: '#ccc',
snap: true
},
zoom:{
controls: true,
wheel: true,
startScale: 1.0,
maxScale: 5,
minScale: 0.1,
scaleSpeed: 1.1,
pinch: true
}
});
@ -52,6 +61,10 @@ try {
}
workspace.getToolbox().getFlyout().autoClose = false;
ipc.on('export-lua-request', (event) => {
console.log("exporting lua")
ipc.send('export-lua', gencodeonly());
})
// Save workspace
ipc.on('save-workspace-request', (event) => {