Author Topic: craftorders.lua - removeSpecialOrders() improvement  (Read 195 times)

Hammelpilaw

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    556
    • View Profile
    • Scrap Yard - Avofactory
on: February 17, 2019, 10:50:32 AM
While modding the craftorders.lua I got two problems with the function removeSpecialOrders().

Code: [Select]
local function removeSpecialOrders()
    local entity = Entity()

    for index, name in pairs(entity:getScripts()) do
        if string.match(name, "data/scripts/entity/ai/") then
            entity:removeScript(index)
        end
    end
end

1.
The function is local, it should be in the namespace instead to overwrite it in other files that extend craftorders.lua.

2.
Code: [Select]
if string.match(name, "data/scripts/entity/ai/") then should be replaced by
Code: [Select]
if string.match(name, "/scripts/entity/ai/") then to remove order scripts in "mods/mymod/scripts/entity/ai/" too.
Scrap Yard Galaxy
My mods and tools
My Workshop

If you find a bug in my mods please contact me.