Barotrauma 潜渊症

Barotrauma 潜渊症

MicroLua
59 条留言
whosyourdaddy 4 月 24 日 上午 7:59 
Hi, I've made some performance optimizations to your Micro Lua (primarily focusing on caching techniques and stack access), and also added a few other features.

RuyiLuaComponent
Matheus  [作者] 2024 年 11 月 28 日 下午 4:24 
Of course, it is my intention to not break existing setups with any updates, going forward.
1465114862 2024 年 11 月 28 日 上午 11:38 
Just a suggestion.
For compatibility, please keep the 32 nodes version existing.
So that I don't need to refactor my code. :steamsad:
Matheus  [作者] 2024 年 11 月 27 日 下午 2:50 
Nick I agree the mod isnt well balanced. Though Id rather fix this mod, than create an alternate one.

I will take this into consideration to the next update. I think it needs to be way harder to craft than a circuit box.
Nick Molliger 2024 年 11 月 26 日 下午 1:48 
How about second (alternative) mod with a some of these balancing features?
1. Input and output nodes are limited to 8/16
2. Can't be used in Circuit Boxes
3. A bit harder to craft. May be the same recipie as vanilla Circuit Box
4. Crafting depends on one of the top engineer's perks
5. Rare and expensive to buy in outposts

I mean, with this thing everyone can handle whole submarine's automatization (even by copying code from internet), save many copper and tin and collect great bunch of FPGAs by disassembling old components. This ability should be deserved by making decisions and having a real engineer game experience
Nick Molliger 2024 年 11 月 26 日 下午 1:48 
This mod is a game-changer! You're damn genious! 🔥👏
Matheus  [作者] 2024 年 10 月 11 日 下午 2:39 
FYI I have published a submarine which showcases MicroLua: https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?edit=true&id=3347044949
Matheus  [作者] 2024 年 10 月 9 日 下午 11:37 
I meant to give an example of table indexing: foo\[i\]
Matheus  [作者] 2024 年 10 月 9 日 下午 11:36 
The error about indexing method not implemented is important.
It means somewhere in the code, we are applying table indexing, for example foo , to an object which does not support it.

The console error should say which line and column have a problem.
Can you double check and paste here?
dhdoctor 2024 年 10 月 9 日 下午 5:04 
polarity is correct going into the componet 1 for presence 0 for none. input 1 is door state out 2 is motion sensor 3-6 room state inputs out 1 door set state. tried it with both polarities and rewiring a new door. console is saying index method is not implemented. no output at all
dhdoctor 2024 年 10 月 9 日 下午 4:47 
sorry got home from work late yesterday can check the connections tonight
Matheus  [作者] 2024 年 10 月 7 日 下午 6:28 
Okay, one thing to keep in mind is that some time ago I edited the polarity of the motion sensor in the example.
Before, the door controller example assumed the motion sensor would be in reversed polarity, relative to the default it gets from placement.
I did not explain that previously in the comments, so that caused a bit of confusion for some users.
I have since edited the code so that it works with the normal polarity (0: no presence, 1: presence)
Can you double check your build for that mistake?
dhdoctor 2024 年 10 月 7 日 下午 5:12 
thanks for taking a look!
dhdoctor 2024 年 10 月 7 日 下午 5:11 
inp = {}
function upd ()
out[1] = inp[1]
end

that wired to a button with hello world as output passes through to the screen. i have other lua componets running too. ive gone over my wiring again on the door but still not working for some reason. It's weird cos when i first got this mod it worked and i picked the code apart to learn how to use lua a bit.
Matheus  [作者] 2024 年 10 月 7 日 下午 1:39 
Can you test something simpler? Just write a single string to a text display.

I’ll have another look tomorrow in any case.
dhdoctor 2024 年 10 月 3 日 下午 6:31 
it seems the door controller no longer works or something on my end is broken
Matheus  [作者] 2024 年 7 月 5 日 下午 1:17 
Great, nice to hear that it works.
Белочка 2024 年 7 月 5 日 下午 12:44 
And now it works. Thank you
Белочка 2024 年 7 月 5 日 下午 12:30 
I'm an idiot. I delete microlua component freeing that id, then i create microlua taking that id, thus not changing update order
Белочка 2024 年 7 月 5 日 下午 12:28 
It still does not gets inputs on first upd call, after microlua component reset (updating source code)
Белочка 2024 年 7 月 5 日 下午 12:21 
I thinking about replacing mems with something more ease to work. Like 'OR' component.
Белочка 2024 年 7 月 5 日 下午 12:14 
Well, i place microlua after mems and it not work out.
Well it because
"A memory component does not send outputs every frame, it only does when the memorized value changes and some other corner cases, like the first frame."

So I confused. If mem does not produce output, how vanilla components gets its output?
Белочка 2024 年 7 月 5 日 下午 12:01 
Thank you very much. Yes, I place mems after microlua.
Matheus  [作者] 2024 年 7 月 5 日 上午 11:44 
Oh I see what you mean.

You only get an input if the component connected to that input produces an output.

A memory component does not send outputs every frame, it only does when the memorized value changes and some other corner cases, like the first frame.

I suspect you are suffering from an update order issue: The game will first process components which have a lower numerical ID, and I suspect your memory component was placed after the microlua component, hence it has a higher ID, and hence it sends its first update too late.

