IAS2424 Posted September 8, 2016 Posted September 8, 2016 Getting into scripting, starting to apply what I've learned. I'm trying to get a simple script to work using triggers in game. Currently trying to get a message to display on screen using the getTime0 and getAbsTime functions. Logic is as follows: if timer.getAbsTime() - timer.getTime0() > 20 then return true end Can someone please tell me whats wrong? I basically copied what was on hoggit wiki but its still not working. Picture of trigger attached.
nomdeplume Posted September 8, 2016 Posted September 8, 2016 What's it doing or not doing? Are you getting any errors, either in-game popups or in dcs.log? I'm pretty sure the lua predicate is expected to always return true or false. You're only returning true if the condition is met, and nothing if it isn't, which might be interpreted as nil or just as an error. So you could try: if timer.getAbsTime() - timer.getTime0() > 20 then return true else return false endor more succinctly: return timer.getAbsTime() - timer.getTime0() > 20 Also, I think the calculation you're doing is the same as the model time, so timer.getTime() would return the same value, or you could just use a "Time more (20)" trigger condition.
IAS2424 Posted September 8, 2016 Author Posted September 8, 2016 I tried both of those, still didn't work. I could use the 'Time more' condition, but I want to learn scripting so I can start to use MIST etc. When I mean it doesn't work, I mean that the message pop-up isn't showing when it is supposed to. No errors or anything.
nomdeplume Posted September 8, 2016 Posted September 8, 2016 Strange... I'll do some more testing after work, I do a lot of scripting in the game but almost never use the lua predicates - tend to just use 'standalone' scripts and use flags to trigger actions via the triggers list. You could try making it as simple as possible: return true and see if that works as expected (you should get the text message right after the mission starts).
IAS2424 Posted September 8, 2016 Author Posted September 8, 2016 Strange... I'll do some more testing after work, I do a lot of scripting in the game but almost never use the lua predicates - tend to just use 'standalone' scripts and use flags to trigger actions via the triggers list. You could try making it as simple as possible: return true and see if that works as expected (you should get the text message right after the mission starts). Unfortunately, that doesn't work either. I'm assuming that lua predicate is broken atm, and just stick to scripting externally and use flags.
nomdeplume Posted September 8, 2016 Posted September 8, 2016 Yep you're right, it seems to be bugged - probably from the localisation changes. The actual code written to the .miz file is: ["conditions"] = { [1] = "return(c_predicate(getValueDictByKey(\"\")) )", }, -- end of ["conditions"]The call to getValueDictByKey() is passed an empty string, so this fails to do anything useful. The localisation dictionary doesn't contain anything that looks like my predicate code, anyway. A normal condition (e.g. flag is true) just has the function directly in there: [2] = "return(c_flag_is_true(1) )",so my guess is it's erroneously writing out a dictionary lookup for the string rather than embedding the code directly.
Stonehouse Posted September 8, 2016 Posted September 8, 2016 Not sure that it is working at present. In the 1.5 beta thread it is still listed as an open scripting issue. https://forums.eagle.ru/showthread.php?t=147792
Quax456 Posted September 9, 2016 Posted September 9, 2016 If I remeber correctly, the LUA PREDICATE fumction within the ME is bugged! So it doesnt work! This is the last information I have. My Rig: Windows 11 Pro, Intel i7-13700k@5.4GHz, 64GB DDR5 5200 RAM, Gigabyte Z790 AORUS Elite AX, 2TB Samsung 990 PRO, RTX4080, Thrustmaster HOTAS WARTHOG Stick + WINWING ORION 2 + MFG Crosswinds, LG 32" 4K 60FPS, ACER 30" 4K 60FPS GSync Display, HP Reverb G2 V2
kontiuka Posted September 25, 2016 Posted September 25, 2016 If I remeber correctly, the LUA PREDICATE fumction within the ME is bugged! So it doesnt work! This is the last information I have.nuts. been trying for an hour to get this to work. and it's broken. :cry:
Recommended Posts