Okay, apparently I was wrong - the OnUpdate runs even when the object hasn't been "updated." (Either that, or there's an update I don't know about).
Here's the new source, which should work Phoenix Risingさま, for I have tested it this time:
require("PGStateMachine")function Definitions() Define_State("State_Init", State_Init) Define_State("State_Controlled", State_Controlled)endfunction State_Init(message) if message == OnEnter then Object.Disable_Capture(false) elseif message == OnUpdate then faction = Object.Get_Owner().Get_Faction_Name() if faction == "REBEL" or faction == "EMPIRE" or faction == "UNDERWORLD" then Set_Next_State("State_Controlled") end endendfunction State_Controlled(message) if message == OnEnter then Object.Disable_Capture(true) endend
Basically like the source in SecondaryHeavyFactory.lua and SecondaryMiningFacility.lua.
Just a note when you test it - if it reverts back to Neutral control, it means the player hasn't fully captured it; I didn't remember that and almost thought it didn't work.
Also, if the game crashes, can you tell me? I'm debugging right now, and it usually crashes during skirmish. I'm trying to narrow down the problem, so it'd help if you verified this for me, if it's not too much trouble. (Though, knowing you, I think you'd tell me anyway.
)
Oh and sorry for the double posting - I think the reason why I double posted is pretty obvious.
EDIT: Okay... this'll work even better:
<Ownership_Sticks>Yes</Ownership_Sticks>. I found it in SecondaryStructures.xml... try that...
Edited by Drieick, 17 February 2008 - 08:04 AM.