Thanks for the code segments. I finally had an opportunity to take detailed look at the samples you provided.
In order for the data.lua to work, i.e. for the short data.lua to be interpreted by Factorio, I had to make the following change to line 4:
Code: Select all
local new_character = table.deepcopy (data.raw.player.player)
new_character.name = 'player-ghost'
new_character.collision_mask = {}
data:extend ({new_character})
Starting the game up, and issuing the first console command works as expected, and produces a targeted new object.
But issuing the following console command:
Code: Select all
/c game.player.character = game.player.selected
produces an entirely different result. Both the original avatar and the newly created avatar do not move, but I can use the movement keys to move my avatar all over the map and explore map, while interacting with the various objects on the surface.
Doing a bit more research, I was able to figure out that default collision mask for objects is:
{"item-layer", "object-layer", "player-layer", "water-tile"}
So trying some different things, creating a one line entry in data-final-fixes.lua of:
Code: Select all
data.raw["player"]["player"]["collision_mask"] = {}
I was able to achieve the same effect with the player's avatar ignoring all the terrain effects.
I did some looking at code within other mods for programing examples, and came across Console Extended and Noxys Swimming. It looks like what Noxys does is remove the water-tile flag from water tiles, which allows players to walk on it. Console Extended is a bit more interesting, in that it has a number of console functions which modify aspects of the game. Of particular interest to me are examples of how the player mining and running speed is modified, and implemented. Along the same line, there there are a number of mods which modify the player's run speed or reach dynamically, based on a certain condition.
I do like your idea of having a periodic check, probably once per second, or once per 60 ticks to see if collision mask should be on or off for the avatar. I've still got quite a bit of learning, figuring out, and testing to do.
Hiladdar