-
Notifications
You must be signed in to change notification settings - Fork 80
Common pitfalls and unexpected behaviours
This is a list of weird behaviors that have caused unexpected issues.
- Don't use local refs to global in control stage code
Refs to global table entries get broken during on_load which will cause desyncs.
- Events will not be caught by modules until after on_init is complete
If you register an event in the control stage of x.lua
and in y.lua
raise an event during on_init
, x.lua
's event hook will not get triggered.
- Dynamic requires
RedMew uses a script to deflate saves. This script does not work correctly with "dynamic requires", or require statements that use variables in them. Example: require 'map_gen.maps.' .. map_name
- Printing table refs
Printing refs to tables has a high chance of causing desyncs. Ex. game.print(tostring(global))
or game.print(serpent.block(_ENV))
- Setting speed
Cars can have their speed set by LuaEntity.speed however trains cannot. For trains you must use LuaEntity.train.speed. This can be tricky if you're using LuaPlayer.vehicle since you don't know what type of vehicle they might be driving.
Having issues? Reach out on discord
Got a bug report, feature request or map idea? Open an issue
Looking to download maps? See releases or the public save directory
Interested in Localization? Check out the progress at Crowdin