Sb forum speech.png DiscordLink.png FacebookLink.png RedditLink.png SteamLink.png TwitterLink.png YoutubeLink.png

Difference between revisions of "YOLOL:jp"

From Starbase wiki
Jump to navigation Jump to search
(Translated into Japanese.)
 
m (Translated into Japanese.)
Line 81: Line 81:
==== 小数点以下 ====
==== 小数点以下 ====


プログラミング言語における数値は、64 ビット固定小数点の 10 進数である。
プログラミング言語における数値は、64ビット固定小数点の10進数です。
変数は10進数を小数点3桁の精度で保持します。
変数は小数点第3位までの数値が格納されます。
そのため、最大値の範囲(演算中も含む)は[-9223372036854775.808, 9223372036854775.807]となります。
そのため、最大値の範囲(演算中も含む)は -9223372036854775.808~9223372036854775.807 となります。
 
Numeric values in the programming language are 64-bit fixed-point decimals.<br>
The variables hold decimal numbers up to three decimal accuracy.<br>
As a result, the maximum value range (even during operations) is [-9223372036854775.808, 9223372036854775.807]


  pieVariable= 3.142
  pieVariable= 3.142
* The above script assigns a numeric value of 3.142 to the variable '''pieVariable'''.
* 上記のスクリプトでは、変数 '''pieVariable''' に 3.142 という数値が割り当てられています。
** Supplying more precise values than the variables can store works, but doesn't affect the end result.
** 変数が格納できる値よりも正確な値を与えても動作しますが、最終的な結果には影響しません。


  notPieVariable= 0.5772156649
  notPieVariable= 0.5772156649
* The above script attempts to assign a numeric value of 0.5772156649 to the variable '''notPieVariable'''.
* 上記のスクリプトは、変数 '''notPieVariable''' に 0.5772156649 という数値を割り当てようとしています。
* The end result however is notPieVariable == 0.577
* 最終的な結果は notPieVariable == 0.577 です。
** Here, the more precise values are cut, leaving only three decimals behind.
** ここでは、より正確な値にカットされ、少数第3位までが残されます。


==== Strings ====
==== 文字列 ====


To specify a string literal in the programming language, the desired string value must be surrounded with double quotation marks.
プログラミング言語で文字列変数を指定するには、希望する文字列の値をダブルクォーテーションで囲む必要があります。


  badRobots= "saltberia"  
  badRobots= "saltberia"  
* This script assigns the string value of "''saltberia''" to the variable '''badRobots'''.
* このスクリプトは、"'''saltberia'''" という文字列値を変数 '''badRobots''' に割り当てます。


==== Device fields / External variables ====
==== デバイスフィールド / 外部変数 ====


External variables and device fields can be used in the programming language with the following syntax:<br>
外部変数とデバイス・フィールドは、プログラミング言語で次のような構文で使用できます:<br>
* ''':variableName'''
* ''':variableName'''
**'''variableName''' being the configured device field id.
** '''variableName'''には設定されたデバイスフィールドIDを指定します。
A colon prefix  ''':''' is used to tell the script that an external variable is being accessed, instead of using one that may or may not be declared or used in the script.<br>
コロンのプレフィックス ''':'''は、スクリプト内で宣言または使用されていない外部変数を使用する代わりに、外部変数にアクセスしていることをスクリプトに伝えるために使用されます。<br>
A programmable [[YOLOL Chip|chip]] that is connected to a [[Devices and machines|device]] has access to all the devices in the same [[Data networks|network]].<br>
プログラム可能な[[YOLOL Chip|チップ]][[Devices and machines|デバイス]]に接続すると、同じ[[Data networks|ネットワーク]]内のすべてのデバイスにアクセスできます。<br>
It can then modify and listen to any device fields it has access to.<br>
そして、アクセスできるすべてのデバイスフィールドを変更したり、聞いたりすることができます。<br>


  if ''':ButtonState''' == 1 then ''':DoorState''' = 1 end
  if ''':ButtonState''' == 1 then ''':DoorState''' = 1 end
* The script above will send the value of 1 to any devices listening to the device field '''DoorState''' if the value of '''ButtonState''' is 1 in the data network.
* 上記のスクリプトは、データネットワーク上で'''ButtonState'''の値が1の場合、デバイスフィールド'''DoorState'''をリッスンしているすべてのデバイスに1の値を送信します。


==== Naming Limitations ====
==== 命名の制限 ====
Currently variables containing keywords such as '''if''' or '''end''' can be parsed incorrectly, and must be avoided.
現在、変数に '''if''' '''end''' などのキーワードが含まれていると、正しく解析されないことがありますので、避けてください。


== Operators and commands ==
== 演算子とコマンド ==


Note that the available operators may be limited by the type of the programmable [[YOLOL Chip|chip]].<br>
プログラム可能な[[YOLOL Chip|チップ]]の種類によって、使用できる演算子が制限されることがあります。<br>
Basic chips have a limited selection of functions while more advanced ones can perform more complex operations natively.
基本的なチップは限られた機能しかありませんが、高度なチップではより複雑な演算をネイティブに行うことができます。


