ActivateObject()/DeactivateObject()
Moderator: Moderators
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: ActivateObject()/DeactivateObject()
I can't tell because you didn't post your exact, full code, but what you posted won't run because FreezeFor isn't defined before you use it. Also, put print() statements throughout your code to determine where it fails.
-
MasterSaitek009
- Black Sun Slicer
- Posts: 619
- Joined: Wed Aug 23, 2006 4:10 pm
Re: ActivateObject()/DeactivateObject()
Sorry 'bout that.
Here's how it's setup in the Lua
And I was wrong about it not working at all. It usually works once. But sometimes it doesn't work at all.
Here's the log for when it worked once.
Here's how it's setup in the Lua
Code: Select all
function ScriptPostLoad()
EnableSPHeroRules()
OnObjectDamage(
function(object, damager)
if GetObjectTeam(object) == DEF then return end
if GetCharacterTeam(damager) == DEF then
if GetCharacterClass(damager) == 1 then
print("check 1")
FreezeFor(object, 2)
print("check 2")
end
end
end
)
hunt = Objective:New{textDEF = "level.cor1.objectives.hunt.def", textATT = "level.cor1.objectives.hunt.att",}
hunt.OnStart = function(self)
AddAIGoal(ATT, "Deathmatch", 1000)
AddAIGoal(DEF, "Deathmatch", 1000)
end
hunt_timer = CreateTimer("hunt_timer")
SetTimerValue(hunt_timer, 300)
StartTimer(hunt_timer)
victory = OnTimerElapse(
function(timer)
MissionVictory(DEF)
ReleaseTimerElapse(victory)
end,
hunt_timer
)
ShowTimer(hunt_timer)
hunt:Start()
end
function FreezeFor(object, timercount)
print("check 3")
--Freeze
health = GetObjectHealth(object)
SetProperty(object, "CurHealth", 1000000)
DeactivateObject()
-- Wait for timercount
print("check 4")
timer2 = CreateTimer("timer2")
SetTimerValue(timer2, timercount)
StartTimer(timer2)
uf = OnTimerElapse(
function(timer)
print("check 5")
--Unfreeze
ActivateObject()
print("check 6")
SetProperty(object, "CurHealth", (GetObjectHealth(object) - 1000000) + health)
print("check 7")
end,
timer2
)
end
Here's the log for when it worked once.
--First use of the weapon: Worked
check 1
check 3
check 4
check 2
check 5
check 6
check 7
--Second use of the weapon: CTD
check 1
check 3
check 4
check 2
check 5
check 6
check 7
check 5
check 6
check 7
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: ActivateObject()/DeactivateObject()
This is more what I meant. Theres no reason to store a timer in a variable. Reread the timer docs. You aren't fully understanding how the timer functions work. In my last post, by variable I meant the timer's name.
Hidden/Spoiler:
-
SergeantShade
Re: ActivateObject()/DeactivateObject()
i wasnt even sure it was 'Freeze', thats how dann's jail cell came into action isnt it?
Though, I'm curious to know how the mustafar bridge works. It has animations, regions, scripts, and a whole bunch of stuff i still dont understand.
Though, I'm curious to know how the mustafar bridge works. It has animations, regions, scripts, and a whole bunch of stuff i still dont understand.
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: ActivateObject()/DeactivateObject()
Don't feel stupid, you probably know it as well or better than anyone short of Zerted. People aren't asking questions not because they know it well, but because most, I think, are intimidated by it.MasterSaitek009 wrote:I feel kind of stupid being the only person asking questions about Lua.
I really enjoy seeing questions I can learn stuff from.
- AceMastermind
- Gametoast Staff

- Posts: 3285
- Joined: Mon Aug 21, 2006 6:23 am
- Contact:
Re: ActivateObject()/DeactivateObject()
My interest in this game is fairly simple, i'm an old fashioned conquest kind of guy, but I do take notes on whatever you guys discuss just incase one day I may need to know something, but I really have no use for advanced scripting so far.
-
MandeRek
- Sith Master

- Posts: 2766
- Joined: Tue Oct 02, 2007 10:51 am
- Projects :: Battlefront Zer0
- xbox live or psn: No gamertag set
- Location: Ghosting around GT
- Contact:
Re: ActivateObject()/DeactivateObject()
Off-topic: I really agree with Ace, especially since conquest can be sooo fun with a lot of new models and weapons to explore...AceMastermind wrote:My interest in this game is fairly simple, i'm an old fashioned conquest kind of guy, but I do take notes on whatever you guys discuss just incase one day I may need to know something, but I really have no use for advanced scripting so far.
