Jump to content

Recommended Posts

I'm trying to make a radiation component that, as you get irradiated (variable gets closer to 0) your maximum health goes down. I've been using console commands to change the variable number but nothing's been happening. I'm stumped. Any help?

Mod.zip

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

ConsoleCommandPlayer().components.rads:SetPercent(n)

 

Where n was replaced with whatever number I wanted to test out. Anywhere from 0 to 0.5 to 1.

 

Also, how would I edit the player_common and classified otherwise?

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 :)

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

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

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)

 

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