编辑“︁
StendhalScripting/LuaAPI
”︁(章节)
跳转到导航
跳转到搜索
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
= Supplemental Methods = A few convenience methods are added to make scripting easier. == String Manipulation == The following methods have been added to the built-in Lua [https://www.lua.org/manual/5.3/manual.html#6.4 string] library. ; ''<span style="color:green;">string.startsWith</span>(st, prefix)'' : Checks if a string begins with a set of characters. : '''''st:''''' The string to be checked. : '''''prefix:''''' The prefix to be compared with. : ''returns:'' <code>true</code> if <code>prefix</code> matches the beginning characters of <code>st</code>. :; ''aliases:'' :: <span style="color:green; font-style:italic;">string.beginsWith</span> ; ''<span style="color:green;">string.endsWith</span>(st, suffix)'' : Checks if a string ends with a set of characters. : '''''st:''''' The string to be checked. : '''''suffix:''''' The suffix to be compared with. : ''returns:'' <code>true</code> if <code>suffix</code> matches then end characters of <code>st</code>. ; ''<span style="color:green;">string.isNumber</span>(st)'' : Checks if a string contains numeric characters only. : '''''st:''''' The string to be checked. : ''returns:'' <code>true</code> if all characters are numeric, <code>false</code> otherwise. :; ''aliases:'' :: <span style="color:green; font-style:italic;">string.isNumeric</span> ; ''<span style="color:green;">string.trim</span>(st)'' : Removes leading & trailing whitespace from a string. : '''''st:''''' The string to be trimmed. : ''returns:'' Trimmed string. ; ''<span style="color:green;">string.ltrim</span>(st)'' : Removes leading whitespace from a string. : '''''st:''''' The string to be trimmed. : ''returns:'' Trimmed string. ; ''<span style="color:green;">string.rtrim</span>(st)'' : Removes trailing whitespace from a string. : '''''st:''''' The string to be trimmed. : ''returns:'' Trimmed string. ; ''<span style="color:green;">string.builder</span>(st)'' : Creates a new instance of [https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html java.lang.StringBuilder]. : '''''st:''''' (optional) String to append on instantiation. : ''returns:'' new StringBuilder instance. == Table Manipulation == The following methods have been added to the built-in Lua [https://www.lua.org/manual/5.3/manual.html#6.6 table] library. ; ''<span style="color:green;">table.concat</span>(tbl1, tbl2)'' : Merges the contents of one table into another. : '''''tbl1:''''' The table receiving the new content. : '''''tbl2:''''' The table containing the content to be copied. {{PublicMethod | table.contains | params=table, o | desc=Checks if a table contains a value. | paramlist= {{MethodParam | table | type=table | desc=Table to be checked.}} {{MethodParam | o | desc=The object to check for.}} | ret=<code>true</code> if <code>o</code> is in <code>table</code>. | rettype=boolean }} ; ''<span style="color:green;">table.clean</span>(tbl)'' : Removes <code>nil</code> values from a table. : '''''tbl:''''' The table to be cleaned. : ''returns:'' Copy of <code>tbl</code> with <code>nil</code> values removed. {{PublicMethod | table.join | params=table, delim | desc=Joins a table of strings into a string. | paramlist= {{MethodParam | table | type=table | desc=Table to be joined.}} {{MethodParam | delim | type=string | desc=Character(s) to be used as separator.}} | ret=The resulting string. | rettype=string }}
摘要:
请注意,所有对gamedev的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Gamedev:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
导航菜单
个人工具
未登录
讨论
贡献
创建账号
登录
命名空间
页面
讨论
不转换
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
臺灣正體
查看
阅读
编辑
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
工具
链入页面
相关更改
特殊页面
页面信息