Small Robots - Just make the robots a bit smaller.

by Pi-C

Change the size of logistic, construction, and combat bots! You can scale vanilla and modded bots between 50% and 250% of their original size. This mod is the perfect complement for "miniMAXIme: Character scaler and selector".

Tweaks
27 days ago
0.16 - 2.0
3.58K

b [Fixed] Crash with Factorio 0.18.4

4 years ago

With version 0.0.5 of your mod, Factorio crashes on starting:

 21.333 Mods to disable:Failed to load mods: __SmallRobots__/data-final-fixes.lua:40: attempt to index field 'working' (a nil value)
stack traceback:
    __SmallRobots__/data-final-fixes.lua:40: in function <__SmallRobots__/data-final-fixes.lua:9>
    (...tail calls...)
    __SmallRobots__/data-final-fixes.lua:56: in function 'process_techs'
    __SmallRobots__/data-final-fixes.lua:60: in main chunk

Mods to be disabled:
• SmallRobots
4 years ago
(updated 4 years ago)

Fixed it by changing data-final-fixes.lua from

local function modify_construction_robot(name, construction_robot)

--- construction
if data.raw["construction-robot"][construction_robot.name]["idle"] then
data.raw["construction-robot"][construction_robot.name]["idle"].scale = 1*(settings.startup["robot-size"].value/100)
end
if data.raw["construction-robot"][construction_robot.name]["idle"]["hr_version"] then
data.raw["construction-robot"][construction_robot.name]["idle"]["hr_version"].scale = 0.5*(settings.startup["robot-size"].value/100)
end

<snip>

  return 
end

to

local function modify_construction_robot(name, construction_robot)

    --- construction
  local bot = data.raw["construction-robot"][construction_robot.name]

  if bot then
    if bot["idle"] then
      bot["idle"].scale = 1*(settings.startup["robot-size"].value/100)
      if bot["idle"]["hr_version"] then
        bot["idle"]["hr_version"].scale = 0.5*(settings.startup["robot-size"].value/100)
      end
    end

    <snip>

  end
  return
end

Did the same for the function modify_logistic_robot() some lines further down.

By the way, I heard that calls to data.raw are expensive, one therefore should use a local variable instead if the same thing in data.raw is used repeatedly. That's why I used "local bots = …". Also, it's less code you have to write and the short reference makes the code more readable. :-)

4 years ago

Thats very nice Pi-C!!! I need to do it in other mods too... Thanks!!!

4 years ago

Great, thank you!

4 years ago

You should do the same for the logistic bots. With 8 different cases, you could even put this in a loop and save a lot of code:

local function modify_logistic_robot(name, logistic_robot)

--- logistic
local bot = data.raw["logistic-robot"][logistic_robot.name]

    if bot then
        for _, state in ipairs({"idle", "idle_with_cargo",
                                "in_motion", "in_motion_with_cargo",
                                "shadow_idle", "shadow_idle_with_cargo",
                                "shadow_in_motion", "shadow_in_motion_with_cargo"}) do

            if bot[state] then
                bot[state].scale = 1*(settings.startup["robot-size"].value/100)
                if bot[state]["hr_version"] then
                    bot[state]["hr_version"].scale = 0.5*(settings.startup["robot-size"].value/100)
                end
            end
        end
    end
  return
end
4 years ago

Came here to report this after running into it last night.

Thank you both for your efforts!

4 years ago

That code is awesome... Pi-C, could you update this mod for me please? I put you as a creator. Thanks.

4 years ago

Thanks! I just updated.

4 years ago

“And there was much rejoicing.”

4 years ago

:-)

4 years ago

Awesome!!!! :D :D :D

4 years ago

@DellAquila:
Glad you like it! If you're interested, I've also taken a shot at your Maps mod for my own use (so it assigns loot to all trees, spawners and worms, including modded ones). I could send you the zip file per PM on the forum. It also would be nice if you could update the Water Turrets. Locally, I just changed info.json and made sure all icon definitions include

icon_size = 32, -- Adapt value to actual icon size!
icon_mipmaps = 1, -- Factorio 0.18 expects 4 mipmaps per default, setting this to 1 will prevent warnings in the log file

I haven't really tested yet during continuous playing, but the mod loads without errors and seems to work. Also, water turrets are too useful to not generally available in 0.18! :-)

4 years ago

Niiice... i will be very happy if you can help me with these mods... Be free to change them... :)

4 years ago

Niiice... i will be very happy if you can help me with these mods... Be free to change them... :)

New response