=== Basic arithmetic and assignment operators ===
=== 基本的な算術演算子と代入演算子について ===
=== Basic arithmetic and assignment ===
=== 基本的な算術演算と代入演算 ===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Operation || Numeric operation || String operation || Chip availability
! 演算|| 数値演算 || 文字列演算 || チップの種類
|-
|-
| A + B || Addition || String A is appended by String B. || All
| A + B || 加算|| 文字列Aに文字列Bを足す。 || すべて
|-
|-
| A - B || Subtraction || The last appearance of String B in String A is removed from String A. || All
| A - B || 減算 || 文字列 A の中で文字列 B の最後の出現部分が文字列 A から削除されます。 || すべて
|-
|-
| A * B || Multiplication || Runtime error. The rest of the line is skipped. || All
| A * B || 乗算 || ランタイムエラー。この行の残りの部分はスキップされます。 || すべて
|-
|-
| A / B || Division || Runtime error. The rest of the line is skipped. || All
| A / B || 除算 || ランタイムエラー。この行の残りの部分はスキップされます。 || すべて
|-
|-
| A ++ || PostIncrement (A=A+1) || Appends a space to String A. Evaluates to the original value. || All
| A ++ || ポストインクリメント (A=A+1) || 文字列 A にスペースを追加します。 || すべて
|-
|-
| A -- || PostDecrement (A=A-1) || Removes the last character of the string. Results in runtime error when trying to remove "". Evaluates to the original value. || All
| A -- || ポストインクリメント (A=A-1) || 文字列の最後の文字を削除します。""(空白)を削除しようとするとランタイムエラーになります。元の値に評価されます。 || すべて
|-
|-
| ++ A  || PreIncrement (A=A+1) || Appends a space to String A. Evaluates to the modified value. || All
| ++ A  || プレインクリメント (A=A+1) || 文字列 A にスペースを追加します。 || すべて
|-
|-
| -- A || PreDecrement (A=A-1) || Removes the last character of the string. Results in runtime error when trying to remove "". Evaluates to the modified value. || All
| -- A || プレインクリメント (A=A-1) || 文字列の最後の文字を削除します。""(空白)を削除しようとするとランタイムエラーになります。元の値に評価されます。 || すべて
|-
|-
| A = B || Assignment (Variable A is set to the value of variable B) || Assignment || All
| A = B || 代入 (変数 A に変数 B の値を設定) || 代入 || すべて
|-
|-
| A += B || Addition-assignment (A=A+B) || A is assigned the value of string-operation A+B || All
| A += B || 加算の代入 (A=A+B) || 文字列操作 A+B の値を代入する。 || すべて
|-
|-
| A -= B || Subtraction-assignment (A=A-B) || A is assigned the value of string-operation A-B || All
| A -= B || 減算の代入(A=A-B) || 文字列操作 A-B の値を代入する。 || すべて
|-
|-
| A *= B || Multiplication-assignment (A=A*B) || Runtime error. The rest of the line is skipped. || All
| A *= B || 乗算の代入 (A=A*B) || ランタイムエラー。この行の残りの部分はスキップされます。 || すべて
|-
|-
| A /= B || Division-assignment (A=A/B) || Runtime error. The rest of the line is skipped. || All
| A /= B || 除算の代入 (A=A/B) || ランタイムエラー。この行の残りの部分はスキップされます。 || すべて
|-
|-
| A ^= B || Exponentiation-assignment (A=A^B) || Runtime error. The rest of the line is skipped. || Advanced, Professional
| A ^= B || Exponentiation-assignment (A=A^B) || ランタイムエラー。この行の残りの部分はスキップされます。 || アドバンス, プロフェッショナル
|-
|-
| A %= B || Modulo-assignment (A=A%B) || Runtime error. The rest of the line is skipped. || Advanced, Professional
| A %= B || Modulo-assignment (A=A%B) || ランタイムエラー。この行の残りの部分はスキップされます。 || アドバンス, プロフェッショナル
|-
|-
| A ^ B || Exponentiation || Runtime error. The rest of the line is skipped. || Advanced, Professional
| A ^ B || Exponentiation || ランタイムエラー。この行の残りの部分はスキップされます。 || アドバンス, プロフェッショナル
|-
|-
| A % B || Modulo || Runtime error. The rest of the line is skipped. || Advanced, Professional
| A % B || 余り || ランタイムエラー。この行の残りの部分はスキップされます。 || アドバンス, プロフェッショナル
|-
|-
| ABS A || Modulus (absol value) (A=A if A>=0, else A=-A) || Runtime error. The rest of the line is skipped. || Advanced, Professional
| ABS A || 対数係数(絶対値) (A=A if A>=0, else A=-A)と同じ処理となる。 || ランタイムエラー。この行の残りの部分はスキップされます。|| アドバンス, プロフェッショナル
|-
|-
| A! || Factorial || Runtime error. The rest of the line is skipped. || Advanced, Professional
| A! || 階乗 || ランタイムエラー。この行の残りの部分はスキップされます。 || アドバンス, プロフェッショナル
|-
|-
| SQRT A || Square root of A || Runtime error. The rest of the line is skipped. || Advanced, Professional
| SQRT A || Aの平方根 || ランタイムエラー。この行の残りの部分はスキップされます。 || アドバンス, プロフェッショナル
|-
|-
| SIN A || Sine of A (degrees) || Runtime error. The rest of the line is skipped. || Professional
| SIN A || AのSIN(度) || ランタイムエラー。この行の残りの部分はスキップされます。. || プロフェッショナル
|-
|-
| COS A || Cosine of A (degrees) || Runtime error. The rest of the line is skipped. || Professional
| COS A || AのCOS(度) || ランタイムエラー。この行の残りの部分はスキップされます。 || プロフェッショナル
|-
|-
| TAN A || Tangent of A (degrees) || Runtime error. The rest of the line is skipped. || Professional
| TAN A || AのTAN(度) || ランタイムエラー。この行の残りの部分はスキップされます。 || プロフェッショナル
|-
|-
| ASIN A || Inverse sine of A (degrees) || Runtime error. The rest of the line is skipped. || Professional
| ASIN A || AのASIN(度) || ランタイムエラー。この行の残りの部分はスキップされます。 || プロフェッショナル
|-
|-
| ACOS A || Inverse cosine of A (degrees) || Runtime error. The rest of the line is skipped. || Professional
| ACOS A || AのACOS(度) || ランタイムエラー。この行の残りの部分はスキップされます。 || プロフェッショナル
|-
|-
| ATAN A || Inverse tangent of A (degrees) || Runtime error. The rest of the line is skipped. || Professional
| ATAN A || AのATAN(度) || ランタイムエラー。この行の残りの部分はスキップされます。 || プロフェッショナル
|}
|}


