Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
api:computer:zh [2023/10/16 13:05]
hfsr [Computer API]
api:computer:zh [2023/10/17 05:26]
hfsr
Line 16: Line 16:
   电脑所在的网络中能够存储的最大能量数量。对机器人而言是机器人的内置能量缓存大小(可以在机器人的GUI中查看)。   电脑所在的网络中能够存储的最大能量数量。对机器人而言是机器人的内置能量缓存大小(可以在机器人的GUI中查看)。
 - `computer.uptime():​ number`  ​ - `computer.uptime():​ number`  ​
-  ​The time in real world seconds this computer has been running, measured based on the world time that passed since it was started - meaning this will not increase while the game is paused, for example.+  ​现实世界中此电脑运行的时间,单位为秒。计算方法为自电脑启动以来游戏世界经过的时间——意味着游戏暂停时此数值不会增长。
 - `computer.shutdown([reboot:​ boolean])`  ​ - `computer.shutdown([reboot:​ boolean])`  ​
   关闭电脑。如果`reboot`为`true`也可以重启电脑,即先关机再自动启动。此函数不会有返回值。   关闭电脑。如果`reboot`为`true`也可以重启电脑,即先关机再自动启动。此函数不会有返回值。
Line 38: Line 38:
   - `1`: 单用户模式,文件系统与组件已初始化——OpenOS完成了启动   - `1`: 单用户模式,文件系统与组件已初始化——OpenOS完成了启动
 - `computer.users():​ string, ...`  ​ - `computer.users():​ string, ...`  ​
-  ​A list of all users registered on this computer, as a tuple. To iterate the result as a list, use `table.pack` ​on it, first. +  ​此电脑上的全体登记用户列表,形式为元组。若要将结果转化为表,请使用`table.pack` 
-  ​Please see [[:​computer_users|the user rights documentation]].+  ​请查看[[:​computer_users:zh|用户行为控制文档]]
 - `computer.addUser(name:​ string): boolean or nil, string`  ​ - `computer.addUser(name:​ string): boolean or nil, string`  ​
-  ​Registers a new user with this computer. Returns ​`true` ​if the user was successfully added. Returns ​`nil` and an error message otherwise.  ​ +  ​在此电脑上登记某个新用户。若添加成功则返回`true`,否则返回`nil`和一条报错信息。 
-  ​The user must be currently in the game. The user will gain full access rights on the computer. In the shell`useradd ​USERis a command line option to invoke this method.+  ​欲添加的用户必须在线。此用户将会获得此电脑的完全访问权限。在shell中,可以执行`useradd ​<​用户名>​`命令调用此方法。
 - `computer.removeUser(name:​ string): boolean`  ​ - `computer.removeUser(name:​ string): boolean`  ​
-  ​Unregisters a user from this computer. Returns ​`true` ​if the user was removed, ​`false` ​if they weren'​t registered in the first place.  ​ +  ​删除此电脑上的某个用户。若用户成功被移除则返回`true`,若用户先前未被登记则返回`false` 
-  ​The user will lose all access to this computer. When the last user is removed from the user list, the computer becomes accessible to all players. ​`userdel ​USERis a command line option to invoke this method.+  ​此用户将会失去对此电脑的一切访问权限。当用户列表中的所有用户均被移除时,所有用户均可访问此电脑。在命令行中可使用`userdel ​<​用户名>​`调用此方法
 - `computer.pushSignal(name:​ string[, ...])`  ​ - `computer.pushSignal(name:​ string[, ...])`  ​
-  ​Pushes a new signal into the queue. Signals are processed in a FIFO order. The signal has to at least have a name. Arguments to pass along with it are optional. Note that the types supported as signal parameters are limited to the basic types nilbooleannumberstring, and tables. Yes tables are supported (keep reading). Threads and functions are not supported.+  ​向队列中推送一个新信号。信号按照先进先出顺序处理。推送的信号应至少有信号名,而一并传递的参数是否存在均可。请注意只有基本数据类型才可作为信号参数,包括:nil(空)、boolean(布尔型)、number(数字型)、string(字符串型)和table(表)。表类型确实受支持(请继续读),但是线程和函数型变量不受支持。
   ​   ​
-  ​Note that only tables of the supported types are supported. That is, tables must compose types supported, such as other strings and numbers, or even sub tables. But not of functions or threads.+  ​请注意只有特定类型的表才受支持。具体而言,表必须由受支持的数据类型组成,例如string(字符串)型和number(数字)型,甚至可以是子表。但是不可以包含线程和数组。
 - `computer.pullSignal([timeout:​ number]): name, ...`  ​ - `computer.pullSignal([timeout:​ number]): name, ...`  ​
-  ​Tries to pull a signal from the queue, waiting up to the specified amount of time before failing and returning ​`nil`. If no timeout is specified waits forever.  ​ +  ​尝试从队列中拉取一个信号,在等待指定时长后判定为失败并返回`nil`。如果不指定时间则永久等待。 
-  ​The first returned result is the signal name, following results correspond to what was pushed in `pushSignal`, for example. These vary based on the event type. +  ​返回结果的第一个值为信号名,后面的返回值与`pushSignal`推送的内容有关。依事件类型而定。 
-  ​Generally it is more convenient to use `event.pull` from the [[api:​event|event]] ​libraryThe return value is the very same, but the `event` ​library provides some more options.+  ​通常而言使用[[api:event:zh|event]]库中的`event.pull`函数更加方便。返回值完全一致,但是`event`库提供了更多选项。
  
 - `computer.beep([frequency:​string or number[, duration: number])` - `computer.beep([frequency:​string or number[, duration: number])`
  
-  ​if `frequency` ​is a number it value must be between ​20 and 2000.+  ​`frequency`为数字,其值需要介于202000之间。
  
-  ​Causes the computer to produce a beep sound at `frequency` Hz for `duration` ​seconds. This method is overloaded taking a single string parameter as a pattern of dots `.` and dashes ​`-` for short and long beeps respectively.+  ​让电脑产生频率为`frequency` Hz,时长为`duration`秒的滴声。此函数已经被重载为可以接收一个字符串参数,其格式为点`.``-`破折号的组合,分别代表短与长滴声。
  
 - `computer.getDeviceInfo():​ table` - `computer.getDeviceInfo():​ table`
  
-  ​Returns a table of information about installed devices in the computer.+  ​返回存储了此电脑上安装的设备信息的表。
  
 目录 目录
 ----------- -----------
 {{page>​api:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}} {{page>​api:​contents:​zh&​noheader&​noeditbutton&​nouser&​nofooter}}