czfshineself Posted January 17, 2015 Share Posted January 17, 2015 I want to add a lock for treasurechest .Click the treasurechest then push a password screen. First: I write into the modmain.lualocal MMScreen=GLOBAL.require("screens/mmscreen")local function PostInit(inst) (...) local function onopenmm (inst,data) (...) TheFrontEnd:PushScreen(MMScreen()) print("open") (...) endinst:ListenForEvent("onopen", onopenmm) endAddPrefabPostInit('treasurechest',PostInit)This code in the Host no problem, but in Client open the treasurechest, show screen in Host instead of Client............... Then, I see the Gesture Wheel mod,because this mod that according to what I know only can add some widget into the HUD. So, the new modmain.lua like thislocal MMScreen = require("widgets/MMScreen")(...)local function ShowMMScreen(can,doer,first) (...) controls.MMScreen:Show()endlocal function AddMMScreen(self) controls = self controls.MMScreen= controls:AddChild(MMScreen()) (...) GLOBAL.TheInput:AddKeyDownHandler(ToggleButton, ShowMMScreen)endAddClassPostConstruct( "widgets/controls", AddMMScreen )local function PostInit(inst) local function onopenmm (inst,data) .... controls.MMScreen:Show() end....inst:ListenForEvent("onopen", onopenmm)endAddPrefabPostInit('treasurechest',PostInit)This in Host no problem, in Client down key no problem too , but open the treasurechest ,the MMScreen show in the Host(*.*) WHY!!!?? Never yield in spite of reverses.~~~~~ Then I readed 'container.lua' ,Discover open the treasurechest at the same time show the "containerwidget".As long as the increase of my MMScreen to the containerwidget,it can show. The modmain.lua III →.→:local MMScreen=GLOBAL.require("widgets/mmscreen")...local function addMM(self) self.MMSRC=MMScreen controls = self function self:ADDmm() self.MM = controls:AddChild(self.MMSRC()) ... end self.oldRefresh=self.Refresh function self:Refresh() self:oldRefresh() if not self.MM then self:ADDmm() if not self.container.components.container.classified.MM then --MM like password --Don't ask me why I did this.Because to don't so in the host can not run self.MM:Setting(self.container.components.container,self.container.components.container.opener,true) else self.MM:Setting(self.container.components.container,self.container.components.container.opener,false) end end endendAddClassPostConstruct( "widgets/containerwidget",addMM)This code run in the Client,is error,it say the "container is a nil indix " How can I do can success run? Provided by the google language translation, thank you! Link to comment https://forums.kleientertainment.com/forums/topic/49294-require-helpabout-the-screen-and-container/ Share on other sites More sharing options...
rezecib Posted January 18, 2015 Share Posted January 18, 2015 @czfshineself, Unfortunately getting this to work as a client will be difficult. I think you will probably need two things: a custom action that can be performed on your locked chests (I went over custom actions in my guide, hopefully translation will help there ). The second part will be custom networking-- this will be the harder part, because you need to handle both the pushing of the screen on the client (I think all this needs is a net_event), but also the sending of the password from the client to the server. Client -> server communication is a bit difficult to mod right now, and essentially involves hijacking the action system, I believe. Link to comment https://forums.kleientertainment.com/forums/topic/49294-require-helpabout-the-screen-and-container/#findComment-603269 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