Jump to content

Custom Component - Not crashing, but not doing anything


Recommended Posts

I mean which command did you type in the console? I don't really want to go through the complete mode scripts to figure it out by myself so if you said what you tried exactly that will make it faster...

EDIT: also I just realized you copied player_common and player_classified in your mod to override them and simply put: never do that. That's the worse thing you can do. It makes your mod incompatible with any mod modifying these 2 prefabs.

Edited by ZupaleX
Link to comment
Share on other sites

You should use the provided functions

AddPrefabPostInit

AddComponentPostInit

AddClassPostConstruct

etc...

Check out the stickied post on this forum, there is a mod API example linked several times which explains how to use the different functions :)

Link to comment
Share on other sites

Aaand, now it doesn't even recognize rads as a value. 

Spoiler

[00:01:55]: Validating portal[3] <-> <nil>[3] (inactive)    
[00:01:55]: Validating portal[4] <-> <nil>[4] (inactive)    
[00:01:55]: Validating portal[5] <-> <nil>[5] (inactive)    
[00:01:55]: Validating portal[6] <-> <nil>[6] (inactive)    
[00:01:55]: Validating portal[7] <-> <nil>[7] (inactive)    
[00:01:55]: Validating portal[8] <-> <nil>[8] (inactive)    
[00:01:55]: Validating portal[9] <-> <nil>[9] (inactive)    
[00:01:55]: Validating portal[10] <-> <nil>[10] (inactive)    
[00:02:00]: Spawn request: wilson from [Host] Eusong
[00:02:00]: Skin request: (wilson_none) () () () ()
[00:02:00]: Spawning player at: [Fixed] (22.00, 0.00, -470.00)    
[00:02:00]: Serializing user: session/6A1B7EA8DC588285/A7LALADL9EHB/0000000003
[00:02:00]: Deserializing tile data (425 x 425)

[00:02:09]: [string "ConsoleCommandPlayer().components.rads:SetP..."]:1: attempt to index field 'rads' (a nil value)
[00:02:21]: unloading prefabs for mod MOD_Fallout - Unfinished    
[00:02:21]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:02:21]: Collecting garbage...
[00:02:21]: lua_gc took 0.23 seconds
[00:02:21]: ~ShardLuaProxy()
[00:02:21]: ~ItemServerLuaProxy()
[00:02:21]: ~InventoryLuaProxy()
[00:02:21]: ~NetworkLuaProxy()
[00:02:21]: ~SimLuaProxy()
[00:02:21]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:02:22]: lua_close took 0.42 seconds
[00:02:22]: ModWorkshop::CancelDownloads clearing all unfinished downloads
[00:02:22]: [Steam] Auth ticket cancelled
[00:02:22]:  Manager - ORPHANED UNKNOWN RESOURCES:
[00:02:22]: shaders/ui_yuv.ksh - 1
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:22]: Orphaned unnamed resource. This resource must have used Add( resource ) to insert itself into the manager. 
[00:02:23]: CurlRequestManager::ClientThread::Main() complete
[00:02:23]: HttpClient2 discarded 0 callbacks.
[00:02:23]: Shutting down

 

 

 

Mod.zip

Link to comment
Share on other sites

You misunderstood how to use the Add[...]PostInit

These functions are here to add functionality to existing prefabs and components. Calling AddComponentPostInit("rads", "player_common") makes no sense beause it means that you want to add to the components Rads a string "player_common".

If you look at the doc I directed you to concerning these functions you will see that it is

AddComponentPostInit("cmponent_to_modify", function)

 

For instance here you want to add the component Rads to the player_common so that should look like

AddPrefabPostInit("player_common", function(inst)
	if TheWorld.ismastersim then
		inst:AddComponent("rads")
	end
end)

From there you should be able to do the rest the same way

Link to comment
Share on other sites

I always forget that player_common is special.

This would work for basically any other prefab but to add something to all the player entities, use

AddPlayerPostInit(function(inst)
	if TheWorld.ismastersim then
		inst:AddComponent("rads")
	end
end)

 

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