Repository navigation
Special Techniques
These are common techniques used by mods to achieve cool effects. We also say where the technique originated from in here.
Originated from: B-Mod
It stores custom data in the individual cells.
The way this is achieved is by setting a field of a cell to a value, and then using that value in other functions so it has meaning to the user or mod.
Examples:
cells[y][x].data = dataUsed best in: B-Mod
Originated from: GridTab
Seperating things by storing them on seperate grids/dimensions.
This is often achieved by creating a copy of the grid and modifying it.
You can copy the grid without having to deal with problems with pointers (remember, all tables in Lua are pointers) using the CopyTable function.
Exmaple:
copiedGrid = CopyTable(cells)
-- Somewhere else
copiedGrid[y][x].someVariable = someValueNote: In the example we are modifying the isolated part, the normal grid will not be affected. Also note: This technique will also require to somehow make functions work with the dimension and render the dimension where it makes sense. GridTab used this technique to store the grid to be loaded later when switching inbetween tabs.
Used best in: GridTab
Originated from: I-Mod
It transforms a cell based off of conditions in real time.
This was used to make the wires all look connected.
Example:
if cells[y+1][x].ctype == 40 then
cells[y][x].ctype = transformationResultID
endUsed best in: I-Mod
Note: This example will transform the cell into another cell (just like in I-Mod) if a ghost cell is put behind it.
Originated from: ME Mod
This one had the same goal as Aware transformations when it was first created, to change the cell look based off of its neighbors. But they do it differently.
In Dynamic Retexturing, each possible texture is broken into small pieces, then when the cell is rendered, on top of the cell we draw the pieces based off of conditions. That way, ME Mod was able to use 4 conditions to represent 16 possible states. There were only 2 pieces, the base and the arm of the wire, the base was the base texture of the wire, while the arm was the thing that marked a connection. The wire piece was drawn rotated in certain places based off of those conditions, so there weren't 5 pieces, there were 2.
Exmaples:
-- In the function returned as onCellDraw in the reutrn table
if cells[y][x].coolData == "Must have red dot" then
local screenPosition = calculateScreenPosition(x, y)
love.graphics.draw(redDotImage, screenPosition.x, screenPosition.y, zoom/redDotImage:getWidth(), zoom/redDotImage:getHeight(), redDotImage:getWidth()/2, redDotImage:getHeight()/2)
endUsed best in: ????
Originated from: NO Mod
Modifies the variable listorder which is responsible for the order cells are presented. This can be done to hide or show cells.
Example:
listorder = {1, 13, 27} -- Makes it only show the mover, puller and advancerUsed best in ????
Originated from: Texturer
Modifies the game's resource variables to change what the game thinks it should load.
This can be done by modifying tex, texsize and audiocache tables.
Used best in: ????
local betterMover = love.graphics.newImage("myMod/betterMover.png")
tex[1] = betterMover -- Changes the texture of the cell of ID equal to 1 (aka the mover) into a new image.
texsize[1] = {
w = betterMover:getWidth(),
h = betterMover:getWidth(),
w2 = betterMover:getWidth()/2,
h2 = betterMover:getWidth()/2,
} -- Also, we can't forget telling the game the dimensions in a more optimized wayOriginated from: B-Mod
Information Processing is where data is carried in some cells and processed by other cells. In B-Mod, this technique was presented in the form of electricity. M-Mod also has something like this in the form of Number Logic.
Example:
-- In carrier
cells[y][x].information = 3
-- In processor
if theInformationFromThatCell == 3 then
DoMover(x, y, direction) -- Act like a normal mover if the information from that cell is 3
endUsed best in: B-Mod
Originated from: BetterChunks
Subtick Manipulation, as the name emplies, is manipulating the subticks variable. This is most of the time done to update your own custom cells ahead of other vanilla cells, as modded cells get updated after all the other cells.
Example:
function DoCoolCell(x, y)
-- Update our cool cell
end
function UpdateCoolCells()
-- Loop through every thing in the grid, using chunk system to improve speed, and not caring about rotation
local x,y = 0,0
while y < height do
while x < width do
if (GetChunk(x,y).hasmodded or {})[coolCellID] then
if cells[y][x].ctype == coolCellID then
DoCoolCell(x, y)
end
x = x + 1
else
x = x + 25
end
end
y = y + 1
x = 0
end
endUsed best in: ????
- NOTE: When we state when they have originated from, we state where they have originated from in CelLuAPI, most of these have, for obvious reasons, been present in the oldest mod that predates CelLuAPI, B-Mod (the non-CelLuAPI version)