mesecons icon indicating copy to clipboard operation
mesecons copied to clipboard

add luacontroller enhancements

Open cpdef opened this issue 8 years ago • 15 comments

I had the Idea to make luacontrollers enahnceable, so that they can maybe detect light, if u put a solar panel in a slot inside it, or detect nodes or players etc. For example os.ingame_time would be then minetest.timeofday().

If this is a good Idea i could also try to add this myself and create a PR. greetings juli

cpdef avatar May 01 '17 08:05 cpdef

Adding digiline functionality to the solar panel (or using the RTC from digilines) would solve this, no?

benrob0329 avatar May 01 '17 14:05 benrob0329

It would solve it, but digilines can't be aviable on much servers because its too slow and people can crash the server with it very simple.

EDIT: an example: u run digiline_send("", i) in a forloop (for 1, 50, i) and connect the controller to 30 LCDs the lag goes so high, that i coldn't run any command anymore ...

cpdef avatar May 01 '17 15:05 cpdef

hmm, so digiline send ratio should be limited too... or LCD receive ratio: these old cheap displays may be allowed to be slow or even to overheat on such intensive signals.

Also, the server should finally become truly multi-threaded. But that’s another story.

numberZero avatar May 07 '17 23:05 numberZero

On digilines: you can install altered mod, without the wires =) Digiline devices do connect to each other if adjacent, so you still can use them.

numberZero avatar May 07 '17 23:05 numberZero

Oh well, and there are so many ways to crash or freeze the server... Quarries at block boundary... These old deployer-breaker tricks... Or just a sufficiently large active mesecon circuit...

numberZero avatar May 07 '17 23:05 numberZero

ok maybe i try to make an option for digilines to restrct the messages send by player per min, overheat would be good too for devices.

cpdef avatar May 08 '17 08:05 cpdef

u run digiline_send("", i) in a forloop (for 1, 50, i)

As far as I noticed, for loops are limited (sadly).

Desour avatar May 08 '17 12:05 Desour

limited? well, Lua execution time is limited somehow, but not the native code which may be called intensively by LCDs (entities are heavy, and may easily freeze a server if you use them in a special, often seemingly innocent way). ~~Also remember that unlike mesecons, digilines are fully synchronous, there is no action queue.~~ Actually, there is a minetest.after(0,…) call.

numberZero avatar May 08 '17 14:05 numberZero

The loops aren't limited in time but in loop count AFAIK.

Desour avatar May 08 '17 15:05 Desour

@DS-Minetest no. The overall instruction count is limited. So if you e.g. unroll a loop, you don’t get any significant benefit.

numberZero avatar May 08 '17 16:05 numberZero

@numberZero I will search for a evidence.

Edit: Hmm, I think, I'm wrong.

Desour avatar May 08 '17 17:05 Desour

https://github.com/minetest-mods/mesecons/blob/master/mesecons_luacontroller/init.lua#L414

numberZero avatar May 08 '17 19:05 numberZero

i don't say that without a test i can send u the world if u don't trust me :P its possible with an amount of 50 in a for loop, if u use 10 more or so it will burn

cpdef avatar May 09 '17 12:05 cpdef

@cpdef That’s how it works. Not the program length is limited, but the amount of instructions being executed. So, if you execute some part several times (e.g. in a loop), it is counted these several times. That works very well for controllers themselves. But the limit is not applied to the LCDs or other devices. (Actually they receive and process all 50 messages only after the controller program ends).

So, while I’m against this particular idea, you noted a serious problem of resource usage limiting. That’s not that simple, though.

BTW, have you understood correctly my suggestion of disabling wires? That way, only up to 4 (maybe a bit more, if it transmits diagonally too) devices could be connected to a LuaCtl, thus limiting resource usage considerably.

numberZero avatar May 10 '17 21:05 numberZero

Yes understood that with disabling the wires. I have some ideas how to restricte the resource usage, but atm i can't test (not enought time), maybe in 2 weeks or so i can test it

cpdef avatar May 11 '17 15:05 cpdef