Jump to content

Help with component on client machines


Recommended Posts

Hi all,

 

I am trying to update one of Heavenfall's old mod for DST. I have it working except for the action and display. Nothing happens when you press right click and there is no edited text on the tootip. I think the answer lies somewhere here in the modmain:

local MAGNIFYIDENTIFY = GLOBAL.Action({rmb = true})MAGNIFYIDENTIFY.str = "Identify"MAGNIFYIDENTIFY.id = "MAGNIFYIDENTIFY"MAGNIFYIDENTIFY.fn = function(act)	if act.target and act.target.components.rpgweapon and act.target.components.rpgweapon.discovered == false and act.invobject and act.invobject.components.magnifyidentify then		return act.invobject.components.magnifyidentify:DoIdentify(act.target, act.doer)	end	if act.target and act.target.components.rpgarmor and act.target.components.rpgarmor.discovered == false and act.invobject and act.invobject.components.magnifyidentify then		return act.invobject.components.magnifyidentify:DoIdentify(act.target, act.doer)	endendAddAction(MAGNIFYIDENTIFY)local function magnifyid (inst, doer, target, actions, right)	if target.components.rpgweapon and target.components.rpgweapon.discovered == false and target.components.rpgweapon.currenttype ~= "nonmagic"  then        table.insert(actions, ACTIONS.MAGNIFYIDENTIFY)    end    if target.components.rpgarmor and target.components.rpgarmor.discovered == false and target.components.rpgarmor.currenttype ~= "nonmagic" then        table.insert(actions, ACTIONS.MAGNIFYIDENTIFY)    endendAddComponentAction("USEITEM", "magnifyidentify", magnifyid)

I am sure I am doing something wrong here. Any advice is greatly appreciated.

 

Thanks in advance,

 

Prof

Edited by ProfFarnsworth
Link to comment
Share on other sites

Are rpgweapon and rpgarmor server-only components? (that's what I'd suspect, because they should be)

 

If so, instead of checking for the component and its attributes, use the component to tag the item, e.g. with "unidentified", and have the magnifying glass action check for that.

Link to comment
Share on other sites

Are rpgweapon and rpgarmor server-only components? (that's what I'd suspect, because they should be)

 

If so, instead of checking for the component and its attributes, use the component to tag the item, e.g. with "unidentified", and have the magnifying glass action check for that.

 

To make sure they are server only is done in the modmain correct? I tried using:

if not GLOBAL.TheNet:GetIsServer()thenreturnend

before the components and prefabs in the modmain, but it threw up a slew of errors. Would I add the PrefabPostInit to each object on all clients as well, then just the components to the server? The modmain and component files are attached for completeness.

 

Thanks for the help.

modmain.lua

rpgarmor.lua

rpgweapon.lua

magnifyidentify.lua

Edited by ProfFarnsworth
Link to comment
Share on other sites

@ProfFarnsworth, No, it would be a TheWorld.ismastersim check in the prefab files for those objects themselves, before they add the rpgweapon/rpgarmor components.

 

Edit: Oh, it's being done with postinits. So... yeah, you wouldn't want that postinit to run on clients.

Edited by rezecib
Link to comment
Share on other sites

@ProfFarnsworth, No, it would be a TheWorld.ismastersim check in the prefab files for those objects themselves, before they add the rpgweapon/rpgarmor components.

Edit: Whoops too quick. I'll try the check again before the postinit's and components and see if I can narrow down the crash.

Edited by ProfFarnsworth
Link to comment
Share on other sites

@ProfFarnsworth, No, it would be a TheWorld.ismastersim check in the prefab files for those objects themselves, before they add the rpgweapon/rpgarmor components.

 

Edit: Oh, it's being done with postinits. So... yeah, you wouldn't want that postinit to run on clients.

 

Using TheWorld.ismastersim in the modmain caused a crash indicating that "TheWorld" is undefined, but doing it with TheNet:IsServer seemed to pass through ok. However, with it all behind the server it seems that nothing is getting added to any of the items.

 

I tried removing the equippable and inventoryitem checks from the components but no luck. I feel like it is something simple since it worked for a hosted game, but not dedicated.

 

Any ideas?

Link to comment
Share on other sites

I have just started looking into custom actions, so I'm not sure what this means, but in other mods I saw

AddStategraphActionHandler("wilson", ActionHandler(...))
followed by

AddStategraphActionHandler("wilson_client", ActionHandler(...))
Link to comment
Share on other sites

@ProfFarnsworth, TheWorld is in the GLOBAL space which is protected from the modmain sandbox. So GLOBAL.TheWorld. But I think you're probably right that using TheNet is safer, as TheWorld might not have been created yet when the modmain runs. But you want TheNet:GetIsServer().

 

@Muche, What this does is tie the action into an animation for the player, like the picking animation. Technically speaking it pushes the player into a particular state in the stategraph, which I guess could be used for other purposes but is usually just to manage some animation.

Link to comment
Share on other sites

@ProfFarnsworth, TheWorld is in the GLOBAL space which is protected from the modmain sandbox. So GLOBAL.TheWorld. But I think you're probably right that using TheNet is safer, as TheWorld might not have been created yet when the modmain runs. But you want TheNet:GetIsServer().

 

@Muche, What this does is tie the action into an animation for the player, like the picking animation. Technically speaking it pushes the player into a particular state in the stategraph, which I guess could be used for other purposes but is usually just to manage some animation.

 

No matter what I try once I have the server check the component is not getting added to any items. If I remove the server check, it crashes checking for the equippable component so I am not sure why checking for the server makes nothing happen at all. In theory it should still add the prefabpostinit to everything.

 

But I am at a loss, and very tired, so I will come back to it unless you can think of anything else.

 

Thanks as always.

Link to comment
Share on other sites

I took a look and got it mostly working.

As a base I used your RPG Items Test Branch v1.18 .

Things I learnt and changes they caused:

As rezecib said, components are mostly server-only, replicable components exist but are more complex; added server check in modmain.

Actions run on the server, component actions on the client, together with point above, component actions don't have access to components and usually rely on tags; replaced component checks with unindentified tag, added basic tag adding & removing in components.

wilson stategraph controls player's options on the server, wilson_client on the client.

I got crash in RPGArmor:dappernesspassivemod, possibly due to incorrect DLC detection, didn't investigate further, just commented it out.

I got crash when loading panflute, commented it out.

As for dynamically changing name on the client (i.e. postfixed (?) / prefixed name), I think you'd need to use named component, see for example Personal Chesters mod.

RPGItemsTestBranch-v118a.zip

Edited by Muche
Link to comment
Share on other sites

I took a look and got it mostly working.

As a base I used your RPG Items Test Branch v1.18 .

Things I learnt and changes they caused:

As rezecib said, components are mostly server-only, replicable components exist but are more complex; added server check in modmain.

Actions run on the server, component actions on the client, together with point above, component actions don't have access to components and usually rely on tags; replaced component checks with unindentified tag, added basic tag adding & removing in components.

wilson stategraph controls player's options on the server, wilson_client on the client.

I got crash in RPGArmor:dappernesspassivemod, possibly due to incorrect DLC detection, didn't investigate further, just commented it out.

I got crash when loading panflute, commented it out.

As for dynamically changing name on the client (i.e. postfixed (?) / prefixed name), I think you'd need to use named component, see for example Personal Chesters mod.

attachicon.gifRPGItemsTestBranch-v118a.zip

 

Wow thanks so much! I have it working pretty well now. Except it's displaying some of the text twice. I will be updating the main version with this one and would be happy to add you as an author. Just friend me on steam to accept the invite.

 

Thanks again! Happy to have this in my game again.

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