Jump to content

HELP PLEASE - Mission Writing with LUA - how to *set* properties?


Recommended Posts

So I've written my share of missions in ME and now I want to try my hand at some Lua scripting. Most of that stuff seems straightforward enough, and I've browsed the (thankfully provided) excellent "Simulator Scripting Engine Documentation". I'm still a bit shaky with Lua (the colon versus dot notation trips me up), but I've discovered that things that seemed impossible just yesterday are trivial today: output a warning when fuel is below a threshold.

 

Now, all these great frameworks (e.g. MIST - really nice!) all seemingly have something in common and I'm scratching my head if I've overlooked something that is blindingly obvious, but -- all these frameworks and accessors are getters only. Why are there no setters? I can get a unit by name just fine, and get it's health. But I can't change it directly. I wanted to script what I thought simple: get my plane, and simply top off the gas. I can get the fuel as a fraction say 0.7) with getFuel() just fine -- but there is no provision to setFuel(1.0) for a Unit. Nor is life. Or position. Or any other attribute.

 

Since these are quite fundamental properties, I'm thinking something of the following must be true

  • I'm an idiot, and changing a Unit's name, group, fuel, position or health attribute is so simple that nobody ever talks about it. Only total Lua n00bs don't know this.
  • From a scripter's vantage, all Unit's properties are immutable once they are created.  

 

So if there is a knowledgeable person here that can help and point me to the relevant documentation, I'd be very happy indeed. 

 

Thanks,

-ch

 

Link to post
Share on other sites

Just a word of warning: I once tried scripts many moons ago.. They were great-

However, My biggest problem with them, was having to fix them with every other new update that was released for the game that broke them.
Some werent reliable no matter how i approached them.

Times passed since that day- The orginal missions are all gone (replaced with good old scriptless one), and maybe there has been improvements, but the last thing i wanted to do as a mission designer was to constantly fix broken scripts to my missions. When there is usually a good work around, or an improvement made to the Mission Editor, that allows a similar solution without the maintainance.
I just moved away from them. But i understand others will move to them.
Id be interested to hear someone who IS an expert in them, and see if they are more reliable anymore or they do require maintainance..



 

Link to post
Share on other sites
1 hour ago, cfrag said:

...

  • From a scripter's vantage, all Unit's properties are immutable once they are created.  ...

 

 

Yes to this - almost. After unit creation you can still set options (like ROE...), commands (like comms/tacan...), but no physical properties except internal load mass for helicopters. Things like fuel, weapons, life are not modifiable outside ingame interaction (refuel/rearm/repair). (for what I know using DCS scripting functions)

Ex : see SET functions available under "S" letter Category:Scripting - DCS World Wiki - Hoggitworld.com

 

That said, maybe and very possibly you can achieve this kind of modification (on fuel, life, etc..) using lua functions MUSHclient documentation: lua_base (gammon.com.au)

but I can't help actually 🙂

  • Thanks 1
Link to post
Share on other sites

I try to keep the scripting engine documentation on the Hoggit wiki as up to date as possible. What you see in the functions category  is what exists for the scripting engine. The same applies to tasks in terms of what AI can be assigned to do. 

13 hours ago, cfrag said:

I'm still a bit shaky with Lua (the colon versus dot notation trips me up), but I've discovered that things that seemed impossible just yesterday are trivial today: output a warning when fuel is below a threshold.

 

 

It applies to "class" functions where the first value that would be passed is the object. Its easiest to understand if the function has multiple input values. 

 

local gp= Group.getByName('whatever')

Group.getUnit(gp, 3) and gp:getUnit(3) are the same thing. 

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...