diff --git a/extern/lang/ebs.js b/extern/lang/ebs.js index 54bf2b465d..64325c1749 100644 --- a/extern/lang/ebs.js +++ b/extern/lang/ebs.js @@ -743,6 +743,7 @@ Lang.Blocks = { "CALC_get_date_minute": "시각(분)", "CALC_get_date_month": "월", "CALC_get_date_second": "시각(초)", + "CALC_get_date_day_of_week": "요일", "CALC_get_date_year": "연도", "CALC_get_sound_duration_1": "", "CALC_get_sound_duration_2": "소리의 길이", @@ -794,10 +795,14 @@ Lang.Blocks = { "JUDGEMENT_boolean_or": "또는", "JUDGEMENT_false": " 거짓 ", "JUDGEMENT_is_clicked": "마우스를 클릭했는가?", + "JUDGEMENT_is_object_clicked": "오브젝트를 클릭했는가?", "JUDGEMENT_is_press_some_key_1": "", "JUDGEMENT_is_press_some_key_2": "키가 눌러져 있는가?", "JUDGEMENT_reach_something_1": "", "JUDGEMENT_reach_something_2": "에 닿았는가?", + "JUDGEMENT_is_type_1": '(이)가', + "JUDGEMENT_is_type_2": '인가?', + "is_type_number": "숫자", "JUDGEMENT_true": " 참 ", "LOOKS": "생김새", "LOOKS_change_scale_percent_1": "크기를", @@ -1523,6 +1528,8 @@ Lang.Blocks = { "CALC_char_at_3": "번째 글자", "CALC_length_of_string_1": "", "CALC_length_of_string_2": "의 글자 수", + "CALC_reverse_of_string_1": "", + "CALC_reverse_of_string_2": "을(를) 뒤집기", "CALC_substring_1": "", "CALC_substring_2": "의", "CALC_substring_3": "번째 글자부터", @@ -1537,6 +1544,8 @@ Lang.Blocks = { "CALC_change_string_case_3": " ", "CALC_change_string_case_sub_1": "대문자", "CALC_change_string_case_sub_2": "소문자", + "CALC_count_match_string_1": "에서", + "CALC_count_match_string_2": "의 글자 개수", "CALC_index_of_string_1": "", "CALC_index_of_string_2": "에서", "CALC_index_of_string_3": "의 시작 위치", @@ -1581,6 +1590,7 @@ Lang.Blocks = { "entry_bot_name": "엔트리봇", "hi_entry": "", "hi_entry_en": "", + "hello_entry": "hello entry", "bark_dog": "", "walking_entryBot": "엔트리봇_걷기", "doggi_bark": "강아지 짖는 소리", @@ -5376,8 +5386,10 @@ Lang.Helper = { "sound_volume_set": "작품에서 재생되는 모든 소리의 크기를 입력한 값으로 정합니다.", "sound_silent_all": "재생 중인 모든 소리를 멈춥니다.", "is_clicked": "마우스를 클릭한 경우 ‘참’으로 판단합니다.", + "is_object_clicked": "오브젝트를 클릭한 경우 ‘참’으로 판단합니다.", "is_press_some_key": "선택한 키가 눌려져 있는 경우 ‘참’으로 판단합니다.", "reach_something": "해당 오브젝트가 선택한 항목과 닿은 경우 ‘참’으로 판단합니다.", + "is_type": "입력한 값이 숫자라면 ‘참’으로 판단합니다.", "is_included_in_list": "선택한 리스트가 입력한 값을 가진 항목을 포함하는 경우 '참'으로 판단합니다.", "boolean_basic_operator": "입력한 두 값을 비교합니다.\n= : 왼쪽에 위치한 값과 오른쪽에 위치한 값이 같은 경우 '참'으로 판단합니다.\n> : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 큰 경우 같로 판단합니다.\n< : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 작은 경우 '참'으로 판단합니다.\n≥ : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 크거나 같은 경우 '참'으로 판단합니다.\n≤ : 왼쪽에 위치한 값이 오른쪽에 위치한 값보다 작거나 같은 경우 '참'으로 판단합니다.", "function_create": "자주 쓰는 코드를 이 블록 아래에 조립하여 함수로 만듭니다. [함수 정의하기]의 오른쪽 빈칸에 [이름]을 조립하여 함수의 이름을 정할 수 있습니다. 함수를 실행하는 데 입력값이 필요한 경우 빈칸에 [문자/숫자값], [판단값]을 조립하여 매개변수로 사용합니다.", @@ -5399,7 +5411,7 @@ Lang.Helper = { "calc_share": "앞 수에서 뒤 수를 나누어 생긴 몫을 의미합니다.", "calc_mod": "앞 수에서 뒤 수를 나누어 생긴 나머지를 의미합니다.", "calc_operation": "입력한 수에 대한 다양한 수학식의 계산값입니다. (제곱, 루트, 사인값, 코사인값, 탄젠트값, 아크사인값, 아크코사인값, 아크탄젠트값, 로그값, 자연로그값, 소수점 부분, 소수점 버림값, 소수점 올림값, 소수점 반올림값, 펙토리얼값, 절대값)", - "get_date": "현재 연도, 월, 일, 시각과 같이 시간에 대한 값입니다.", + "get_date": "현재 연도, 월, 일, 요일, 시각과 같이 시간에 대한 값입니다.", "distance_something": "해당 오브젝트와 선택한 오브젝트 또는 마우스 포인터 간의 거릿값입니다.", "get_sound_duration": "선택한 소리의 길이(초) 값입니다.", "get_user_name": "작품을 실행하고 있는 사용자의 이름값입니다.", @@ -5411,6 +5423,7 @@ Lang.Helper = { "get_canvas_input_value": "사용자가 '대답 창'에 입력한 값입니다.", "set_visible_answer": "대답 창'을 실행화면에서 숨기거나 보이게 합니다.", "combine_something": "입력한 두 값을 결합한 값입니다.", + "reverse_of_string": "입력한 값을 뒤집은 값입니다.", "get_variable": "선택한 변수에 저장된 값입니다.", "change_variable": "선택한 변수에 입력한 값을 더합니다.", "set_variable": "선택한 변수의 값을 입력한 값으로 정합니다.", @@ -5454,6 +5467,7 @@ Lang.Helper = { "char_at": "입력한 값에서 입력한 숫자 번째의 글자 값입니다. (공백을 포함합니다.)", "length_of_string": "입력한 값의 공백을 포함한 글자 수입니다.", "substring": "입력한 값에서 입력한 범위 내의 글자 값입니다. (공백을 포함합니다.)", + "count_match_string": "입력한 값에서 지정한 값의 글자 개수입니다.", "replace_string": "입력한 값에서 지정한 값을 찾아 추가로 입력한 값으로 모두 바꾼 값입니다. (영문 입력 시 대소문자를 구분합니다.)", "index_of_string": "입력한 값에서 지정한 값이 처음으로 등장하는 위치 값입니다. (공백을 포함합니다.)", "change_string_case": "입력한 영문의 모든 알파벳을 대문자 또는 소문자로 바꾼 값입니다.", @@ -6031,10 +6045,12 @@ Lang.template = { "get_project_timer_value": "%1 %2", "char_at": "%1 %2 %3 %4 %5", "length_of_string": "%1 %2 %3", + "reverse_of_string": "%1 %2 %3", "substring": "%1 %2 %3 %4 %5 %6 %7", "replace_string": "%1 %2 %3 %4 %5 %6 %7", "change_string_case": "%1 %2 %3 %4 %5", "index_of_string": "%1 %2 %3 %4 %5", + "count_match_string": "%1 %2 %3 %4", "combine_something": "%1 %2 %3 %4 %5", "get_sound_volume": "%1 %2", "quotient_and_mod": "%1 %2 %3 %4 %5 %6", @@ -6248,8 +6264,10 @@ Lang.template = { "turtle_turn_unit_with_radius_in_direction": "%1 으로 %2 %3 반지름 %4 cm를 %5 방향으로 돌기 %6", "turtle_value": "%1", "is_clicked": "%1", + "is_object_clicked": "%1", "is_press_some_key": "%1 %2", "reach_something": "%1 %2 %3", + "is_type": '%1 %2 %3 %4', "boolean_comparison": "%1 %2 %3", "boolean_equal": "%1 %2 %3", "boolean_bigger": "%1 %2 %3", diff --git a/extern/lang/en.js b/extern/lang/en.js index 4cd8e21f76..561ae9633f 100644 --- a/extern/lang/en.js +++ b/extern/lang/en.js @@ -722,6 +722,8 @@ Lang.Blocks = { "CALC_char_at_3": "", "CALC_length_of_string_1": "length of", "CALC_length_of_string_2": "", + "CALC_reverse_of_string_1": "Reverse", + "CALC_reverse_of_string_2": "", "CALC_substring_1": "substring of", "CALC_substring_2": "from", "CALC_substring_3": "to", @@ -736,6 +738,8 @@ Lang.Blocks = { "CALC_change_string_case_3": " ", "CALC_change_string_case_sub_1": "uppercase", "CALC_change_string_case_sub_2": "lowercase", + "CALC_count_match_string_1": "'s count of", + "CALC_count_match_string_2": "", "CALC_index_of_string_1": "index of", "CALC_index_of_string_2": "in", "CALC_index_of_string_3": "", @@ -780,6 +784,7 @@ Lang.Blocks = { "entry_bot_name": "Entrybot", "hi_entry": "Hello Entry!", "hi_entry_en": "Hello Entry!", + "hello_entry": "hello entry", "bark_dog": "dog barking", "walking_entryBot": "Walking Entrybot", "doggi_bark": "Doggi's Bark", @@ -1109,6 +1114,10 @@ Lang.Blocks = { "arduino_lite_connect": "Web Connection", "arduino_lite_disconnect": "Cancel", "arduino_lite_guide": "• connection guide", + "JUDGEMENT_is_object_clicked": "Object clicked?", + "JUDGEMENT_is_type_1": "is", + "JUDGEMENT_is_type_2": "", + "is_type_number": "number", }; Lang.video_body_coord_params = { "left_eye": "Left Eye", @@ -4582,8 +4591,10 @@ Lang.Helper = { "sound_volume_set": "Sets the volume of all the sounds played as much as the input percentage.", "sound_silent_all": "Stops all sounds currently playing.", "is_clicked": "Checks whether mouse is clicked.", + "is_object_clicked": "Checks whether object is clicked.", "is_press_some_key": "Checks whether an selected key is pressed.", "reach_something": "Checks whether the object reaches the selected point.", + "is_type": "Checks whether the input text is a number. If the input text is a number, it is judged as ’True’.", "is_included_in_list": "Checks whether selected list contains the input value.", "boolean_basic_operator": "Checks whether the value on the left is the same as the value on the right.", "function_create": "Define a function by placing frequently used sets of blocks under this block. Place [name] next to [Define function] to give function a name. Pass on number of text values by placing [numeric/text value] block. Pass on boolean value of true or false by placing the [boolean value] block.", @@ -4606,7 +4617,7 @@ Lang.Helper = { "calc_share": "Reports the quotient occurring from first number divided by the second number. ", "calc_mod": "Reports the remainder occurring from the first number divided by the second number.", "calc_operation": "Reports calculated values of a variety of equations relating to input numbers.", - "get_date": "Reports the values regarding the current year, month, day and time.", + "get_date": "Reports the values regarding the current year, month, day, day of the week and time.", "distance_something": "Reports the distance between the object and the selected object.", "get_sound_duration": "Reports the time length of the selected sound.", "get_user_name": "Reports the username who runs the project.", @@ -4619,6 +4630,7 @@ Lang.Helper = { "get_canvas_input_value": "Reports the answer which is taken after the object asked.", "set_visible_answer": "Hide or show the response window.", "combine_something": "Combines two input texts.", + "reverse_of_string": "Reports the text that reversed input text.", "get_variable": "Reports the value of the selected variable.", "change_variable": "Adds the input value to the selected variable.", "set_variable": "Sets the value of the selected variable to the input value.", @@ -4662,6 +4674,7 @@ Lang.Helper = { "char_at": "Reports the letter of the input text.", "length_of_string": "Reports the length of input text including space.", "substring": "Reports the text extracted from the input text between two specified indices. (includes space)", + "count_match_string": "Reports the number of letters in a specific text in the input text.", "replace_string": "Reports the text that replaced all the input text with another input text. (distinguishes uppercase to lowercase)", "index_of_string": "Reports the index of first input text in second input text. (includes space)", "change_string_case": "Reports the text that converted to uppercase or lowercase.", @@ -5241,9 +5254,11 @@ Lang.template = { "get_project_timer_value": "%1 %2", "char_at": "%1 %2 %3 %4 %5", "length_of_string": "%1 %2 %3", + "reverse_of_string": "%1 %2 %3", "substring": "%1 %2 %3 %4 %5 %6 %7", "replace_string": "%1 %2 %3 %4 %5 %6 %7", "change_string_case": "%1 %2 %3 %4 %5", + "count_match_string": "%3 %2 %1 %4", "index_of_string": "%1 %2 %3 %4 %5", "combine_something": "%1 %2 %3 %4 %5", "get_sound_volume": "%1 %2", @@ -5458,8 +5473,10 @@ Lang.template = { "turtle_turn_unit_with_radius_in_direction": "turn %1 %2 %3 with radius %4 cm in %5 direction %6", "turtle_value": "%1", "is_clicked": "%1", + "is_object_clicked": "%1", "is_press_some_key": "%1 %2", "reach_something": "%1 %2 %3", + "is_type": '%1 %2 %3 %4', "boolean_comparison": "%1 %2 %3", "boolean_equal": "%1 %2 %3", "boolean_bigger": "%1 %2 %3", diff --git a/extern/lang/ko.js b/extern/lang/ko.js index 971ebb4699..ce6d9c2d17 100644 --- a/extern/lang/ko.js +++ b/extern/lang/ko.js @@ -756,6 +756,7 @@ Lang.Blocks = { CALC_get_date_day: '일', CALC_get_date_hour: '시각(시)', CALC_get_date_minute: '시각(분)', + CALC_get_date_day_of_week: '요일', CALC_get_date_month: '월', CALC_get_date_second: '시각(초)', CALC_get_date_year: '연도', @@ -809,12 +810,16 @@ Lang.Blocks = { JUDGEMENT_boolean_or: '또는', JUDGEMENT_false: ' 거짓 ', JUDGEMENT_is_clicked: '마우스를 클릭했는가?', + JUDGEMENT_is_object_clicked: '오브젝트를 클릭했는가?', JUDGEMENT_is_press_some_key_1: '', JUDGEMENT_is_press_some_key_2: '키가 눌러져 있는가?', JUDGEMENT_reach_something_1: '', JUDGEMENT_reach_something_2: '에 닿았는가?', + JUDGEMENT_is_type_1: '(이)가', + JUDGEMENT_is_type_2: '인가?', JUDGEMENT_true: ' 참 ', JUDGEMENT_is_boost_mode: '부스트모드가 켜져 있는가?', + is_type_number: '숫자', LOOKS: '생김새', LOOKS_change_scale_percent_1: '크기를', LOOKS_change_scale_percent_2: '만큼 바꾸기', @@ -1539,6 +1544,8 @@ Lang.Blocks = { CALC_char_at_3: '번째 글자', CALC_length_of_string_1: '', CALC_length_of_string_2: '의 글자 수', + CALC_reverse_of_string_1: '', + CALC_reverse_of_string_2: '을(를) 뒤집기', CALC_substring_1: '', CALC_substring_2: '의', CALC_substring_3: '번째 글자부터', @@ -1553,6 +1560,8 @@ Lang.Blocks = { CALC_change_string_case_3: ' ', CALC_change_string_case_sub_1: '대문자', CALC_change_string_case_sub_2: '소문자', + CALC_count_match_string_1: '에서', + CALC_count_match_string_2: '의 글자 개수', CALC_index_of_string_1: '', CALC_index_of_string_2: '에서', CALC_index_of_string_3: '의 시작 위치', @@ -1597,6 +1606,7 @@ Lang.Blocks = { entry_bot_name: '엔트리봇', hi_entry: '안녕 엔트리!', hi_entry_en: 'Hello Entry!', + hello_entry: 'hello entry', bark_dog: '강아지 짖는 소리', walking_entryBot: '엔트리봇_걷기', doggi_bark: '강아지 짖는 소리', @@ -5907,8 +5917,10 @@ Lang.Helper = { sound_volume_set: '작품에서 재생되는 모든 소리의 크기를 입력한 값으로 정합니다.', sound_silent_all: '재생 중인 모든 소리를 멈춥니다.', is_clicked: '마우스를 클릭한 경우 ‘참’으로 판단합니다.', + is_object_clicked: '오브젝트를 클릭한 경우 ‘참’으로 판단합니다.', is_press_some_key: '선택한 키가 눌려져 있는 경우 ‘참’으로 판단합니다.', reach_something: '해당 오브젝트가 선택한 항목과 닿은 경우 ‘참’으로 판단합니다.', + is_type: '입력한 값이 숫자라면 ‘참’으로 판단합니다.', is_included_in_list: "선택한 리스트가 입력한 값을 가진 항목을 포함하는 경우 '참'으로 판단합니다.", boolean_basic_operator: @@ -5941,7 +5953,7 @@ Lang.Helper = { calc_mod: '앞 수에서 뒤 수를 나누어 생긴 나머지를 의미합니다.', calc_operation: '입력한 수에 대한 다양한 수학식의 계산값입니다. (제곱, 루트, 사인값, 코사인값, 탄젠트값, 아크사인값, 아크코사인값, 아크탄젠트값, 로그값, 자연로그값, 소수점 부분, 소수점 버림값, 소수점 올림값, 소수점 반올림값, 펙토리얼값, 절대값)', - get_date: '현재 연도, 월, 일, 시각과 같이 시간에 대한 값입니다.', + get_date: '현재 연도, 월, 일, 요일, 시각과 같이 시간에 대한 값입니다.', distance_something: '해당 오브젝트와 선택한 오브젝트 또는 마우스 포인터 간의 거릿값입니다.', get_sound_duration: '선택한 소리의 길이(초) 값입니다.', get_user_name: '작품을 실행하고 있는 사용자의 아이디 값입니다.', @@ -5956,6 +5968,7 @@ Lang.Helper = { get_canvas_input_value: "사용자가 '대답 창'에 입력한 값입니다.", set_visible_answer: "대답 창'을 실행화면에서 숨기거나 보이게 합니다.", combine_something: '입력한 두 값을 결합한 값입니다.', + reverse_of_string: '입력한 값을 뒤집은 값입니다.', get_variable: '선택한 변수에 저장된 값입니다.', change_variable: '선택한 변수에 입력한 값을 더합니다.', set_variable: '선택한 변수의 값을 입력한 값으로 정합니다.', @@ -6017,6 +6030,7 @@ Lang.Helper = { char_at: '입력한 값에서 입력한 숫자 번째의 글자 값입니다. (공백을 포함합니다.)', length_of_string: '입력한 값의 공백을 포함한 글자 수입니다.', substring: '입력한 값에서 입력한 범위 내의 글자 값입니다. (공백을 포함합니다.)', + count_match_string: '입력한 값에서 지정한 값의 글자 개수입니다.', replace_string: '입력한 값에서 지정한 값을 찾아 추가로 입력한 값으로 모두 바꾼 값입니다. (영문 입력 시 대소문자를 구분합니다.)', index_of_string: @@ -6945,6 +6959,7 @@ Lang.template = { substring: '%1 %2 %3 %4 %5 %6 %7', replace_string: '%1 %2 %3 %4 %5 %6 %7', change_string_case: '%1 %2 %3 %4 %5', + count_match_string: '%1 %2 %3 %4', index_of_string: '%1 %2 %3 %4 %5', combine_something: '%1 %2 %3 %4 %5', get_sound_volume: '%1 %2', @@ -7254,8 +7269,10 @@ Lang.template = { turtle_turn_unit_with_radius_in_direction: '%1 으로 %2 %3 반지름 %4 cm를 %5 방향으로 돌기 %6', turtle_value: '%1', is_clicked: '%1', + is_object_clicked: '%1', is_press_some_key: '%1 %2', reach_something: '%1 %2 %3', + is_type: '%1 %2 %3 %4', boolean_comparison: '%1 %2 %3', boolean_equal: '%1 %2 %3', boolean_bigger: '%1 %2 %3', diff --git a/extern/util/static.js b/extern/util/static.js index 9f77604bb6..7d053b0d3d 100644 --- a/extern/util/static.js +++ b/extern/util/static.js @@ -318,8 +318,10 @@ EntryStatic.getAllBlocks = function() { category: 'judgement', blocks: [ 'is_clicked', + 'is_object_clicked', 'is_press_some_key', 'reach_something', + 'is_type', 'boolean_basic_operator', 'boolean_and_or', 'boolean_not', @@ -348,8 +350,10 @@ EntryStatic.getAllBlocks = function() { 'combine_something', 'char_at', 'substring', + 'count_match_string', 'index_of_string', 'replace_string', + 'reverse_of_string', 'change_string_case', 'get_block_count', ], diff --git a/src/class/engine.js b/src/class/engine.js index 833118753e..49b482c849 100644 --- a/src/class/engine.js +++ b/src/class/engine.js @@ -22,12 +22,15 @@ Entry.Engine = class Engine { _addEventListener('canvasClick', () => this.fireEvent('mouse_clicked')); _addEventListener('canvasClickCanceled', () => this.fireEvent('mouse_click_cancled')); - _addEventListener('entityClick', (entity) => - this.fireEventOnEntity('when_object_click', entity) - ); - _addEventListener('entityClickCanceled', (entity) => - this.fireEventOnEntity('when_object_click_canceled', entity) - ); + _addEventListener('entityClick', (entity) => { + const objId = entity.id; + Entry.stage.clickedObjectId = objId; + this.fireEventOnEntity('when_object_click', entity); + }); + _addEventListener('entityClickCanceled', (entity) => { + delete Entry.stage.clickedObjectId; + this.fireEventOnEntity('when_object_click_canceled', entity); + }); if (Entry.type !== 'phone' && Entry.type !== 'playground') { _addEventListener( @@ -689,7 +692,7 @@ Entry.Engine = class Engine { Entry.dispatchEvent('beforeStop'); try { await Promise.all(this.execPromises); - } catch (e) {} + } catch (e) { } const container = Entry.container; const variableContainer = Entry.variableContainer; diff --git a/src/playground/blocks/block_calc.js b/src/playground/blocks/block_calc.js index e41fab8102..ba4259edcb 100644 --- a/src/playground/blocks/block_calc.js +++ b/src/playground/blocks/block_calc.js @@ -1100,14 +1100,14 @@ module.exports = { ], events: { viewAdd: [ - function() { + function () { if (Entry.engine) { Entry.engine.showProjectTimer(); } }, ], viewDestroy: [ - function(block, notIncludeSelf) { + function (block, notIncludeSelf) { if (Entry.engine) { Entry.engine.hideProjectTimer(block, notIncludeSelf); } @@ -1176,7 +1176,7 @@ module.exports = { }, ], dataDestroy: [ - function(block) { + function (block) { if (Entry.engine) { Entry.engine.hideProjectTimer(block); } @@ -1307,14 +1307,14 @@ module.exports = { ], events: { viewAdd: [ - function() { + function () { if (Entry.engine) { Entry.engine.showProjectTimer(); } }, ], viewDestroy: [ - function(block, notIncludeSelf) { + function (block, notIncludeSelf) { if (Entry.engine) { Entry.engine.hideProjectTimer(block, notIncludeSelf); } @@ -1399,6 +1399,7 @@ module.exports = { [Lang.Blocks.CALC_get_date_hour, 'HOUR'], [Lang.Blocks.CALC_get_date_minute, 'MINUTE'], [Lang.Blocks.CALC_get_date_second, 'SECOND'], + [Lang.Blocks.CALC_get_date_day_of_week, 'DAY_OF_WEEK'], ], value: 'YEAR', fontSize: 10, @@ -1438,6 +1439,10 @@ module.exports = { return dateTime.getHours(); } else if (operator === 'MINUTE') { return dateTime.getMinutes(); + } else if (operator === 'DAY_OF_WEEK') { + const daysLang = ['일', '월', '화', '수', '목', '금', '토']; + const dayNum = dateTime.getDay(); + return daysLang[dayNum]; } else { return dateTime.getSeconds(); } @@ -1459,6 +1464,7 @@ module.exports = { [Lang.Blocks.CALC_get_date_hour, 'HOUR'], [Lang.Blocks.CALC_get_date_minute, 'MINUTE'], [Lang.Blocks.CALC_get_date_second, 'SECOND'], + [Lang.Blocks.CALC_get_date_day_of_week, 'DAY_OF_WEEK'], ], value: 'YEAR', fontSize: 11, @@ -1516,13 +1522,13 @@ module.exports = { const mousePos = Entry.stage.mouseCoordinate; return Math.sqrt( Math.pow(sprite.getX() - mousePos.x, 2) + - Math.pow(sprite.getY() - mousePos.y, 2) + Math.pow(sprite.getY() - mousePos.y, 2) ); } else { const targetEntity = Entry.container.getEntity(targetId); return Math.sqrt( Math.pow(sprite.getX() - targetEntity.getX(), 2) + - Math.pow(sprite.getY() - targetEntity.getY(), 2) + Math.pow(sprite.getY() - targetEntity.getY(), 2) ); } }, @@ -1735,6 +1741,54 @@ module.exports = { ], }, }, + reverse_of_string: { + color: EntryStatic.colorSet.block.default.CALC, + outerLine: EntryStatic.colorSet.block.darken.CALC, + skeleton: 'basic_string_field', + statements: [], + params: [ + { + type: 'Text', + text: Lang.Blocks.CALC_reverse_of_string_1, + color: '#FFF', + }, + { + type: 'Block', + accept: 'string', + }, + { + type: 'Text', + text: Lang.Blocks.CALC_reverse_of_string_2, + color: '#FFF', + }, + ], + events: {}, + def: { + params: [ + null, + { + type: 'text', + params: [Lang.Blocks.entry], + }, + null, + ], + type: 'reverse_of_string', + }, + paramsKeyMap: { + STRING: 1, + }, + class: 'calc_string', + isNotFor: [], + func(sprite, script) { + const originStr = script.getStringValue('STRING', script); + const reversedStr = originStr.split('').reverse().join(''); + return reversedStr; + }, + syntax: { + js: [], + py: [], + }, + }, combine_something: { color: EntryStatic.colorSet.block.default.CALC, outerLine: EntryStatic.colorSet.block.darken.CALC, @@ -2070,6 +2124,70 @@ module.exports = { ], }, }, + count_match_string: { + color: EntryStatic.colorSet.block.default.CALC, + outerLine: EntryStatic.colorSet.block.darken.CALC, + skeleton: 'basic_string_field', + statements: [], + params: [ + { + type: 'Block', + accept: 'string', + }, + { + type: 'Text', + text: Lang.Blocks.CALC_count_match_string_1, + color: '#FFF', + }, + { + type: 'Block', + accept: 'string', + }, + { + type: 'Text', + text: Lang.Blocks.CALC_count_match_string_2, + color: '#FFF', + }, + ], + events: {}, + def: { + params: [ + { + type: 'text', + params: [Lang.Blocks.hello_entry], + }, + null, + { + type: 'text', + params: ['e'], + }, + null, + ], + type: 'count_match_string', + }, + paramsKeyMap: { + STRING: 0, + TARGET: 2, + }, + class: 'calc_string', + isNotFor: [], + func(sprite, script) { + const originStr = script.getStringValue('STRING', script); + const targetStr = script.getStringValue('TARGET', script); + + if (originStr.length > 0 && targetStr.length > 0) { + const result = originStr.match(new RegExp(targetStr, 'g')); + if (result) { + return result.length; + } + } + return 0; + }, + syntax: { + js: [], + py: [], + }, + }, index_of_string: { color: EntryStatic.colorSet.block.default.CALC, outerLine: EntryStatic.colorSet.block.darken.CALC, @@ -2339,7 +2457,7 @@ module.exports = { func(sprite, script) { return script .getStringValue('STRING', script) - [script.getField('CASE', script)](); + [script.getField('CASE', script)](); }, syntax: { js: [], diff --git a/src/playground/blocks/block_judgement.js b/src/playground/blocks/block_judgement.js index 52752f04eb..dc79007b9e 100644 --- a/src/playground/blocks/block_judgement.js +++ b/src/playground/blocks/block_judgement.js @@ -36,6 +36,34 @@ module.exports = { ], }, }, + is_object_clicked: { + color: EntryStatic.colorSet.block.default.JUDGE, + outerLine: EntryStatic.colorSet.block.darken.JUDGE, + skeleton: 'basic_boolean_field', + statements: [], + params: [ + { + type: 'Text', + text: Lang.Blocks.JUDGEMENT_is_object_clicked, + color: '#FFF', + }, + ], + events: {}, + def: { + params: [null], + type: 'is_object_clicked', + }, + class: 'boolean_input', + isNotFor: [], + func(sprite, script) { + const objId = sprite.id; + if (Entry.stage.clickedObjectId == objId) { + return true; + } + return false; + }, + syntax: { js: [], py: [] }, + }, is_press_some_key: { color: EntryStatic.colorSet.block.default.JUDGE, outerLine: EntryStatic.colorSet.block.darken.JUDGE, @@ -229,6 +257,64 @@ module.exports = { ], }, }, + is_type: { + color: EntryStatic.colorSet.block.default.JUDGE, + outerLine: EntryStatic.colorSet.block.darken.JUDGE, + skeleton: 'basic_boolean_field', + statements: [], + params: [ + { + type: 'Block', + accept: 'string', + }, + { + type: 'Text', + text: Lang.Blocks.JUDGEMENT_is_type_1, + color: '#FFF', + }, + { + type: 'Dropdown', + options: [ + [Lang.Blocks.is_type_number, 'number'], + ], + value: 'number', + fontSize: 10, + bgColor: EntryStatic.colorSet.block.darken.JUDGE, + }, + { + type: 'Text', + text: Lang.Blocks.JUDGEMENT_is_type_2, + color: '#FFF', + }, + ], + events: {}, + def: { + params: ['10', null, 'number', null], + type: 'is_type', + }, + paramsKeyMap: { + VALUE: 0, + TYPE: 2, + }, + class: 'boolean_type', + isNotFor: [], + func(sprite, script) { + const value = script.getStringValue('VALUE', script); + const type = script.getField('TYPE', script); + + if (type === 'number') { + const numCheckRegex = /^-?\d+$/; + if (numCheckRegex.test(value)) { + return true; + } + } + return false; + }, + syntax: { + js: [], + py: [], + }, + }, boolean_basic_operator: { color: EntryStatic.colorSet.block.default.JUDGE, outerLine: EntryStatic.colorSet.block.darken.JUDGE,