D00Med / scifi_nodes

Minetest mod that adds scifi themed nodes
Other
12 stars 18 forks source link

Code cleanup #20

Closed thomasrudin closed 5 years ago

thomasrudin commented 5 years ago

I can squash that if you like

D00Med commented 5 years ago

thankyou

Grossam commented 5 years ago

Your code for palm scanner is far simpler than mine, so it's better I guess.

Could you tell more about the crashes ? We have known on another server, so I'd like to have a look a it (I hate when I don't understand ;-) )

For instance : I don't understand what's between the parenthesis :

on_timer = (has_mesecons and toggle_switch)

Someone can explain ?

thomasrudin commented 5 years ago

Your code for palm scanner is far simpler than mine, so it's better I guess.

Could you tell more about the crashes ? We have known on another server, so I'd like to have a look a it (I hate when I don't understand ;-) )

There were some race-conditions in which this code: https://github.com/D00Med/scifi_nodes/blob/4860c82137006533b98ea2668fafb927aa8aabcc/nodeboxes.lua#L1469 got called from a timer without a player value :/

Sorry for refactoring your code, i was in the process of splitting the codebase into multiple files... The new variant also checks for is_protected() to allow (for example) multiple players access with the protector_redo or areas mod, not just the owner.

I hope that works for you, if not just tell me i can add a PR with compatibility settings...

Grossam commented 5 years ago

It's open source so there's nothing like "my" code, so you did well : thank you for improving our code ;-)

And what about that (has_mesecons and toggle_switch)

thomasrudin commented 5 years ago

It's open source so there's nothing like "my" code, so you did well : thank you for improving our code ;-)

And what about that (has_mesecons and toggle_switch)

Its basically a "trick" to return the second value if the first is present, or nil if not:

local x = (has_mesecons and 42)

-- has_mesecons == true
local x = 42
-- has_mesecons == false
local x = nil

I try to apply that as sparsely as possible though, as it is not that transparent :confused:

Grossam commented 5 years ago

It's handy, once you know about it.

Thank you !