Jump to content

Need Lua Predicate Help!


IAS2424

Recommended Posts

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.

Screen_160907_204438.thumb.jpg.e7413df4b6f2ab46de8d10dfe66b0804.jpg

Link to comment
Share on other sites

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
end

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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, 1TB Samsung EVO 970, RTX4080, Thrustmaster HOTAS WARTHOG + Saitek Pro Flight Pedals, LG 32" 4K 60FPS, ACER 30" 4K 60FPS GSync Display, HP Reverb G2 V2

Link to comment
Share on other sites

  • 3 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...