FleurDuSoleil3 Posted February 28, 2018 Share Posted February 28, 2018 Not sure if this is the correct place for this; however, I am making a bit of a schoolboy error and after numerous attempts to rectify it myself I am having a bit of trouble. There is a missing end function that resolves the if.GLOBAL line. I got the character to plant rabbit holes and then added in those extra two lines to make this ability unique to her. Can anyone help me out with where the missing end goes? local function rabbitHolePostInit(inst) if GLOBAL.GetPlayer().prefab == "bob" then local function CanDeploy(inst) return true end local function ondeploy(inst, pt) local rabbit = GLOBAL.SpawnPrefab("rabbithole") if rabbit then rabbit.Transform:SetPosition(pt.x, pt.y, pt.z) end end function rabbitHole(inst) inst:AddComponent("deployable") inst.components.deployable.test = function() return true end inst.components.deployable.ondeploy = ondeploy end AddPrefabPostInit("rabbit", rabbitHole) I feel so silly for not being able to work this one out myself. I am slowly improving my coding abilities but in, well, very tentative baby steps. Link to comment Share on other sites More sharing options...
Developer ImDaMisterL Posted February 28, 2018 Developer Share Posted February 28, 2018 Moved to Mods and Tools. Kleilist is for requesting assistance of coders/artists etc. to make a mod together. Hope you find someone who can help you Link to comment Share on other sites More sharing options...
ThemInspectors Posted February 28, 2018 Share Posted February 28, 2018 21 minutes ago, Aquafox333 said: local function rabbitHolePostInit(inst) if GLOBAL.GetPlayer().prefab == "bob" then local function CanDeploy(inst) return true end local function ondeploy(inst, pt) local rabbit = GLOBAL.SpawnPrefab("rabbithole") if rabbit then rabbit.Transform:SetPosition(pt.x, pt.y, pt.z) end end function rabbitHole(inst) inst:AddComponent("deployable") inst.components.deployable.test = function() return true end inst.components.deployable.ondeploy = ondeploy end AddPrefabPostInit("rabbit", rabbitHole) Hey, indentation might be something to look into, it makes your code neater. local function rabbitHolePostInit(inst) if GLOBAL.GetPlayer().prefab == "bob" then local function CanDeploy(inst) return true end local function ondeploy(inst, pt) local rabbit = GLOBAL.SpawnPrefab("rabbithole") end if rabbit then rabbit.Transform:SetPosition(pt.x, pt.y, pt.z) end end function rabbitHole(inst) inst:AddComponent("deployable") inst.components.deployable.test = function() return true end inst.components.deployable.ondeploy = ondeploy end AddPrefabPostInit("rabbit", rabbitHole) I'm not entirely sure if that's what you want, give it a spin and tell me if it works as intended Link to comment Share on other sites More sharing options...
FleurDuSoleil3 Posted February 28, 2018 Author Share Posted February 28, 2018 @ImDaMisterL Ah, collaboration. I assumed it was a request for help, period. Thank you for sorting that. @ThemInspectors Thank you for your assistance. Indentation is definitely a weak point of mine. I am actually going to polish it at the weekend if time allows. 10 hours ago, ThemInspectors said: local function rabbitHolePostInit(inst) if GLOBAL.GetPlayer().prefab == "bob" then local function CanDeploy(inst) return true end local function ondeploy(inst, pt) local rabbit = GLOBAL.SpawnPrefab("rabbithole") end if rabbit then rabbit.Transform:SetPosition(pt.x, pt.y, pt.z) end end function rabbitHole(inst) inst:AddComponent("deployable") inst.components.deployable.test = function() return true end inst.components.deployable.ondeploy = ondeploy end AddPrefabPostInit("rabbit", rabbitHole) So, the game crashed and offered me this helpful titbit. Problem is, this is how I came to learn I was missing an end in the first place. Any more suggestions? I'm greatly appreciative of your help. Also, if you do know how to fix this, could you tell me what the issue is, and how you solved it, so I don't need to ask anyone for help should this problem arise in the future? Link to comment Share on other sites More sharing options...
ThemInspectors Posted February 28, 2018 Share Posted February 28, 2018 @Aquafox333 Sorry, I made an error in my code, so sorry that I missed it, it should be this local function rabbitHolePostInit(inst) if GLOBAL.GetPlayer().prefab == "bob" then local function CanDeploy(inst) return true end local function ondeploy(inst, pt) end local rabbit = GLOBAL.SpawnPrefab("rabbithole") end if rabbit then rabbit.Transform:SetPosition(pt.x, pt.y, pt.z) end end function rabbitHole(inst) inst:AddComponent("deployable") inst.components.deployable.test = function() return true end inst.components.deployable.ondeploy = ondeploy end AddPrefabPostInit("rabbit", rabbitHole) it was on the local function ondeploy(inst, pt) end there was a missing end there. Link to comment Share on other sites More sharing options...
FleurDuSoleil3 Posted March 1, 2018 Author Share Posted March 1, 2018 @ThemInspectors Thank you very much! You've helped me out a lot. The game no longer crashes! Now I can focus on the other daunting unique abilities of this character. At least this is a far more intuitive system than the one Bethesda uses for their games. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.