=== Logical operators ===
=== 論理演算子 ===


Logical operators are checks that identify if the statement is true or false.<br>
論理演算子は、命令が真か偽かを識別するチェックです。<br>
All logical operations return either '''"0 for False"''' or '''"1 for True"'''.
すべての論理演算は、'''0の偽'''または'''1の真'''のいずれかを返します。<br>
The '''NOT''', '''AND''', and '''OR''' keywords consider 0 to be falsy and anything not 0 to be truthy.
また、'''NOT''''''AND''''''OR'''キーワードは、0を偽とし、0以外を真とします。


{| class="wikitable"
{| class="wikitable"
|-
|-
! Operation || Numeric operation || String operation || Chip availability
! 演算||数値演算||文字列演算||チップの種類
|-
|-
| A < B || Less than || returns 1 if String A is first in alphabetical order, returns 0 if not. || All
| A < B || AはBより小さい || 文字列Aがアルファベット順で1番目の場合は1を、そうでない場合は0を返します。 || すべて
|-
|-
| A > B || Greater than || returns 0 if String A is first in alphabetical order, returns 1 if not. || All
| A > B || AはBより大きい || 文字列Aがアルファベット順で1番目の場合は0を、そうでない場合は1を返します。 || すべて
|-
|-
| A <= B ||Less than or equal to || returns 1 if String A is first in alphabetical order or identical to String B, returns 0 if not. || All
| A <= B || AはB以下 || 文字列Aがアルファベット順で1番目の場合か、文字列Bと同じであれば1を、そうでない場合は0を返します。 || すべて
|-
|-
| A >= B || Greater than or equal to || returns 0 if String A is first in alphabetical order or identical to String B, returns 1 if not. || All
| A >= B || AはB以上 || 文字列Aがアルファベット順で1番目の場合か、文字列Bと同じであれば0を、そうでない場合は1を返します。 || すべて
|-
|-
| A != B || Not equal to || returns 1 if String A is not equal to String B, 0 if it is. || All
| A != B || AはBと異なる || 文字列Aが文字列Bと等しくない場合は1を、等しい場合は0を返します。 || すべて
|-
|-
| A == B || Equal to || returns 1 if String A is equal to String B, 0 if not. || All
| A == B || AはBと同じ || 文字列Aが文字列Bと等しい場合は1を、等しくない場合は0を返します。 || すべて
|-
|-
| NOT A || Not || Returns 1 if A is 0, otherwise returns 0. || All
| NOT A || 真偽反転 || A 0 であれば 1 を、そうでなければ 0 を返します。 || すべて
|-
|-
| A AND B || And || Returns 1 if neither A nor B are 0, otherwise returns 0. || All
| A AND B || AとBの両方 || A B 0 でなければ 1 を、そうでなければ 0 を返します。 || すべて
|-
|-
| A OR B || Or || Returns 1 if either A or B is not 0, otherwise returns 0. || All
| A OR B || AまたはBのどちらか || A または B のどちらかが 0 でない場合は 1 を、そうでない場合は 0 を返します。 || すべて
|}
|}


=== Mixing variable types in operations ===
=== 演算における変数型の混在 ===


演算の中で変数の型を混ぜると、すべてのパラメータを''文字列''として演算を行います。
Mixing variable types in an operation handles the operation using all parameters as ''strings''.
Mixing variable types in an operation handles the operation using all parameters as ''strings''.


  previouslyNumber= "10" + 15
  previouslyNumber= "10" + 15
