smalruby-editor 0.1.1-x86-mingw32 → 0.1.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/demos/default.xml +1 -1
- data/app/assets/javascripts/application.js +1 -0
- data/app/assets/javascripts/blocks/blockly.js.coffee.erb +1 -1
- data/app/assets/javascripts/blocks/events.js.coffee.erb +2 -3
- data/app/assets/javascripts/blocks/field_character.js.coffee.erb +108 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +35 -2
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +4 -4
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +27 -29
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +4 -6
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +21 -19
- data/app/assets/javascripts/models/character.js.coffee +21 -0
- data/app/assets/javascripts/views/character_modal_view.js.coffee +24 -3
- data/app/views/editor/_character_modal.html.haml +1 -1
- data/app/views/editor/_toolbox.html.haml +7 -3
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/assets/{application-0c2ae32cd8822cec7ba6e445e2501010.js → application-735e172a0df828da16d22f5d3c26671f.js} +294 -59
- data/public/assets/{application-0c2ae32cd8822cec7ba6e445e2501010.js.gz → application-735e172a0df828da16d22f5d3c26671f.js.gz} +0 -0
- data/public/assets/{default-7f438ebd7f8ab6ef65c5b9744786e57f.xml → default-5d1886100d7c8961e9962bbc4bb0c714.xml} +1 -1
- data/public/assets/manifest-1f254fa92a71ba4faad0f99136daeed8.json +1 -1
- data/spec/acceptance/block_mode/blocks/hardware/servo_set_position.feature +104 -0
- data/spec/acceptance/block_mode/blocks/operators/and_or.feature +61 -0
- data/spec/acceptance/block_mode/blocks/operators/four_arithmetic_and_compares.feature +85 -0
- data/spec/acceptance/block_mode/blocks/operators/index_of.feature +60 -0
- data/spec/acceptance/block_mode/blocks/operators/length.feature +52 -0
- data/spec/acceptance/block_mode/blocks/operators/math_method.feature +109 -0
- data/spec/acceptance/block_mode/blocks/operators/negate.feature +47 -0
- data/spec/acceptance/block_mode/blocks/operators/rand.feature +60 -0
- data/spec/acceptance/block_mode/blocks/operators/round.feature +52 -0
- data/spec/acceptance/block_mode/blocks/operators/true_false.feature +36 -0
- data/spec/acceptance/block_mode/blocks/ruby/expression.feature +36 -0
- data/spec/acceptance/block_mode/blocks/ruby/p.feature +34 -0
- data/spec/acceptance/block_mode/blocks/ruby/statement_comment.feature +25 -0
- data/spec/javascripts/models/character_spec.coffee +44 -5
- data/spec/steps/ace_steps.rb +9 -0
- data/spec/steps/block_mode_steps.rb +14 -0
- data/spec/steps/fix_turnip.rb +35 -0
- data/spec/steps/text_editor_steps.rb +1 -0
- data/spec/teaspoon_env.rb +1 -1
- data/spec/turnip_helper.rb +1 -0
- metadata +34 -5
@@ -12642,6 +12642,26 @@ Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
|
|
12642
12642
|
});
|
12643
12643
|
}
|
12644
12644
|
},
|
12645
|
+
validate: function(attrs, options) {
|
12646
|
+
var errors, name;
|
12647
|
+
errors = [];
|
12648
|
+
name = attrs.name;
|
12649
|
+
if (_.isUndefined(name) || _.isNull(name) || (_.isString(name) && name.length === 0)) {
|
12650
|
+
errors.push({
|
12651
|
+
attr: 'name',
|
12652
|
+
message: 'Name is required'
|
12653
|
+
});
|
12654
|
+
}
|
12655
|
+
if (_.isString(name) && name.match(/^[0-9A-Z]|[!\"\#$%&\'()\-=^~\\|@`\[{;+:*\]},<.>/?]/)) {
|
12656
|
+
errors.push({
|
12657
|
+
attr: 'name',
|
12658
|
+
message: 'Name is invalid'
|
12659
|
+
});
|
12660
|
+
}
|
12661
|
+
if (errors.length > 0) {
|
12662
|
+
return errors;
|
12663
|
+
}
|
12664
|
+
},
|
12645
12665
|
link: function(object) {
|
12646
12666
|
this.objects.push(object);
|
12647
12667
|
this.objects = _.uniq(this.objects);
|
@@ -12820,7 +12840,7 @@ Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
|
|
12820
12840
|
},
|
12821
12841
|
previewZoomLevel: 0.5,
|
12822
12842
|
initialize: function() {
|
12823
|
-
var self, setPosition,
|
12843
|
+
var changeNameFunc, self, setPosition,
|
12824
12844
|
_this = this;
|
12825
12845
|
this.target = null;
|
12826
12846
|
$('#character-modal-costume-selector img').on('dragstart', function(e) {
|
@@ -12855,12 +12875,14 @@ Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
|
|
12855
12875
|
}
|
12856
12876
|
});
|
12857
12877
|
self = this;
|
12858
|
-
|
12878
|
+
changeNameFunc = function(e) {
|
12859
12879
|
self.model.set({
|
12860
12880
|
name: $(this).val()
|
12861
12881
|
});
|
12862
12882
|
return self.nameChanged = true;
|
12863
|
-
}
|
12883
|
+
};
|
12884
|
+
this.$el.find('input[name="character[name]"]').change(changeNameFunc);
|
12885
|
+
this.$el.find('input[name="character[name]"]').keyup(changeNameFunc);
|
12864
12886
|
this.$el.find('input[name="character[x]"]').change(function(e) {
|
12865
12887
|
return self.model.set({
|
12866
12888
|
x: $(this).val()
|
@@ -12881,10 +12903,12 @@ Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
|
|
12881
12903
|
this.listenTo(this.model, 'change:y', this.onChangeY);
|
12882
12904
|
this.listenTo(this.model, 'change:angle', this.onChangeAngle);
|
12883
12905
|
this.listenTo(this.model, 'change:costumes', this.onChangeCostumes);
|
12884
|
-
|
12906
|
+
this.listenTo(this.model, 'change', this.onChange);
|
12907
|
+
return this.callAllOnChangeAttributes_();
|
12885
12908
|
},
|
12886
12909
|
render: function() {
|
12887
12910
|
var f;
|
12911
|
+
this.onChange(this.model);
|
12888
12912
|
this.$el.modal('show');
|
12889
12913
|
f = function() {
|
12890
12914
|
var img;
|
@@ -12905,7 +12929,7 @@ Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
|
|
12905
12929
|
return setTimeout(_.bind(f, this), 1);
|
12906
12930
|
}
|
12907
12931
|
},
|
12908
|
-
|
12932
|
+
callAllOnChangeAttributes_: function() {
|
12909
12933
|
this.onChangeName(this.model, this.model.get('name'));
|
12910
12934
|
this.onChangeX(this.model, this.model.get('x'));
|
12911
12935
|
this.onChangeY(this.model, this.model.get('y'));
|
@@ -12955,6 +12979,29 @@ Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE = Blockly.Msg.CONTROLS_IF_MSG_ELSE;
|
|
12955
12979
|
return this.readImageSizeflag = true;
|
12956
12980
|
}
|
12957
12981
|
},
|
12982
|
+
onChange: function(model, options) {
|
12983
|
+
var name;
|
12984
|
+
if (!this.target) {
|
12985
|
+
return;
|
12986
|
+
}
|
12987
|
+
this.$el.find('.control-group[for="character[name]"]').removeClass('error');
|
12988
|
+
this.$el.find('#character-modal-ok-button').removeClass('disabled').removeAttr('disabled');
|
12989
|
+
if (!this.model.isValid()) {
|
12990
|
+
this.$el.find('.control-group[for="character[name]"]').addClass('error');
|
12991
|
+
this.$el.find('#character-modal-ok-button').addClass('disabled').attr({
|
12992
|
+
disabled: 'disabled'
|
12993
|
+
});
|
12994
|
+
}
|
12995
|
+
name = this.model.get('name');
|
12996
|
+
if (this.target.get('name') !== name && Smalruby.Collections.CharacterSet.findWhere({
|
12997
|
+
name: name
|
12998
|
+
})) {
|
12999
|
+
this.$el.find('.control-group[for="character[name]"]').addClass('error');
|
13000
|
+
return this.$el.find('#character-modal-ok-button').addClass('disabled').attr({
|
13001
|
+
disabled: 'disabled'
|
13002
|
+
});
|
13003
|
+
}
|
13004
|
+
},
|
12958
13005
|
onSelectCostume: function(e) {
|
12959
13006
|
var attrs, costume, prefix;
|
12960
13007
|
e.preventDefault();
|
@@ -13405,37 +13452,45 @@ case end next return until\
|
|
13405
13452
|
|
13406
13453
|
Blockly.Ruby.ORDER_MEMBER = 2;
|
13407
13454
|
|
13408
|
-
Blockly.Ruby.
|
13455
|
+
Blockly.Ruby.ORDER_INDEX = 3;
|
13456
|
+
|
13457
|
+
Blockly.Ruby.ORDER_FUNCTION_CALL = 4;
|
13458
|
+
|
13459
|
+
Blockly.Ruby.ORDER_UNARY_SIGN = 5;
|
13409
13460
|
|
13410
|
-
Blockly.Ruby.ORDER_EXPONENTIATION =
|
13461
|
+
Blockly.Ruby.ORDER_EXPONENTIATION = 6;
|
13411
13462
|
|
13412
|
-
Blockly.Ruby.
|
13463
|
+
Blockly.Ruby.ORDER_UNARY_MINUS_SIGN = 7;
|
13413
13464
|
|
13414
|
-
Blockly.Ruby.
|
13465
|
+
Blockly.Ruby.ORDER_MULTIPLICATIVE = 8;
|
13415
13466
|
|
13416
|
-
Blockly.Ruby.
|
13467
|
+
Blockly.Ruby.ORDER_ADDITIVE = 9;
|
13417
13468
|
|
13418
|
-
Blockly.Ruby.
|
13469
|
+
Blockly.Ruby.ORDER_BITWISE_SHIFT = 10;
|
13419
13470
|
|
13420
|
-
Blockly.Ruby.
|
13471
|
+
Blockly.Ruby.ORDER_BITWISE_AND = 11;
|
13421
13472
|
|
13422
|
-
Blockly.Ruby.
|
13473
|
+
Blockly.Ruby.ORDER_BITWISE_XOR = 12;
|
13423
13474
|
|
13424
|
-
Blockly.Ruby.
|
13475
|
+
Blockly.Ruby.ORDER_BITWISE_OR = 12;
|
13425
13476
|
|
13426
|
-
Blockly.Ruby.
|
13477
|
+
Blockly.Ruby.ORDER_RELATIONAL = 13;
|
13427
13478
|
|
13428
|
-
Blockly.Ruby.
|
13479
|
+
Blockly.Ruby.ORDER_EQUALS = 14;
|
13429
13480
|
|
13430
|
-
Blockly.Ruby.
|
13481
|
+
Blockly.Ruby.ORDER_LOGICAL_AND = 15;
|
13431
13482
|
|
13432
|
-
Blockly.Ruby.
|
13483
|
+
Blockly.Ruby.ORDER_LOGICAL_OR = 16;
|
13433
13484
|
|
13434
|
-
Blockly.Ruby.
|
13485
|
+
Blockly.Ruby.ORDER_RANGE = 17;
|
13435
13486
|
|
13436
|
-
Blockly.Ruby.ORDER_CONDITIONAL =
|
13487
|
+
Blockly.Ruby.ORDER_CONDITIONAL = 18;
|
13437
13488
|
|
13438
|
-
Blockly.Ruby.
|
13489
|
+
Blockly.Ruby.ORDER_ASSIGNMENT = 19;
|
13490
|
+
|
13491
|
+
Blockly.Ruby.ORDER_NOT = 20;
|
13492
|
+
|
13493
|
+
Blockly.Ruby.ORDER_AND_OR = 21;
|
13439
13494
|
|
13440
13495
|
Blockly.Ruby.ORDER_NONE = 99;
|
13441
13496
|
|
@@ -13642,12 +13697,160 @@ case end next return until\
|
|
13642
13697
|
return commentCode + code + nextCode;
|
13643
13698
|
};
|
13644
13699
|
|
13700
|
+
}).call(this);
|
13701
|
+
(function() {
|
13702
|
+
'use strict';
|
13703
|
+
goog.provide('Smalruby.FieldCharacter');
|
13704
|
+
|
13705
|
+
goog.require('Blockly.FieldDropdown');
|
13706
|
+
|
13707
|
+
Smalruby.FieldCharacter = function(character, opt_changeHandler) {
|
13708
|
+
var changeHandler, charSet,
|
13709
|
+
_this = this;
|
13710
|
+
if (opt_changeHandler) {
|
13711
|
+
changeHandler = function(value) {
|
13712
|
+
var newVal, retVal;
|
13713
|
+
retVal = Smalruby.FieldCharacter.dropdownChange.call(_this, value);
|
13714
|
+
if (retVal) {
|
13715
|
+
newVal = retVal;
|
13716
|
+
} else {
|
13717
|
+
retVal = _this.getValue();
|
13718
|
+
}
|
13719
|
+
opt_changeHandler.call(_this, newVal);
|
13720
|
+
return retVal;
|
13721
|
+
};
|
13722
|
+
} else {
|
13723
|
+
changeHandler = Smalruby.FieldCharacter.dropdownChange;
|
13724
|
+
}
|
13725
|
+
Smalruby.FieldCharacter.superClass_.constructor.call(this, Smalruby.FieldCharacter.dropdownCreate, changeHandler);
|
13726
|
+
charSet = Smalruby.Collections.CharacterSet;
|
13727
|
+
charSet.on('add', this.onCharacterSetAdd_, this);
|
13728
|
+
charSet.on('remove', this.onCharacterSetRemove_, this);
|
13729
|
+
charSet.on('reset', this.onCharacterSetReset_, this);
|
13730
|
+
this.character = Smalruby.FieldCharacter.NullCharacter;
|
13731
|
+
if (!character) {
|
13732
|
+
character = Smalruby.Collections.CharacterSet.first();
|
13733
|
+
}
|
13734
|
+
return this.setCharacter(character);
|
13735
|
+
};
|
13736
|
+
|
13737
|
+
goog.inherits(Smalruby.FieldCharacter, Blockly.FieldDropdown);
|
13738
|
+
|
13739
|
+
Smalruby.FieldCharacter.prototype.setCharacter = function(character) {
|
13740
|
+
if (character === this.character) {
|
13741
|
+
return;
|
13742
|
+
}
|
13743
|
+
this.character.unlink(this);
|
13744
|
+
this.character.off('change:name', this.onCharacterChangeName_, this);
|
13745
|
+
this.character = character ? character : Smalruby.FieldCharacter.NullCharacter;
|
13746
|
+
this.character.link(this);
|
13747
|
+
this.character.on('change:name', this.onCharacterChangeName_, this);
|
13748
|
+
return this.setValue(this.character.get('name'));
|
13749
|
+
};
|
13750
|
+
|
13751
|
+
Smalruby.FieldCharacter.prototype.onCharacterSetAdd_ = function(model, collection, options) {
|
13752
|
+
if (this.character === Smalruby.FieldCharacter.NullCharacter) {
|
13753
|
+
return this.setCharacter(model);
|
13754
|
+
}
|
13755
|
+
};
|
13756
|
+
|
13757
|
+
Smalruby.FieldCharacter.prototype.onCharacterSetRemove_ = function(model, collection, options) {
|
13758
|
+
if (model === this.character) {
|
13759
|
+
return this.setCharacter();
|
13760
|
+
}
|
13761
|
+
};
|
13762
|
+
|
13763
|
+
Smalruby.FieldCharacter.prototype.onCharacterSetReset_ = function(collection, options) {
|
13764
|
+
if (this.character === Smalruby.FieldCharacter.NullCharacter) {
|
13765
|
+
return this.setCharacter(collection.first());
|
13766
|
+
} else {
|
13767
|
+
return this.setCharacter(collection.findWhere({
|
13768
|
+
name: this.getValue()
|
13769
|
+
}));
|
13770
|
+
}
|
13771
|
+
};
|
13772
|
+
|
13773
|
+
Smalruby.FieldCharacter.prototype.onCharacterChangeName_ = function(model, value, options) {
|
13774
|
+
return this.setValue(value);
|
13775
|
+
};
|
13776
|
+
|
13777
|
+
Smalruby.FieldCharacter.prototype.clone = function() {
|
13778
|
+
return new Smalruby.FieldCharacter(this.character, this.changeHandler_);
|
13779
|
+
};
|
13780
|
+
|
13781
|
+
Smalruby.FieldCharacter.prototype.dispose = function() {
|
13782
|
+
var charSet;
|
13783
|
+
charSet = Smalruby.Collections.CharacterSet;
|
13784
|
+
charSet.off('add', this.onCharacterSetAdd_, this);
|
13785
|
+
charSet.off('remove', this.onCharacterSetRemove_, this);
|
13786
|
+
charSet.off('reset', this.onCharacterSetReset_, this);
|
13787
|
+
this.setCharacter();
|
13788
|
+
return Blockly.FieldDropdown.prototype.dispose.call(this);
|
13789
|
+
};
|
13790
|
+
|
13791
|
+
Smalruby.FieldCharacter.prototype.setText = function(value) {
|
13792
|
+
var charSet;
|
13793
|
+
if (!this.character) {
|
13794
|
+
this.character = Smalruby.FieldCharacter.NullCharacter;
|
13795
|
+
charSet = Smalruby.Collections.CharacterSet;
|
13796
|
+
this.setCharacter(charSet.findWhere({
|
13797
|
+
name: value
|
13798
|
+
}));
|
13799
|
+
}
|
13800
|
+
return Blockly.FieldDropdown.prototype.setText.call(this, value);
|
13801
|
+
};
|
13802
|
+
|
13803
|
+
Smalruby.FieldCharacter.dropdownCreate = function() {
|
13804
|
+
var charSet;
|
13805
|
+
charSet = Smalruby.Collections.CharacterSet;
|
13806
|
+
if (charSet.length > 0) {
|
13807
|
+
return Smalruby.Collections.CharacterSet.map(function(c) {
|
13808
|
+
var n;
|
13809
|
+
n = c.get('name');
|
13810
|
+
return [n, n];
|
13811
|
+
});
|
13812
|
+
} else {
|
13813
|
+
return [[Smalruby.FieldCharacter.NullCharacter.get('name'), '']];
|
13814
|
+
}
|
13815
|
+
};
|
13816
|
+
|
13817
|
+
Smalruby.FieldCharacter.dropdownChange = function(value) {
|
13818
|
+
var c;
|
13819
|
+
c = Smalruby.Collections.CharacterSet.findWhere({
|
13820
|
+
name: value
|
13821
|
+
});
|
13822
|
+
if (c) {
|
13823
|
+
this.setCharacter(c);
|
13824
|
+
return value;
|
13825
|
+
} else {
|
13826
|
+
return null;
|
13827
|
+
}
|
13828
|
+
};
|
13829
|
+
|
13830
|
+
Smalruby.FieldCharacter.NullCharacter = {
|
13831
|
+
get: function(name) {
|
13832
|
+
return 'キャラクターなし';
|
13833
|
+
},
|
13834
|
+
on: function() {
|
13835
|
+
return $.noop;
|
13836
|
+
},
|
13837
|
+
off: function() {
|
13838
|
+
return $.noop;
|
13839
|
+
},
|
13840
|
+
link: function() {
|
13841
|
+
return $.noop;
|
13842
|
+
},
|
13843
|
+
unlink: function() {
|
13844
|
+
return $.noop;
|
13845
|
+
}
|
13846
|
+
};
|
13847
|
+
|
13645
13848
|
}).call(this);
|
13646
13849
|
(function() {
|
13647
13850
|
Blockly.Ruby['math_number'] = function(block) {
|
13648
13851
|
var code, order;
|
13649
13852
|
code = parseFloat(this.getFieldValue('NUM'));
|
13650
|
-
order = code < 0 ? Blockly.Ruby.
|
13853
|
+
order = code < 0 ? Blockly.Ruby.ORDER_UNARY_MINUS_SIGN : Blockly.Ruby.ORDER_ATOMIC;
|
13651
13854
|
return [code, order];
|
13652
13855
|
};
|
13653
13856
|
|
@@ -14015,7 +14218,7 @@ case end next return until\
|
|
14015
14218
|
init: function() {
|
14016
14219
|
this.setHelpUrl('');
|
14017
14220
|
this.setColour(33);
|
14018
|
-
this.appendDummyInput().appendField(new
|
14221
|
+
this.appendDummyInput().appendField(new Smalruby.FieldCharacter(), 'CHAR').appendField('にぶつかったとき');
|
14019
14222
|
this.appendStatementInput('DO');
|
14020
14223
|
this.setPreviousStatement(true);
|
14021
14224
|
this.setNextStatement(true);
|
@@ -14025,17 +14228,18 @@ case end next return until\
|
|
14025
14228
|
|
14026
14229
|
Blockly.Ruby['events_on_hit'] = function(block) {
|
14027
14230
|
var char;
|
14028
|
-
char =
|
14231
|
+
char = this.getFieldValue('CHAR');
|
14029
14232
|
return Blockly.Ruby.characterEvent_(block, 'DO', 'hit', char);
|
14030
14233
|
};
|
14031
14234
|
|
14032
14235
|
}).call(this);
|
14033
14236
|
(function() {
|
14034
|
-
var acDropdown, aiPinDropdown, dioPinDropdown, n, pwmPinDropdown;
|
14237
|
+
var acDropdown, aiPinDropdown, dioPinDropdown, n, pwmPinDropdown, rgbLedPinDropdown;
|
14035
14238
|
|
14036
14239
|
window.SmalrubyEditor.Hardware = {
|
14037
14240
|
Type: 'Arduino',
|
14038
14241
|
DioPins: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
14242
|
+
PwmPins: [3, 5, 6, 9, 10, 11],
|
14039
14243
|
AiPins: [0, 1, 2, 3, 4, 5]
|
14040
14244
|
};
|
14041
14245
|
|
@@ -14051,6 +14255,17 @@ case end next return until\
|
|
14051
14255
|
})();
|
14052
14256
|
|
14053
14257
|
pwmPinDropdown = (function() {
|
14258
|
+
var _i, _len, _ref, _results;
|
14259
|
+
_ref = window.SmalrubyEditor.Hardware.PwmPins;
|
14260
|
+
_results = [];
|
14261
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
14262
|
+
n = _ref[_i];
|
14263
|
+
_results.push(["D" + n, "D" + n]);
|
14264
|
+
}
|
14265
|
+
return _results;
|
14266
|
+
})();
|
14267
|
+
|
14268
|
+
rgbLedPinDropdown = (function() {
|
14054
14269
|
var _i, _len, _ref, _results;
|
14055
14270
|
_ref = [3, 9];
|
14056
14271
|
_results = [];
|
@@ -14128,7 +14343,7 @@ case end next return until\
|
|
14128
14343
|
init: function() {
|
14129
14344
|
this.setHelpUrl('');
|
14130
14345
|
this.setColour(208);
|
14131
|
-
this.appendDummyInput().appendField('RGB LED').appendField(new Blockly.FieldDropdown(acDropdown), 'AC').appendField('コモン').appendField(new Blockly.FieldDropdown(
|
14346
|
+
this.appendDummyInput().appendField('RGB LED').appendField(new Blockly.FieldDropdown(acDropdown), 'AC').appendField('コモン').appendField(new Blockly.FieldDropdown(rgbLedPinDropdown), 'PIN').appendField('を').appendField(new Blockly.FieldColour('#ff0000'), 'COLOUR').appendField('にする');
|
14132
14347
|
this.setPreviousStatement(true);
|
14133
14348
|
this.setNextStatement(true);
|
14134
14349
|
return this.setTooltip('');
|
@@ -14150,7 +14365,7 @@ case end next return until\
|
|
14150
14365
|
init: function() {
|
14151
14366
|
this.setHelpUrl('');
|
14152
14367
|
this.setColour(208);
|
14153
|
-
this.appendDummyInput().appendField('RGB LED').appendField(new Blockly.FieldDropdown(acDropdown), 'AC').appendField('コモン').appendField(new Blockly.FieldDropdown(
|
14368
|
+
this.appendDummyInput().appendField('RGB LED').appendField(new Blockly.FieldDropdown(acDropdown), 'AC').appendField('コモン').appendField(new Blockly.FieldDropdown(rgbLedPinDropdown), 'PIN').appendField('をオフにする');
|
14154
14369
|
this.setPreviousStatement(true);
|
14155
14370
|
this.setNextStatement(true);
|
14156
14371
|
return this.setTooltip('');
|
@@ -14254,6 +14469,27 @@ case end next return until\
|
|
14254
14469
|
return "seven_segment_display.off\n";
|
14255
14470
|
};
|
14256
14471
|
|
14472
|
+
Blockly.Blocks['hardware_servo_set_position'] = {
|
14473
|
+
init: function() {
|
14474
|
+
this.setHelpUrl('');
|
14475
|
+
this.setColour(208);
|
14476
|
+
this.appendDummyInput().appendField('サーボ').appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN').appendField('を');
|
14477
|
+
this.appendValueInput('POS').setCheck('Number');
|
14478
|
+
this.appendDummyInput().appendField('度(5~180)にする');
|
14479
|
+
this.setInputsInline(true);
|
14480
|
+
this.setPreviousStatement(true);
|
14481
|
+
this.setNextStatement(true);
|
14482
|
+
return this.setTooltip('');
|
14483
|
+
}
|
14484
|
+
};
|
14485
|
+
|
14486
|
+
Blockly.Ruby['hardware_servo_set_position'] = function(block) {
|
14487
|
+
var pin, pos;
|
14488
|
+
pin = this.getFieldValue('PIN');
|
14489
|
+
pos = Blockly.Ruby.valueToCode(this, 'POS', Blockly.Ruby.ORDER_FUNCTION_CALL) || '5';
|
14490
|
+
return Blockly.Ruby.characterMethodCall_("servo(" + (Blockly.Ruby.quote_(pin)) + ").position = " + pos);
|
14491
|
+
};
|
14492
|
+
|
14257
14493
|
Blockly.Blocks['hardware_button_down'] = {
|
14258
14494
|
init: function() {
|
14259
14495
|
this.setHelpUrl('');
|
@@ -14650,7 +14886,7 @@ case end next return until\
|
|
14650
14886
|
init: function() {
|
14651
14887
|
this.setHelpUrl('');
|
14652
14888
|
this.setColour(225);
|
14653
|
-
this.appendDummyInput().appendField(new
|
14889
|
+
this.appendDummyInput().appendField(new Smalruby.FieldCharacter(), 'CHAR').appendField('へ向ける');
|
14654
14890
|
this.setPreviousStatement(true);
|
14655
14891
|
this.setNextStatement(true);
|
14656
14892
|
return this.setTooltip('');
|
@@ -14659,7 +14895,7 @@ case end next return until\
|
|
14659
14895
|
|
14660
14896
|
Blockly.Ruby['motion_point_towards_character'] = function(block) {
|
14661
14897
|
var char;
|
14662
|
-
char =
|
14898
|
+
char = this.getFieldValue('CHAR');
|
14663
14899
|
return Blockly.Ruby.characterMethodCall_('point_towards', char);
|
14664
14900
|
};
|
14665
14901
|
|
@@ -14705,7 +14941,7 @@ case end next return until\
|
|
14705
14941
|
init: function() {
|
14706
14942
|
this.setHelpUrl('');
|
14707
14943
|
this.setColour(225);
|
14708
|
-
this.appendDummyInput().appendField(new
|
14944
|
+
this.appendDummyInput().appendField(new Smalruby.FieldCharacter(), 'CHAR').appendField('へ行く');
|
14709
14945
|
this.setPreviousStatement(true);
|
14710
14946
|
this.setNextStatement(true);
|
14711
14947
|
return this.setTooltip('');
|
@@ -14713,8 +14949,8 @@ case end next return until\
|
|
14713
14949
|
};
|
14714
14950
|
|
14715
14951
|
Blockly.Ruby['motion_go_to_character'] = function(block) {
|
14716
|
-
var
|
14717
|
-
|
14952
|
+
var char;
|
14953
|
+
char = this.getFieldValue('CHAR');
|
14718
14954
|
return "" + (Blockly.Ruby.rn()) + "go_to(" + var0 + ")\n";
|
14719
14955
|
};
|
14720
14956
|
|
@@ -14991,11 +15227,11 @@ case end next return until\
|
|
14991
15227
|
var a, b, order;
|
14992
15228
|
order = Blockly.Ruby.ORDER_MULTIPLICATIVE;
|
14993
15229
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0';
|
14994
|
-
b = Blockly.Ruby.valueToCode(block, 'B', order) || '
|
15230
|
+
b = Blockly.Ruby.valueToCode(block, 'B', order) || '1';
|
14995
15231
|
return [a + ' / ' + b, order];
|
14996
15232
|
};
|
14997
15233
|
|
14998
|
-
Blockly.Blocks['
|
15234
|
+
Blockly.Blocks['operators_compare_lt'] = {
|
14999
15235
|
init: function() {
|
15000
15236
|
this.setHelpUrl('');
|
15001
15237
|
this.setColour(93);
|
@@ -15006,7 +15242,7 @@ case end next return until\
|
|
15006
15242
|
}
|
15007
15243
|
};
|
15008
15244
|
|
15009
|
-
Blockly.Ruby['
|
15245
|
+
Blockly.Ruby['operators_compare_lt'] = function(block) {
|
15010
15246
|
var a, b, order;
|
15011
15247
|
order = Blockly.Ruby.ORDER_RELATIONAL;
|
15012
15248
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0';
|
@@ -15014,7 +15250,7 @@ case end next return until\
|
|
15014
15250
|
return [a + ' < ' + b, order];
|
15015
15251
|
};
|
15016
15252
|
|
15017
|
-
Blockly.Blocks['
|
15253
|
+
Blockly.Blocks['operators_compare_lte'] = {
|
15018
15254
|
init: function() {
|
15019
15255
|
this.setHelpUrl('');
|
15020
15256
|
this.setColour(93);
|
@@ -15025,7 +15261,7 @@ case end next return until\
|
|
15025
15261
|
}
|
15026
15262
|
};
|
15027
15263
|
|
15028
|
-
Blockly.Ruby['
|
15264
|
+
Blockly.Ruby['operators_compare_lte'] = function(block) {
|
15029
15265
|
var a, b, order;
|
15030
15266
|
order = Blockly.Ruby.ORDER_RELATIONAL;
|
15031
15267
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0';
|
@@ -15046,13 +15282,13 @@ case end next return until\
|
|
15046
15282
|
|
15047
15283
|
Blockly.Ruby['operators_compare_eq'] = function(block) {
|
15048
15284
|
var a, b, order;
|
15049
|
-
order = Blockly.Ruby.
|
15285
|
+
order = Blockly.Ruby.ORDER_EQUALS;
|
15050
15286
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0';
|
15051
15287
|
b = Blockly.Ruby.valueToCode(block, 'B', order) || '0';
|
15052
15288
|
return [a + ' == ' + b, order];
|
15053
15289
|
};
|
15054
15290
|
|
15055
|
-
Blockly.Blocks['
|
15291
|
+
Blockly.Blocks['operators_compare_gte'] = {
|
15056
15292
|
init: function() {
|
15057
15293
|
this.setHelpUrl('');
|
15058
15294
|
this.setColour(93);
|
@@ -15063,7 +15299,7 @@ case end next return until\
|
|
15063
15299
|
}
|
15064
15300
|
};
|
15065
15301
|
|
15066
|
-
Blockly.Ruby['
|
15302
|
+
Blockly.Ruby['operators_compare_gte'] = function(block) {
|
15067
15303
|
var a, b, order;
|
15068
15304
|
order = Blockly.Ruby.ORDER_RELATIONAL;
|
15069
15305
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0';
|
@@ -15071,7 +15307,7 @@ case end next return until\
|
|
15071
15307
|
return [a + ' >= ' + b, order];
|
15072
15308
|
};
|
15073
15309
|
|
15074
|
-
Blockly.Blocks['
|
15310
|
+
Blockly.Blocks['operators_compare_gt'] = {
|
15075
15311
|
init: function() {
|
15076
15312
|
this.setHelpUrl('');
|
15077
15313
|
this.setColour(93);
|
@@ -15082,7 +15318,7 @@ case end next return until\
|
|
15082
15318
|
}
|
15083
15319
|
};
|
15084
15320
|
|
15085
|
-
Blockly.Ruby['
|
15321
|
+
Blockly.Ruby['operators_compare_gt'] = function(block) {
|
15086
15322
|
var a, b, order;
|
15087
15323
|
order = Blockly.Ruby.ORDER_RELATIONAL;
|
15088
15324
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || '0';
|
@@ -15102,11 +15338,10 @@ case end next return until\
|
|
15102
15338
|
};
|
15103
15339
|
|
15104
15340
|
Blockly.Ruby['operators_rand'] = function(block) {
|
15105
|
-
var a, b
|
15106
|
-
|
15107
|
-
|
15108
|
-
b
|
15109
|
-
return ["rand(" + a + ".." + b + ")", order];
|
15341
|
+
var a, b;
|
15342
|
+
a = Blockly.Ruby.valueToCode(block, 'A', Blockly.Ruby.ORDER_RANGE) || '0';
|
15343
|
+
b = Blockly.Ruby.valueToCode(block, 'B', Blockly.Ruby.ORDER_RANGE) || '0';
|
15344
|
+
return ["rand(" + a + ".." + b + ")", Blockly.Ruby.ORDER_FUNCTION_CALL];
|
15110
15345
|
};
|
15111
15346
|
|
15112
15347
|
Blockly.Blocks['operators_and'] = {
|
@@ -15160,7 +15395,7 @@ case end next return until\
|
|
15160
15395
|
|
15161
15396
|
Blockly.Ruby['operators_negate'] = function(block) {
|
15162
15397
|
var a, order;
|
15163
|
-
order = Blockly.Ruby.
|
15398
|
+
order = Blockly.Ruby.ORDER_UNARY_SIGN;
|
15164
15399
|
a = Blockly.Ruby.valueToCode(block, 'A', order) || 'true';
|
15165
15400
|
return ["!" + a, order];
|
15166
15401
|
};
|
@@ -15177,11 +15412,10 @@ case end next return until\
|
|
15177
15412
|
};
|
15178
15413
|
|
15179
15414
|
Blockly.Ruby['operators_index_of'] = function(block) {
|
15180
|
-
var a, index
|
15181
|
-
|
15182
|
-
|
15183
|
-
index
|
15184
|
-
return ["" + a + "[" + index + "]", order];
|
15415
|
+
var a, index;
|
15416
|
+
a = Blockly.Ruby.valueToCode(block, 'A', Blockly.Ruby.ORDER_FUNCTION_CALL) || '""';
|
15417
|
+
index = Blockly.Ruby.valueToCode(block, 'INDEX', Blockly.Ruby.ORDER_INDEX) || '0';
|
15418
|
+
return ["" + a + "[" + index + "]", Blockly.Ruby.ORDER_FUNCTION_CALL];
|
15185
15419
|
};
|
15186
15420
|
|
15187
15421
|
Blockly.Blocks['operators_length'] = {
|
@@ -15216,8 +15450,8 @@ case end next return until\
|
|
15216
15450
|
Blockly.Ruby['operators_modulo'] = function(block) {
|
15217
15451
|
var a, b, order;
|
15218
15452
|
order = Blockly.Ruby.ORDER_MULTIPLICATIVE;
|
15219
|
-
a = Blockly.Ruby.valueToCode(block, 'A', order) || '
|
15220
|
-
b = Blockly.Ruby.valueToCode(block, 'B', order) || '
|
15453
|
+
a = Blockly.Ruby.valueToCode(block, 'A', order) || '1';
|
15454
|
+
b = Blockly.Ruby.valueToCode(block, 'B', order) || '1';
|
15221
15455
|
return ["" + a + " % " + b, order];
|
15222
15456
|
};
|
15223
15457
|
|
@@ -15445,7 +15679,7 @@ case end next return until\
|
|
15445
15679
|
init: function() {
|
15446
15680
|
this.setHelpUrl('');
|
15447
15681
|
this.setColour(200);
|
15448
|
-
this.appendDummyInput().appendField(new
|
15682
|
+
this.appendDummyInput().appendField(new Smalruby.FieldCharacter(), 'CHAR').appendField('に触れた');
|
15449
15683
|
this.setOutput(true, 'Boolean');
|
15450
15684
|
return this.setTooltip('');
|
15451
15685
|
}
|
@@ -15453,7 +15687,7 @@ case end next return until\
|
|
15453
15687
|
|
15454
15688
|
Blockly.Ruby['sensing_hit'] = function(block) {
|
15455
15689
|
var char;
|
15456
|
-
char =
|
15690
|
+
char = this.getFieldValue('CHAR');
|
15457
15691
|
return Blockly.Ruby.characterMethodCallInput_('hit?', char);
|
15458
15692
|
};
|
15459
15693
|
|
@@ -15524,7 +15758,7 @@ case end next return until\
|
|
15524
15758
|
dropdown = [['x座標', 'x'], ['y座標', 'y'], ['向き', 'angle'], ['コスチューム番号', 'costume_index'], ['コスチューム名', 'costume'], ['大きさ', 'scale'], ['ボリューム', 'volume']];
|
15525
15759
|
this.setHelpUrl('');
|
15526
15760
|
this.setColour(200);
|
15527
|
-
this.appendDummyInput().appendField(new
|
15761
|
+
this.appendDummyInput().appendField(new Smalruby.FieldCharacter(), 'CHAR').appendField('の').appendField(new Blockly.FieldDropdown(dropdown), 'PROPERTY');
|
15528
15762
|
this.setOutput(true, ['Number', 'String']);
|
15529
15763
|
return this.setTooltip('');
|
15530
15764
|
}
|
@@ -15532,7 +15766,7 @@ case end next return until\
|
|
15532
15766
|
|
15533
15767
|
Blockly.Ruby['sensing_character_property'] = function(block) {
|
15534
15768
|
var c, char, property;
|
15535
|
-
char =
|
15769
|
+
char = this.getFieldValue('CHAR');
|
15536
15770
|
property = this.getFieldValue('PROPERTY');
|
15537
15771
|
c = Smalruby.Collections.CharacterSet.findWhere({
|
15538
15772
|
name: char
|
@@ -15696,6 +15930,7 @@ case end next return until\
|
|
15696
15930
|
|
15697
15931
|
|
15698
15932
|
|
15933
|
+
|
15699
15934
|
|
15700
15935
|
|
15701
15936
|
;
|
Binary file
|