Jump to content

Recommended Posts

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. 
 
Edited by Aquafox333
Adding solved
Link to comment
https://forums.kleientertainment.com/forums/topic/88145-solved-missing-end/
Share on other sites

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

@ImDaMisterL

Ah, collaboration. I assumed it was a request for help, period. Thank you for sorting that.

 

@ThemInspectorsimage.thumb.png.34831e2039bff6f813eb9e1d3a4b1c0f.png

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?

Edited by Aquafox333
Formatting

@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.

@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. 

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
×
  • Create New...