Barotrauma

Barotrauma

Not enough ratings
Lua Component
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
28.688 KB
23 May, 2022 @ 2:03pm
4 Aug, 2022 @ 12:17am
3 Change Notes ( view )

Subscribe to download
Lua Component

Description
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 Comments
Matheus 27 Sep, 2023 @ 7:06am 
Since this one is obsolete, please also consider using MicroLua
zomgtehderpy  [author] 1 Apr, 2023 @ 10:13pm 
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  [author] 29 Mar, 2023 @ 12:27pm 
@Derpino I am pretty sure indexes go from 1 to 8, not 0 to 7.
Derpino 13 Mar, 2023 @ 11:54am 
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 7 Jan, 2023 @ 6:12am 
I don't know how useful this will be, but I'm still having memory leaks with this in MP.
zomgtehderpy  [author] 21 Oct, 2022 @ 6:43am 
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 20 Oct, 2022 @ 12:09pm 
Has anyone tested this in MP (as the author says they have not)?
|SPQR| Vetinarix 5 Aug, 2022 @ 7:03pm 
Excellent news - cheers.
Will let you know if it's not :)
zomgtehderpy  [author] 4 Aug, 2022 @ 12:30am 
@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 2 Aug, 2022 @ 11:57pm 
Worth pointing out, it may have been the math I was doing in the lua component itself, although admittedly it wasn't too complex.