For large circuits where just replacing the components is difficult, you can try using: https://github.com/Jlobblet/Barotrauma-Circuit-Resolver/blob/master/README.md
Белочка 2024 年 7 月 5 日 上午 10:14 
i think i found a workaround
Белочка 2024 年 7 月 5 日 上午 10:07 
If i read the inp[] in body it gives nil. And on the first upd call, inp[] in upd function also nil.

I want to read inputs from memory components not give them values myself
Matheus  [作者] 2024 年 7 月 5 日 上午 9:12 
Белочка: Everything on the body of the script executes before the first game update, so there you can initialize your input table with the values you need.

For example:





inp = {}

for i = 1, 32 do
inp[i] = 0
end

function upd()

end
Белочка 2024 年 7 月 3 日 下午 11:55 
Tried make a firstTick condition. Where on first upd call function will do nothing, but then on second tick there are nil inputs so i confused how inputs are updated
Белочка 2024 年 7 月 3 日 下午 11:48 
Is there a way to initialize inputs before program starts?
Белочка 2024 年 7 月 3 日 下午 11:35 
I wanted to save data across rounds. Thought I can use a default memory component by reading and writing data to it. But on the first tick all inputs are nil, triggering fail-safe mechanism in case wire is disconnected
Matheus  [作者] 2024 年 6 月 22 日 下午 12:00 
Try something simple first, just write some string to a text display, for example.
Undead 2024 年 6 月 22 日 上午 11:43 
i followed the steps and cant seem to get it to work im not sure why i will try to mess with it more when i get more time
Undead 2024 年 6 月 20 日 下午 3:03 
sorry i haven't had a chance to yet soon as i can i will let you know
Matheus  [作者] 2024 年 6 月 20 日 下午 12:21 
@Undead did that help, or are you still stuck?
Matheus  [作者] 2024 年 6 月 15 日 下午 9:13 
FYI I just modified the example in the description so it is now correct regarding motion sensor polarity.
Matheus  [作者] 2024 年 6 月 15 日 下午 8:42 
I just tested. Everything is working.

However I just remembered the door controller example is expecting the motion sensor output to be inverted, and this is not mentioned in the document.

Sorry about that!

Either modify Motion Sensor properties so 'Output' is 0 and 'False Output' is 1, or modify the example source code such that this line:

local isDoorwayObstructed = inp[2] ~= 1

is replaced with:

local isDoorwayObstructed = inp[2] ~= 0
Undead 2024 年 6 月 14 日 下午 10:06 
sounds good boss sorry for bugging but this in my opinion could be the best mod for the game
Matheus  [作者] 2024 年 6 月 14 日 下午 10:01 
ok, I will double check everything tomorrow, haven’t had time to play in quite a while…
Undead 2024 年 6 月 14 日 下午 4:15 
i for sure have it i need it for a few other mods
Matheus  [作者] 2024 年 6 月 14 日 下午 12:33 
Thats fine. I think the only thing that would make the mod not work, but not give any errors, is if you didnt do the client side lua installation, which is still required.
Undead 2024 年 6 月 14 日 上午 11:51 
the c's for lua is no longer used. the lua mod added c sharp support
Matheus  [作者] 2024 年 6 月 14 日 上午 9:32 
Do you have all the prerequisite modules installed and loaded?

After that, did you follow https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2940324793
in order to get client-side lua working with Lua for Barotrauma?

If you followed all that, if there were any problems with the mod, I would expect there to be errors on the console. Did you get any?

In any case, I will double check everything this weekend.
Undead 2024 年 6 月 13 日 下午 9:22 
Cant seem to get it working*
Undead 2024 年 6 月 13 日 下午 9:21 
i can seem to get it to work using the auto door code. i even had a buddy who is familiar with this version of lua try it and no luck
Matheus  [作者] 2024 年 6 月 11 日 下午 6:44 
Undead, It should, the mod is very simple, I dont expect having to change it every game update.
If it doesnt work, please report here and I will have it fixed.
Undead 2024 年 6 月 11 日 上午 12:33 
Does this still work?
Matheus  [作者] 2024 年 5 月 7 日 下午 3:32 
Glothia: Sure, I will try to include it next release.

Note that while this is fine for experimentation and running on small servers and fast networks, please consider that JSON is very space inefficient, even if you use no objects / only arrays.

Even so, numbers will be represented in decimal ascii, instead of just packed in few bytes.

This space inefficiency will translate into more lag and less FPS for your users.

Also note that Barotrauma imposes limits on message sizes, if your message becomes too big, you might need to split it into multiple messages, which might increase lag further.

If I have some time, I will try to implement string.pack and string.unpack, which are lua 5.3 features MoonSharp lacks. This will allow implementing much more space efficient struct packing than possible with JSON.
Glothia 2024 年 5 月 6 日 下午 8:08 
Can you make the json module available? It will make syncing more than one state easier.
Matheus  [作者] 2024 年 2 月 2 日 下午 4:53 
That works as well, but in lua you don't need to declare a parameter you won't use.
Functions are untyped, and there is no runtime enforcement of arguments passed versus parameters taken.
If you pass more arguments than parameters, extra arguments are discarded.
If you pass less arguments than parameters, then unfilled arguments will just have 'nil' value.
Ɑ͞ ̶͞ ̶͞ ﻝﮞ 2024 年 2 月 2 日 下午 1:00 
Complete example should be for that
inp = {}
function upd(deltaTime)
if inp[1] < 80 then
out[1] = "text"
end
end