Barotrauma 潜渊症

Barotrauma 潜渊症

评价数不足
Lua Component
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
28.688 KB
2022 年 5 月 23 日 下午 2:03
2022 年 8 月 4 日 上午 12:17
3 项改动说明 ( 查看 )

订阅以下载
Lua Component

描述
instead a thousand of wires

! designs before aug 4th update need their scripts to be updated and may require component rewire !
! i, o, m renamed to inp, out, mem !

inp[] is for inputs, out[] is for outputs, 8 of each.
mem[] for memory, size is limited by your sanity and 4096 characters of lua representation by default.
sample:
if not mem.bar then mem.bar=0 end -- init mem.bar if inp[1]==1 then mem.bar=mem.bar+1 end -- if input 1 is high, increment mem.bar out[1]=mem.bar -- set output 1 to mem.bar if inp[2]==1 then msave() end -- if input 2 is high, save memory to component (done automatically on round end) if inp[3]==1 then mload() end -- if input 3 is high, load memory from component (done automatically on round start)
code goes in first "memory component" value, second one is used to store memory between rounds; the latter is not editable in-game by default as it probably should.

memory can store simple values under any index:
mem.foo="bar" mem[1]=9001 mem[0]=inp[1]==1

not tested in actual MP, may just work fine dunno.

requires "Lua for Barotrauma" mod.
18 条留言
Matheus 2023 年 9 月 27 日 上午 7:06 
Since this one is obsolete, please also consider using MicroLua
zomgtehderpy  [作者] 2023 年 4 月 1 日 下午 10:13 
with the release of a Better Lua Component , this one should be considered a proof-of-concept and not used unless you are a masochist.
zomgtehderpy  [作者] 2023 年 3 月 29 日 下午 12:27 
@Derpino I am pretty sure indexes go from 1 to 8, not 0 to 7.
Derpino 2023 年 3 月 13 日 上午 11:54 
I can't get this mod to work for some reason with even with a super simple script "out[0]=9001".

I have lua for barotrauma installed and get some other dependent mods to work...:steamsad:
Maddremor 2023 年 1 月 7 日 上午 6:12 
I don't know how useful this will be, but I'm still having memory leaks with this in MP.
zomgtehderpy  [作者] 2022 年 10 月 21 日 上午 6:43 
4096 is a soft cap and can be increased exactly as you said. i remember reading somewhere that too much data in memory component might negatively affect game performance, so there's that. minimizing code could be a slightly better idea.
testing for mp should be pretty simple: first 3 lines from sample code, push button, text display, couple of wires; start a round, click the button, end the round, start the next one (output should retain), all the while checking for consistency among all clients. i coudve test it myself but i hab no frens :c
NeckRopeMancer 2022 年 10 月 20 日 下午 12:09 
Has anyone tested this in MP (as the author says they have not)?
|SPQR| Vetinarix 2022 年 8 月 5 日 下午 7:03 
Excellent news - cheers.
Will let you know if it's not :)
zomgtehderpy  [作者] 2022 年 8 月 4 日 上午 12:30 
@Vetinarix incompatibility is highly unlikely.
all potential leaks should be fixed now with brand new storage method and other fixes.
please update your designs and check for errors.
|SPQR| Vetinarix 2022 年 8 月 2 日 下午 11:57 
Worth pointing out, it may have been the math I was doing in the lua component itself, although admittedly it wasn't too complex.