Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
component:redstone_in_motion:zh [2023/11/29 10:30]
hfsr created
component:redstone_in_motion:zh [2023/12/27 03:26]
hfsr [组件:运动红石机构]
Line 1: Line 1:
-Component: Redstone in Motion+组件:运动红石机构
 -------------------------------- --------------------------------
-This component represents a Carriage Controller block from the [Redstone in Motion](https://​www.curseforge.com/​minecraft/​mc-mods/​remain-in-motion) ​mod.+此组件代表了[Redstone in Motion(运动红石机构)](https://​www.curseforge.com/​minecraft/​mc-mods/​remain-in-motion)模组的车辆控制器方块。 ​  
 +<​del>​**注意:**此组件只有在安装附属模组OpenComponents的前提下才可用!</​del> ​  
 +OpenComponents的内容已经被合并进Opencomputers内。 ​  
 +   
 +组件名:`carriage`。
  
-**Important**:​ this component is only available if OpenComponents is also installed! +回调函数:
- +
-Component name: `carriage`. +
- +
-Callbacks:+
  
 - `getAnchored():​ boolean`  ​ - `getAnchored():​ boolean`  ​
-Gets whether the controller should remain where it is when moving a carriage.+获取控制器方块在车辆移动时是否应保持原位。 ​   
 +\\
 - `setAnchored(value:​ boolean): boolean`  ​ - `setAnchored(value:​ boolean): boolean`  ​
-Sets whether the controller should remain where it is when moving a carriage. Returns the new value.+设定控制器方块在车辆移动时是否应保持原位。返回新的值。 ​  
 +\\
 - `move(direction:​ string or number[, simulate: boolean]): boolean`  ​ - `move(direction:​ string or number[, simulate: boolean]): boolean`  ​
-Tells the controller to try to move a carriage. The direction ​can either be a string indicating a direction or one of the [[api:​sides|sides API]] constants. You can optionally specify whether to only simulate a move, which defaults to false. Returns ​`true` ​if the command was relayed successfully. ​  +让控制器尝试移动车辆。`direction`可以为指示某方向的字符串,或[[api:sides:zh|sides(方向) ​API]]中的常量之一。你还可以指定是否要进行模拟运动,默认为`false`。若命令执行成功则返回`true`。   
-This function does not return the actual results of the move.  ​ +此函数不会返回移动的真正结果。 ​   ​ 
-Due to technical limitations the results are asynchronously fed back to the computer as a signal with the name `carriage_moved`. It has the signature success: ​`result[, reason: string]`, where `reason` ​is an error string if the move failed. This is because the computer that triggers the move may be moved as well, meaning it has to be persisted, which is only possible while it is in a yielded state. ​  +由于技术限制,移动结果将以名为`carriage_moved`的信号异步反馈给电脑。其签名为:`result[, reason: string]`,若移动失败,其中的`reason`为报错信息字符串。这是因为触发了移动的电脑可能也会进行移动,意味着电脑需要暂停运作,这必然导致电脑进入yield状态。 ​  
-Possible string values for direction are: negyposynegzposznegxposx and downupnorthsouthwesteast \\+可用的方向字符串有:`negy`、`posy`、`negz`、`posz`、`negx`、`posx`,以及`down`、`up`、`north`、`south`、`west`、`east`。  \\ 
 +\\
 - `simulate(direction:​ string or number): boolean`  ​ - `simulate(direction:​ string or number): boolean`  ​
-Like `move(direction,​ true)`. ​ \\+类似`move(direction,​ true)`. ​ \\
  
-Example use:+使用例:
  
 ```lua ```lua
Line 28: Line 31:
 local sides = require("​sides"​) local sides = require("​sides"​)
  
-local cc = component.carriage -- get primary carriage controller+local cc = component.carriage --获取首选车辆控制器组件
 cc.move("​up"​) cc.move("​up"​)
 local _, _, result, reason, x, y, z = event.pull("​carriage_moved"​) local _, _, result, reason, x, y, z = event.pull("​carriage_moved"​)
Line 39: Line 42:
   end   end
 end end
--- using the sides table:+-- 使用sides表的值:
 cc.simulate(sides.west) cc.simulate(sides.west)
 ``` ```