Page 1 of 1

Timer not working

Posted: Sun Jul 05, 2009 5:37 pm
by KnightsFan
I'm trying to make a timer which plays an animation after 3 seconds and it isn't working.

LUA pertaining to timer...

Code: Select all

target1_timer =  CreateTimer("target1_timer")
SetTimerValue(target1_timer, 3.0)
StartTimer(target1_timer)
OnTimerElapse(
function(timer)
PlayAnimation("target1_move")
DestroyTimer(target1_timer)
end,
target1_timer
)
BF log error...

Code: Select all

Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #2 on 'OnTimerElapse' (string expected, got nil)
stack traceback:
[C]: in function 'OnTimerElapse'
(none): in function 'OnStart'
(none): in function 'Start'
(none): in function 'Start'
(none): in function 'ActivateObjectSet'
(none): in function <(none):317>
Can anyone tell me what to do?

Re: Timer not working

Posted: Sun Jul 05, 2009 7:01 pm
by YaNkFaN
the .lua doesn't know when to start to look for a timer ie the player needs to be detected this is a copy of a working timer i made I edited to fit your needs just copy and paste this into your.lua and see if it works
Hidden/Spoiler:
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
ScriptCB_PlayInGameMusic("rep_fel_amb_obj1_3_explore")
start_timer = CreateTimer("start_timer")
SetTimerValue(start_timer, 2)
StartTimer(start_timer)
begin_objectives = OnTimerElapse(
function()

ReleaseTimerElapse(begin_objectives)
begin_objectives = nil
end,
start_timer
)
end

end)

SetTimerValue(target1_timer, 3.0)
StartTimer(target1_timer)
OnTimerElapse(
function(timer)
PlayAnimation("target1_move")
ShowTimer(nil)
end,
target1_timer
)

Re: Timer not working

Posted: Mon Jul 06, 2009 3:57 pm
by KnightsFan
Perhaps I should've mentioned that this is a campaign map and this timer starts within an objective.

I copied that stuff in, same thing happens. No crashes, but no Victory ever appears. Same Severity 3 error.

Re: Timer not working

Posted: Mon Jul 06, 2009 10:05 pm
by [RDH]Zerted
KnightsFan wrote:CallProc failed: bad argument #2 on 'OnTimerElapse' (string expected, got nil)
That is a bit strange. It's saying the target1_timer on the second to last line has the value nil. I'm not seeing why thats the case. Maybe it goes out of scope or because of the DestoryTimer()... Anyway, try referencing the timer by name instead of by the return value from CreateTimer(). I edited your code to reflect this:

Code: Select all

CreateTimer("target1_timer")
SetTimerValue("target1_timer", 3.0)
StartTimer("target1_timer")
OnTimerElapse(
    function(timer)
        PlayAnimation("target1_move")
        DestroyTimer("target1_timer")
    end,
    "target1_timer"
)
If that doesn't work, post your full error log.

Re: Timer not working

Posted: Tue Jul 07, 2009 11:59 am
by KnightsFan
I added the "s in (weird that the asset scripts don't use them) and now the Victory works. But still no animation playing. I just made sure the animations are there in ZE, BTW.

Re: Timer not working

Posted: Tue Jul 07, 2009 12:06 pm
by YaNkFaN
did you save the animation file in ZE? like a box comes up that says all's good here boss or something like that

Re: Timer not working

Posted: Tue Jul 07, 2009 2:23 pm
by KnightsFan
Yes, I saved.

Seems I forgot to post my error log before...
Hidden/Spoiler:
Opened logfile BFront2.log 2009-07-07 1153
shell_interface: Entered
shell_interface: Reading in custom strings
ifs_era_handler - Entered
ifs_era_handler - Exited
custom_GetSPMissionList()
custom_GetMPMissionList()
custom_EraButtonList(): Building era button table
custom_EraButtonList(): Finished building era button table Known eras buttons: 28
custom_GetGMapEras(): Building era table
custom_GetGMapEras(): Finished building era table Known eras: 28
custom_GetGMapModes(): Building game mode table
custom_GetGMapModes(): Finished building game mode table Known Modes: 38
custom_GetMPGameModeList(): Building game mode list table
custom_GetMPGameModeList(): Finished building game mode list table List Length: 39
custom_SetMovieLocation()
custom_AddEraBoxes()
custom_SetMovieLocation()
custom_AddEraBoxes()
ingame stream movies\crawl.mvs
shell_interface: Opening movie: movies\shell.mvs
shell_interface: Leaving
Found side\rvs.lvl. Adding ADS's extra missions
prev = none iLastPage = nil
prev = texture iLastPage = 1
prev = texture iLastPage = 2
prev = texture iLastPage = 3
ifs_legal.Exit