* The above script results in '''previouslyNumber''' containing the string value "1015".
* 上記スクリプトの結果、'''precedlyNumber''' には文字列値 "1015" が格納されます。
** Note that the involved parameters themselves don't change types, their values are just cast as strings for the purpose of the operation:
** 関係するパラメータ自体の型は変更されず、その値は操作の目的のために文字列として変換されるだけであることに注意してください。
 
  purelyNumber = 15
  purelyNumber = 15
  purelyString = "10" + purelyNumber
  purelyString = "10" + purelyNumber
* When this script has executed, '''purelyString''' contains the string value of "1015", while '''purelyNumber''' still contains the numeric value of 15.
* このスクリプトが実行されたとき、'''purelyString''' には文字列値の "1015" が、'''purelyNumber''' には数値値の "15" が入っています。
 


=== Goto ===
=== Goto文 ===


Goto syntax is used when the normal script reading order from 1->20 is not desired, or needs to be altered.
Goto文は、通常のスクリプトの1->20の読み順が望ましくない場合や、変更する必要がある場合に使用します。


Goto is used with the following syntax:
Gotoは次のような構文で使用します:
*'''goto lineNumber'''
* '''goto lineNumber'''です。
** lineNumber is the line which this command will take the script execution.<br>
** lineNumber は、このコマンドがスクリプトの実行を開始する行です。
** Any remaining script that is on the same line after the goto-command will not be executed.
** goto コマンドの後に同じ行にある残りのスクリプトは実行されません。
*** using if statements before goto ignores goto syntax, assuming the if-statement is false
*** goto の前に if 文を使用すると、if 文が false であると仮定して、goto の構文を無視します。
** Multiple goto commands can be added on the same line using conditionals, as '''False''' goto commands are skipped.
** 条件式を使って同じ行に複数のgotoコマンドを追加することができますが、'''False'''のgotoコマンドはスキップされます。
** Numeric values outside the [1,20] range are clamped to this range.
** [1,20] の範囲外の数値は、この範囲にクランプされます。
** Non-integer values are floored.
** 非整数の値は整数として扱われます。
** String values will result in a Runtime Error.
** 文字列値はランタイムエラーになります。


  if variable == 5 then '''goto 4''' end '''goto 6'''
  if variable == 5 then '''goto 4''' end '''goto 6'''


The script above will go to line number 4, if '''variable''' has a value of 5.<br>
上のスクリプトは、もし'''variable'''の値が5であれば、4行目に進みます。<br>
Otherwise it will go to line number 6. Numerical operations can also be done "inside" the goto, e.g.
それ以外の場合は、6行目に進みます。数値演算はgoto文の中でも行うことができます。(例)


   goto 4+1
   goto 4+1


=== If-else conditional ===
=== If-else文 ===
If-else文は、スクリプトを異なる経路に分岐させるために使用します。<br>
以下のような構文になります:
* '''if ''条件式'' then ''命令'' else ''命令'' end'''
** 条件式は結果が数値になる必要があり(0はFalse、それ以外はTrueとして解析されます)で、命令は実行されるスクリプトの一部です。
** すべての If-else文は、文が完了した後に '''end''' 命令を記述しなければなりません。
<br>
If は、スクリプトの実行を変数の値に基づいて2つの結果に分岐させるために使用できます。<br>
'''例:'''<br>
<font color="orangered">'''if'''</font> variable != 2 <font color="orangered">'''then'''</font> endResult = 3 <font color="orangered">'''else'''</font> endResult = 4 <font color="orangered">'''end'''</font>


If-else statements are used to branch out the script into different paths.<br>
* このスクリプトは、'''variable'''が2の値の場合、'''endResult''' の値を3に設定します。
They use the following syntax:
* '''if ''condition'' then ''statement'' else ''statement'' end'''
** Condition is a statement that results in a numeric value (where 0 is parsed as False, anything else as True), and statements are pieces of script that are run.
** All If-else conditional stations must have '''end''' syntax written after statement is complete.


If can be used to branch script execution into two possible outcomes temporarily based on variable value(s).<br>
* '''variable'''の値が2の場合、'''endResult'''の値は4に設定されます。
'''Example:'''<br>
<font color="orangered">'''if'''</font> variable != 2 <font color="orangered">'''then'''</font> endResult = 3 <font color="orangered">'''else'''</font> endResult = 4 <font color="orangered">'''end'''</font>


