Jump to content

'end' expected (to close 'if' at line 144) near ')'


Recommended Posts

I am trying to add more actions for the werebeaver such as shaving, being able to dig turfs and being able to carry suspicious marbles but after I implement this

and mimick the games' codes I get the error of the TITLEAfter this crash report I kept on adding endings at line 149 until it stopped and then redirected me to line 160 and expected a then near ( , I did that but it now keeps on asking me for <eof> at the previous line 159.

local function RightClickPicker(inst, target)
   144 if target ~= nil and target ~= inst then
        for i, v in ipairs(BEAVER_DIET) do
            if target:HasTag("edible_"..v) then
                return inst.components.playeractionpicker:SortActionList({ ACTIONS.EAT }, target, nil)
              end
         149 end
end
  end
end
        return (target:HasTag("HAMMER_workable") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.HAMMER }, target, nil))
            or (target:HasTag("DIG_workable") and
                target:HasTag("sign") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.DIG }, target, nil))
            or (target:HasTag("groundtile")) and
      160  target:HasTag("molebait") and
		 inst.components.playeractionpicker:SortActionList({ ACTIONS.TERRAFORM }, target, nil))
		or (target:HasTag("bearded") and
		inst.components.playeractionpicker:SortActionList({ SHAVE }, target, nil))
		or (target:HasTag("irreplaceable") and
        target:HasTag("nonpotatable") and
        target:HasTag("heavy") and
		inst.components.playeractionpicker:SortActionList({ PICKUP }, target, nil))
		or nil
   end
end

The vanilla woodie code is this one

local function RightClickPicker(inst, target)
    if target ~= nil and target ~= inst then
        for i, v in ipairs(BEAVER_DIET) do
            if target:HasTag("edible_"..v) then
                return inst.components.playeractionpicker:SortActionList({ ACTIONS.EAT }, target, nil)
            end
        end
        return (target:HasTag("HAMMER_workable") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.HAMMER }, target, nil))
            or (target:HasTag("DIG_workable") and
                target:HasTag("sign") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.DIG }, target, nil))
            or nil
    end

The crash report:

[00:02:00]: [string "scripts/mainfunctions.lua"]:147: Error loading file prefabs/woodie
[string "../mods/test/scripts/prefabs/woodie.lua"]:158: 'end' expected (to close 'if' at line 144) near ')'
LUA ERROR stack traceback:
    =[C]:-1 in (global) assert (C) <-1--1>
    scripts/mainfunctions.lua:147 in (global) LoadPrefabFile (Lua) <135-166>
    scripts/gamelogic.lua:261 in (upvalue) LoadAssets (Lua) <159-295>
    scripts/gamelogic.lua:851 in (upvalue) cb (Lua) <846-853>
    scripts/saveindex.lua:285 in () ? (Lua) <267-286>
    =[C]:-1 in (method) GetPersistentString (C) <-1--1>
    scripts/saveindex.lua:267 in (method) GetSaveDataFile (Lua) <266-287>
    scripts/saveindex.lua:293 in (method) GetSaveData (Lua) <289-297>
    scripts/gamelogic.lua:854 in (upvalue) DoLoadWorld (Lua) <845-855>
    scripts/gamelogic.lua:897 in (upvalue) LoadSlot (Lua) <891-903>
    scripts/gamelogic.lua:963 in (upvalue) DoResetAction (Lua) <914-1003>
    scripts/gamelogic.lua:1013 in (local) complete_callback (Lua) <1005-1014>

Sorry for the mess but I don't know how to add spoilers.

 

woodie.lua

woodievanilla.lua

Link to comment
Share on other sites

Try this:

local function RightClickPicker(inst, target)
    if target ~= nil and target ~= inst then
        for i, v in ipairs(BEAVER_DIET) do
            if target:HasTag("edible_"..v) then
                return inst.components.playeractionpicker:SortActionList({ ACTIONS.EAT }, target, nil)
              end
          end
        return (target:HasTag("HAMMER_workable") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.HAMMER }, target, nil))
            or (target:HasTag("DIG_workable") and
                target:HasTag("sign") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.DIG }, target, nil))
            or (target:HasTag("groundtile") and
                target:HasTag("molebait") and
                inst.components.playeractionpicker:SortActionList({ ACTIONS.TERRAFORM }, target, nil))
            or (target:HasTag("bearded") and
                inst.components.playeractionpicker:SortActionList({ SHAVE }, target, nil))
            or (target:HasTag("irreplaceable") and
                target:HasTag("nonpotatable") and
                target:HasTag("heavy") and
                inst.components.playeractionpicker:SortActionList({ PICKUP }, target, nil))
        or nil
   end
end

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...