Message Severity: 2
.\Source\GameMovie.cpp(399)
Unable to find open movie segment shell_main

ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadProfile
ifs_saveop_DoOps LoadProfile
ifs_missionselect_pcMulti_fnSetMapPreview(): Defaulting index to 1
this.CurButton = check_mode10
cur_button = nil
Checkbox for check_era3 clicked
this.CurButton = check_era3
cur_button = nil
custom_AddMapNew()
custom_printTable(): table: 03CC116C
The key, value is: blue 0
The key, value is: mode_con_c 1
The key, value is: isModLevel 1
The key, value is: bSelected 1
The key is mapluafile, the formated value is: KMO<A>_<B>
The key, value is: era_c 1
The key, value is: green 128
The key, value is: era_g 1
The key, value is: mode_con_g 1
The key, value is: mode_c_c 1
The key, value is: red 0
custom_printTable(): Returning
custom_printTable(): table: 03CC66CC
The key, value is: key mode_con
The key, value is: subst con
The key, value is: showstr modename.name.con
The key, value is: descstr modename.description.con
The key, value is: icon mode_icon_con
custom_printTable(): Returning
gMapEras.key = era_c Era = era_c subst = c
Adding map: KMOc_c idx: 1
this.CurButton = _map_add
cur_button = nil
this.CurButton = Launch
cur_button = nil

Message Severity: 2
.\Source\HUDElementBitmap.cpp(380)
HUD BitmapElement unable to find texture hud_target_hint_offscreen

Message Severity: 2
.\Source\HUDElementBitmap.cpp(380)
HUD BitmapElement unable to find texture hud_target_hint_offscreen

Message Severity: 2
.\Source\HUDElementBitmap.cpp(380)
HUD BitmapElement unable to find texture btn_directional_pad_LR
game_interface: Reading in custom strings
ifs_sideselect_fnBuildScreen()
utility_functions2: Listening on AddUnitClass() calls
utility_functions2: Listening on SetHeroClass() calls

Message Severity: 2
.\Memory\RedMemoryPool.cpp(317)
Memory pool "ClothData" set item count after being allocated

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_hostile_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_bacta_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_mechanic_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_ammo_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_transport_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_backup_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_clear_area_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (rep1_inf_pc_com_defend_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Graphics\Pc\pcRedTexture.cpp(553)
Texture 'weap_inf_dc17pistol' [5271c6eb] uses 1.33 MB

Message Severity: 2
.\Graphics\Pc\pcRedTexture.cpp(553)
Texture 'weap_inf_dc17pistol' [5271c6eb] uses 1.33 MB

Message Severity: 2
.\Graphics\Pc\pcRedTexture.cpp(553)
Texture 'weap_inf_dc17pistol' [5271c6eb] uses 1.33 MB

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_hostile_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_bacta_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_mechanic_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_ammo_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_transport_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_backup_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_clear_area_inVehicle): unknown modifier "InVehicle"

Message Severity: 2
.\Source\VOHelper.cpp(183)
VOSound (cis1_inf_pc_com_defend_inVehicle): unknown modifier "InVehicle"
uf_updateClassIndex(): Added class: rep_inf_player_smg
uf_updateClassIndex(): Added class: rep_inf_player_rifle
uf_updateClassIndex(): Added class: rep_inf_player_lmg
uf_updateClassIndex(): Added class: rep_inf_player_minigun
uf_updateClassIndex(): Added class: cis_inf_b1droid

Message Severity: 2
.\Source\SkyManager.cpp(122)
Skyfile FarSceneRange is in old format

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(2523)
Timer "victoryTimer" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(2523)
Timer "delayTimer" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(2523)
Timer "dittyTimer" not found
release self.dittyTimerResponse
release self.dittyTimerResponse

Re: Timer not working

Posted: Tue Jul 07, 2009 10:55 pm
by [RDH]Zerted
Try pausing and rewinding the animation before you play it. If that doesn't work, reread the animation docs to see if you missed something.

Re: Timer not working

Posted: Wed Jul 08, 2009 11:47 am
by KnightsFan
The animation isn't the problem. It plays fine if I play it without the timer. Something is probably wrong with my timer code. I don't have to load up any external codes or anything, do I?