* This script sets the value of '''endResult''' to 3 if '''variable''' does not have the value of 2.
なお、else 文の部分は、必要なければ省略することができます。<br>
* If '''variable''''s value is 2, '''endResult''' is set to the value of 4.
''':'''<br>
 
Note that the else statement -part can be left out if not needed.<br>
'''Example:'''<br>
  <font color="orangered">'''if'''</font> variable != 2 <font color="orangered">'''then'''</font> endResult = 3 <font color="orangered">'''end'''</font>
  <font color="orangered">'''if'''</font> variable != 2 <font color="orangered">'''then'''</font> endResult = 3 <font color="orangered">'''end'''</font>
*This script only sets the value of 3 to '''endResult''' if '''variable''' does not have a value of 2, and doesn't do anything else.
*このスクリプトは、'''variable'''の値が2でない場合に、'''endResult''' に3の値を設定するだけで、他には何もしていません。


==== Nesting if statements ====
==== if文の入れ子 ====


It is possible to place if-conditionals inside the true/false statement blocks to achieve further branching of execution.<br>
true/false文のブロックの中にif文を入れることで、さらに実行を分岐させることができます。<br>
Example:<br>
:<br>
  <font color="orangered">'''if'''</font> variable == 0 <font color="orangered">'''then'''</font> endResult = 1 <font color="orangered">'''else'''</font> <font color="cyan">'''if'''</font> variable == 1 <font color="cyan">'''then'''</font> endResult = 2 <font color="cyan">'''end'''</font> <font color="orangered">'''end'''</font>  
  <font color="orangered">'''if'''</font> variable == 0 <font color="orangered">'''then'''</font> endResult = 1 <font color="orangered">'''else'''</font> <font color="cyan">'''if'''</font> variable == 1 <font color="cyan">'''then'''</font> endResult = 2 <font color="cyan">'''end'''</font> <font color="orangered">'''end'''</font>  
* This script sets '''endResult''' to 1 if '''variable''' equals 0.
* このスクリプトは、'''variable'''が0の場合、'''endResult''' を1に設定します。
* If '''variable''' doesn't equal 0, but it equals 1, '''endResult''' is set to 2.
* '''variable''' 0 にならず、1 になる場合、'''endResult''' 2 に設定されます。


Example:<br>
:<br>
  <font color="orangered">'''if'''</font> variable == 0 <font color="orangered">'''then'''</font> <font color="cyan">'''if'''</font> endResult == 1 <font color="cyan">'''then'''</font> endResult = 2 <font color="cyan">'''end'''</font> <font color="orangered">'''else'''</font> endResult = 1 <font color="orangered">'''end'''</font>
  <font color="orangered">'''if'''</font> variable == 0 <font color="orangered">'''then'''</font> <font color="cyan">'''if'''</font> endResult == 1 <font color="cyan">'''then'''</font> endResult = 2 <font color="cyan">'''end'''</font> <font color="orangered">'''else'''</font> endResult = 1 <font color="orangered">'''end'''</font>
* This script sets '''endResult''' to 2 if '''variable''' has a value of 0, and '''endResult''' equals to 1.
* このスクリプトは、'''vaiable'''の値が0で、'''endResult'''が1の場合、'''endResult''' を2に設定します。
* Otherwise it sets '''endResult''' to 1.
* そうでなければ '''endResult''' 1 に設定します。


Note that it may be easier to plan and debug the script flow by formatting the script containing nested if-statements to a neater indented form.<br>
なお、入れ子になったif文を含むスクリプトは、インデントされたきれいな形にフォーマットしたほうが、スクリプトの流れを計画したり、デバッグしたりしやすいかもしれません。<br>


'''Note: writing the script like this won't work on the [[YOLOL Chip|chip]], but doing this can still be useful when debugging scripts.'''
'''注意:このようにスクリプトを書いても[[YOLOL Chip|チップ]]では動作しませんが、スクリプトをデバッグする際にはこのようにすると便利です。


This is the second nested example formatted:
これは、2つ目の入れ子になった例を整形したものです:


  <font color="orangered">'''if'''</font> variable == 0 <font color="orangered">'''then'''</font>
  <font color="orangered">'''if'''</font> variable == 0 <font color="orangered">'''then'''</font>
Line 293: Line 291:
  <font color="orangered">'''end'''</font>
  <font color="orangered">'''end'''</font>


=== Comments ===
=== コメント ===


Comments are useful when writing code that is used by a lot of programmers.<br>
コメントは、多くのプログラマが使用するコードを書くときに便利です。<br>
Note that comments also use up space from the pre-determined 70 character line limit and are not excluded from it.<br>
また、コメントは1行70文字の文字数制限にカウントされることを注意してください。<br>


Commenting is used with the following syntax:
コメントは次のような構文で使用します。
*// '''text'''
*// '''text'''
** Text can be any single-line set of characters.
** テキストは一行分の任意の文字集合です。
 
'''//''' これはコメントです。他の行のスクリプトがどのように動作するかを説明します。
* コメント構文の例


'''//''' This is a comment. It will explain how other lines of script work.
== エラー ==
* An example of a possible comment syntax


== Errors ==
プログラミング言語では、2種類のエラーが発生することがあります。
# 構文エラー
# ランタイムエラー


There are two types of errors that can happen with the programming language.
* 構文エラーは、無効で解析不能なスクリプトから発生し、その行全体が実行されません。
# Syntax errors
* ランタイムエラーは、スクリプトが実行されている間のみ発生します。ランタイムエラーは、スクリプトが実行されている間にのみ発生し、その行の実行は中断されますが、エラーが発生するまでの効果は残ります。
# Runtime errors


