Jump to content

[require help]about the screen and container

Recommended Posts

I want to add a lock for treasurechest .Click the treasurechest then push a password screen.


First: I write  into  the modmain.lua

local 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  this

local 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(*.*)




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
Share on other sites

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

  • Create New...