Jump to content

Works in DS but not DST


Recommended Posts

Alright, So this code worked in DS but not DST. Why not?

 

 

EDIT: Problem solved thanks to DarkXero

 

 

 

local ImageButton = require "widgets/imagebutton"

 

local function AddLeaveButton(inst)

    local controls = inst.HUD.controls

 

    local function LeavingVessel()

     LeaveVesselButton:Hide()

AddReturnButton(inst)

    end

 

    LeaveVesselButton = controls.sidepanel:AddChild(ImageButton(UI_ATLAS, "button.tex", "button_over.tex", "button_disabled.tex"))

    LeaveVesselButton:SetScale(1, 1, 1)

    LeaveVesselButton:SetPosition(-1450, 0, 0)

    LeaveVesselButton:SetOnClick(LeavingVessel)

    LeaveVesselButton:Show()

    LeaveVesselButton:SetText("Leave vessel")

    LeaveVesselButton:Enable()

    controls.sidepanel:AddChild(LeaveVesselButton)

end

 

function AddReturnButton(inst)

    local controls = inst.HUD.controls

 

    local function LeavingVessel()

 EnterButton:Hide()

      AddLeaveButton(inst)

     end

 

     EnterButton = controls.sidepanel:AddChild(ImageButton(UI_ATLAS, "button.tex", "button_over.tex", "button_disabled.tex"))

     EnterButton:SetScale(1, 1, 1)

     EnterButton:SetPosition(-1450, 0, 0)

     EnterButton:SetOnClick(LeavingVessel)

     EnterButton:Show()

     EnterButton:SetText("Return")

     EnterButton:Enable()

     controls.sidepanel:AddChild(EnterButton)

 end 

 

 function SpiritState()

  inst:AddComponent("playercontroller")

 end

 

local function sim_postinit(inst)

    if (inst.prefab == "wynter") then

        AddLeaveButton(inst)

    end

end

 

AddSimPostInit(sim_postinit)

Edited by AgainstMatter
Link to comment
Share on other sites

@AgainstMatter,

where did u put this, how do u use it and what error do u get?

i haven't done UI stuff in DST yet, but generally u need to rethink anything like that in DST, since UI and Playercontrols happen on the client, but actual stuff in the gameworld happens on the server, and u have to use RPCs and netvars to communicate that.

http://forums.kleientertainment.com/topic/47353-guide-getting-started-with-modding-dst-and-some-general-tips-for-ds-as-well/

Edited by Seiai
Link to comment
Share on other sites

local function sim_postinit(inst)    if (inst.prefab == "wynter") then        AddLeaveButton(inst)    endend AddSimPostInit(sim_postinit)

This causes the crash, because now all sim_postinits are called with the nil argument.

So inst is nil, and inst.prefab indexes a nil.

 

Use

AddPrefabPostInit("wynter", function(inst)	inst:DoTaskInTime(0.1, function()		if inst == GLOBAL.ThePlayer then			if (inst.prefab == "wynter") then				AddLeaveButton(inst)			end		end	end)end)
Link to comment
Share on other sites

local function sim_postinit(inst)    if (inst.prefab == "wynter") then        AddLeaveButton(inst)    endend AddSimPostInit(sim_postinit)

This causes the crash, because now all sim_postinits are called with the nil argument.

So inst is nil, and inst.prefab indexes a nil.

 

Use

AddPrefabPostInit("wynter", function(inst)	inst:DoTaskInTime(0.1, function()		if inst == GLOBAL.ThePlayer then			if (inst.prefab == "wynter") then				AddLeaveButton(inst)			end		end	end)end)

Thank you, That fixed the problem x3

Edited by AgainstMatter
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...