* Syntax errors come from invalid and unparseable script and will result in the whole line not being executed.
== 既知のバグ/意図しない動作 ==
* Runtime errors are only catchable while the script is being executed. They result in the execution of the line being interrupted, but any effects until the error will remain.


== Known Bugs/Unintended Behavior ==
以下は、YOLOLに関する既知の問題のリストです:<br>
This is a list of known problems regarding yolol:<br>


* variablenames including keywords like "if" in them will parse with the keyword in mind, resulting in a syntax error. Example: :life would be parsed as :l if e
* "if" のようなキーワードを含む 変数名は、そのキーワードを考慮して解析され、シンタックスエラーになります。例: :life :l if e と解析されます。


== Related Pages ==
== 関連ページ ==
* [[YOLOL Tricks]]
* [[YOLOL Tricks]]


[[Category:Networks|YOLOL]]
[[Category:Networks|YOLOL]]

Revision as of 15:05, 3 April 2021

Deutsch Русский Українська 日本語 简体中文

概要

YOLOLは、デバイスを制御・管理するためのプログラミング言語です。
コードはYOLOLチップに書かれており、チップソケットに挿入され、チップがメッセージを読み取って中継する。
このプログラミング言語は、既知の宇宙にあるほとんどすべてのデバイスのプログラミングと制御を可能にします。

基本情報

使い方

コードはプログラマブル・チップに書き込まれて実行され、データ・ネットワークに接続されたデバイスの監視と制御の両方に使用される。
コードの行は、上から下へと順番に実行され、最後の行が実行された後、チップのサイクルを繰り返します。ただし、スクリプトに特定の行を変更したり、実行を完全に停止したりするプログラムされた命令が含まれている場合はこの限りではありません。

要点:

  1. コードの実行は1行目から
  2. 1行目を読んだ後、チップの時間間隔に基づいて次の行に進む
  3. このプロセスは、2行目、3行目、4行目...と繰り返されます。
  4. チップは、最後の行が実行された後、再び1行目の実行を開始します。(最後の行にgoto文が含まれている場合や、実行が一時停止されている場合を除く)

このように、空行でも0.2秒を使用するので、短い実行遅延として使用することができます。(コメントのみの行は実質的に空行と同じです)

制限事項

  • 行の実行には0.2秒かかります。
  • 1行に入力できる文字数は最大70文字(コメント、スペースを含む)です。
  • 一部の機能は、特定のYOLOLチップでのみ動作します。

*そのため、以下の例のようにゲーム内で動作しないことがありますのでご注意ください。

関連ページ

コマンドリファレンス

大文字小文字を区別しない

プログラミング言語は、大文字と小文字を区別しません。
つまり、次の2つのスクリプト例は、互いに同じ機能を持っています:

if ButtonState == 1 then DoorState = 1 end
IF buttonstate == 1 THEN doorstate = 1 END
  • どちらのスクリプトも、buttonstateの値が1であれば、doorstateを1に設定します。
  • プログラミング言語の文字は、小文字でも大文字でも書くことができます。
    • 大文字小文字を区別せずに解析されます。
    • このようにして、コードを少し整理することができます。

変数

  • プログラミング言語の変数は弱い型付け(型の有効性を強制しない)で、2つのデータ型をサポートしています。固定小数点の10進数(0.001までの精度)と文字列です。
    • 簡単に言うと、変数は文字列か数字のどちらかで導入することができ、前の変数の型が同一でない場合は、エラーを起こさずに前の変数の型を無視します。
  • 各変数は常に単一の型ですが、必要に応じて暗黙のうちに変換されます。
  • 初期化されていない変数のデフォルト値は0で、NULL値はサポートされていません。
  • True/Falseは、0以外の数値と0の数値です。
    • True =! 0
    • False == 0

変数に値を代入すると、その変数は常に新しく代入された値の型に変換されます。

例:

ultimateAutopilot= 128.643
  • この結果、変数 ultimateAutopilot には 128.643 という数値が格納されます。
ultimateAutopilot= "Error prone"
  • この結果、変数 ultimateAutopilot は文字列変数 "Error prone" となり、数値 128.643 が削除されます。

小数点以下

プログラミング言語における数値は、64ビット固定小数点の10進数です。 変数は小数点第3位までの数値が格納されます。 そのため、最大値の範囲(演算中も含む)は -9223372036854775.808~9223372036854775.807 となります。

pieVariable= 3.142
  • 上記のスクリプトでは、変数 pieVariable に 3.142 という数値が割り当てられています。
    • 変数が格納できる値よりも正確な値を与えても動作しますが、最終的な結果には影響しません。
notPieVariable= 0.5772156649
  • 上記のスクリプトは、変数 notPieVariable に 0.5772156649 という数値を割り当てようとしています。
  • 最終的な結果は notPieVariable == 0.577 です。
    • ここでは、より正確な値にカットされ、少数第3位までが残されます。

文字列

プログラミング言語で文字列変数を指定するには、希望する文字列の値をダブルクォーテーションで囲む必要があります。

badRobots= "saltberia" 
  • このスクリプトは、"saltberia" という文字列値を変数 badRobots に割り当てます。

