AgainstMatter Posted June 9, 2015 Share Posted June 9, 2015 (edited) 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) endend AddSimPostInit(sim_postinit) Edited June 9, 2015 by AgainstMatter Link to comment https://forums.kleientertainment.com/forums/topic/55014-works-in-ds-but-not-dst/ Share on other sites More sharing options...
Seiai Posted June 9, 2015 Share Posted June 9, 2015 (edited) @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 June 9, 2015 by Seiai Link to comment https://forums.kleientertainment.com/forums/topic/55014-works-in-ds-but-not-dst/#findComment-645493 Share on other sites More sharing options...
DarkXero Posted June 9, 2015 Share Posted June 9, 2015 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. UseAddPrefabPostInit("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 https://forums.kleientertainment.com/forums/topic/55014-works-in-ds-but-not-dst/#findComment-645545 Share on other sites More sharing options...
AgainstMatter Posted June 9, 2015 Author Share Posted June 9, 2015 (edited) 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. UseAddPrefabPostInit("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 June 9, 2015 by AgainstMatter Link to comment https://forums.kleientertainment.com/forums/topic/55014-works-in-ds-but-not-dst/#findComment-645600 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now