デバイスフィールド / 外部変数

外部変数とデバイス・フィールドは、プログラミング言語で次のような構文で使用できます:

  • :variableName
    • variableNameには設定されたデバイスフィールドIDを指定します。

コロンのプレフィックス :は、スクリプト内で宣言または使用されていない外部変数を使用する代わりに、外部変数にアクセスしていることをスクリプトに伝えるために使用されます。
プログラム可能なチップデバイスに接続すると、同じネットワーク内のすべてのデバイスにアクセスできます。
そして、アクセスできるすべてのデバイスフィールドを変更したり、聞いたりすることができます。

if :ButtonState == 1 then :DoorState = 1 end
  • 上記のスクリプトは、データネットワーク上でButtonStateの値が1の場合、デバイスフィールドDoorStateをリッスンしているすべてのデバイスに1の値を送信します。

命名の制限

現在、変数に ifend などのキーワードが含まれていると、正しく解析されないことがありますので、避けてください。

演算子とコマンド

プログラム可能なチップの種類によって、使用できる演算子が制限されることがあります。
基本的なチップは限られた機能しかありませんが、高度なチップではより複雑な演算をネイティブに行うことができます。

基本的な算術演算子と代入演算子について

基本的な算術演算と代入演算

演算 数値演算 文字列演算 チップの種類
A + B 加算 文字列Aに文字列Bを足す。 すべて
A - B 減算 文字列 A の中で文字列 B の最後の出現部分が文字列 A から削除されます。 すべて
A * B 乗算 ランタイムエラー。この行の残りの部分はスキップされます。 すべて
A / B 除算 ランタイムエラー。この行の残りの部分はスキップされます。 すべて
A ++ ポストインクリメント (A=A+1) 文字列 A にスペースを追加します。 すべて
A -- ポストインクリメント (A=A-1) 文字列の最後の文字を削除します。""(空白)を削除しようとするとランタイムエラーになります。元の値に評価されます。 すべて
++ A プレインクリメント (A=A+1) 文字列 A にスペースを追加します。 すべて
-- A プレインクリメント (A=A-1) 文字列の最後の文字を削除します。""(空白)を削除しようとするとランタイムエラーになります。元の値に評価されます。 すべて
A = B 代入 (変数 A に変数 B の値を設定) 代入 すべて
A += B 加算の代入 (A=A+B) 文字列操作 A+B の値を代入する。 すべて
A -= B 減算の代入(A=A-B) 文字列操作 A-B の値を代入する。 すべて
A *= B 乗算の代入 (A=A*B) ランタイムエラー。この行の残りの部分はスキップされます。 すべて
A /= B 除算の代入 (A=A/B) ランタイムエラー。この行の残りの部分はスキップされます。 すべて
A ^= B Exponentiation-assignment (A=A^B) ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
A %= B Modulo-assignment (A=A%B) ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
A ^ B Exponentiation ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
A % B 余り ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
ABS A 対数係数(絶対値) (A=A if A>=0, else A=-A)と同じ処理となる。 ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
A! 階乗 ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
SQRT A Aの平方根 ランタイムエラー。この行の残りの部分はスキップされます。 アドバンス, プロフェッショナル
SIN A AのSIN(度) ランタイムエラー。この行の残りの部分はスキップされます。. プロフェッショナル
COS A AのCOS(度) ランタイムエラー。この行の残りの部分はスキップされます。 プロフェッショナル
TAN A AのTAN(度) ランタイムエラー。この行の残りの部分はスキップされます。 プロフェッショナル
ASIN A AのASIN(度) ランタイムエラー。この行の残りの部分はスキップされます。 プロフェッショナル
ACOS A AのACOS(度) ランタイムエラー。この行の残りの部分はスキップされます。 プロフェッショナル
ATAN A AのATAN(度) ランタイムエラー。この行の残りの部分はスキップされます。 プロフェッショナル

論理演算子

論理演算子は、命令が真か偽かを識別するチェックです。
すべての論理演算は、0の偽または1の真のいずれかを返します。
また、NOTANDORキーワードは、0を偽とし、0以外を真とします。

演算||数値演算||文字列演算||チップの種類
A < B AはBより小さい 文字列Aがアルファベット順で1番目の場合は1を、そうでない場合は0を返します。 すべて
A > B AはBより大きい 文字列Aがアルファベット順で1番目の場合は0を、そうでない場合は1を返します。 すべて
A <= B AはB以下 文字列Aがアルファベット順で1番目の場合か、文字列Bと同じであれば1を、そうでない場合は0を返します。 すべて
A >= B AはB以上 文字列Aがアルファベット順で1番目の場合か、文字列Bと同じであれば0を、そうでない場合は1を返します。 すべて
A != B AはBと異なる 文字列Aが文字列Bと等しくない場合は1を、等しい場合は0を返します。 すべて
A == B AはBと同じ 文字列Aが文字列Bと等しい場合は1を、等しくない場合は0を返します。 すべて
NOT A 真偽反転 A が 0 であれば 1 を、そうでなければ 0 を返します。 すべて
A AND B AとBの両方 A も B も 0 でなければ 1 を、そうでなければ 0 を返します。 すべて
A OR B AまたはBのどちらか A または B のどちらかが 0 でない場合は 1 を、そうでない場合は 0 を返します。 すべて

演算における変数型の混在

演算の中で変数の型を混ぜると、すべてのパラメータを文字列として演算を行います。 Mixing variable types in an operation handles the operation using all parameters as strings.

previouslyNumber= "10" + 15
  • 上記スクリプトの結果、precedlyNumber には文字列値 "1015" が格納されます。
    • 関係するパラメータ自体の型は変更されず、その値は操作の目的のために文字列として変換されるだけであることに注意してください。
purelyNumber = 15
purelyString = "10" + purelyNumber
  • このスクリプトが実行されたとき、purelyString には文字列値の "1015" が、purelyNumber には数値値の "15" が入っています。


Goto文

Goto文は、通常のスクリプトの1->20の読み順が望ましくない場合や、変更する必要がある場合に使用します。

Gotoは次のような構文で使用します:

  • goto lineNumberです。
    • lineNumber は、このコマンドがスクリプトの実行を開始する行です。
    • goto コマンドの後に同じ行にある残りのスクリプトは実行されません。
      • goto の前に if 文を使用すると、if 文が false であると仮定して、goto の構文を無視します。
    • 条件式を使って同じ行に複数のgotoコマンドを追加することができますが、Falseのgotoコマンドはスキップされます。
    • [1,20] の範囲外の数値は、この範囲にクランプされます。
    • 非整数の値は整数として扱われます。
    • 文字列値はランタイムエラーになります。
if variable == 5 then goto 4 end goto 6

上のスクリプトは、もしvariableの値が5であれば、4行目に進みます。
それ以外の場合は、6行目に進みます。数値演算はgoto文の中でも行うことができます。(例)

 goto 4+1

If-else文

If-else文は、スクリプトを異なる経路に分岐させるために使用します。
以下のような構文になります:

  • if 条件式 then 命令 else 命令 end
    • 条件式は結果が数値になる必要があり(0はFalse、それ以外はTrueとして解析されます)で、命令は実行されるスクリプトの一部です。
    • すべての If-else文は、文が完了した後に end 命令を記述しなければなりません。


If は、スクリプトの実行を変数の値に基づいて2つの結果に分岐させるために使用できます。
例:

if variable != 2 then endResult = 3 else endResult = 4 end
  • このスクリプトは、variableが2の値の場合、endResult の値を3に設定します。
  • variableの値が2の場合、endResultの値は4に設定されます。

なお、else 文の部分は、必要なければ省略することができます。
例:

if variable != 2 then endResult = 3 end
  • このスクリプトは、variableの値が2でない場合に、endResult に3の値を設定するだけで、他には何もしていません。

if文の入れ子

true/false文のブロックの中にif文を入れることで、さらに実行を分岐させることができます。
例:

if variable == 0 then endResult = 1 else if variable == 1 then endResult = 2 end end 
  • このスクリプトは、variableが0の場合、endResult を1に設定します。
  • variable が 0 にならず、1 になる場合、endResult は 2 に設定されます。

例:

if variable == 0 then if endResult == 1 then endResult = 2 end else endResult = 1 end
  • このスクリプトは、vaiableの値が0で、endResultが1の場合、endResult を2に設定します。
  • そうでなければ endResult を 1 に設定します。

なお、入れ子になったif文を含むスクリプトは、インデントされたきれいな形にフォーマットしたほうが、スクリプトの流れを計画したり、デバッグしたりしやすいかもしれません。

注意:このようにスクリプトを書いてもチップでは動作しませんが、スクリプトをデバッグする際にはこのようにすると便利です。

これは、2つ目の入れ子になった例を整形したものです:

if variable == 0 then
    if otherVariable == 1 then
        otherVariable = 2
    end
else
    otherVariable = 1
end

コメント

コメントは、多くのプログラマが使用するコードを書くときに便利です。
また、コメントは1行70文字の文字数制限にカウントされることを注意してください。

コメントは次のような構文で使用します。

  • // text
    • テキストは一行分の任意の文字集合です。
// これはコメントです。他の行のスクリプトがどのように動作するかを説明します。
  • コメント構文の例

エラー

プログラミング言語では、2種類のエラーが発生することがあります。

  1. 構文エラー
  2. ランタイムエラー
  • 構文エラーは、無効で解析不能なスクリプトから発生し、その行全体が実行されません。
  • ランタイムエラーは、スクリプトが実行されている間のみ発生します。ランタイムエラーは、スクリプトが実行されている間にのみ発生し、その行の実行は中断されますが、エラーが発生するまでの効果は残ります。

既知のバグ/意図しない動作

以下は、YOLOLに関する既知の問題のリストです:

  • "if" のようなキーワードを含む 変数名は、そのキーワードを考慮して解析され、シンタックスエラーになります。例: :life は :l if e と解析されます。

関連ページ

Cookies help us deliver our services. By using our services, you agree to our use of cookies.