Community Forum

Levitator FS19conversion

Forum Overview >> Scripting

CategoryScripting
Created10.03.2020 16:13


Peter Farmer (zippyo) 10.03.2020 16:13
please be gentle with me still just getting my feet wet.

setLinearDamping(self.components[1].node, 0.18); WILL NOT WORK but the table is valid

setLinearDamping(self.components.1.node, 0.18); THIS WORKS IN DEBUGGER ie fetches right value from table BUT ENGINE MOANING about malformed number

same with
(self.spec_workArea.workAreas[1].width NIL

(self.spec_workArea.workAreas.1.width ok in debugger but malformed number.......good feeling gone


benn tinkering with this see thread: https://forum.giants-software.com/viewtopic.php?f=895&t=109061 for aerial application of liquids and solids
this is making me go nutz. please help

(bilbo please go easy on me mate, i promise i've been reading a lot 'round here)

zip

Bilbo Beutlin (BBeutlin) 10.03.2020 19:42
*g* I'd suggest, you read a little in the LUA tutorials about table handling, eg. here: https://www.lua.org/pil/2.5.html
For a construct like "a.b[n].c" you need an indexed table.

Use
local component = self.components[1]
setLinearDamping(component.node, 0.18)

Peter Farmer (zippyo) 11.03.2020 20:48
your kindness is admirable mate...been trying to wrap my head around all this ,,, maybe not very smoothly...still coming along unexpectedly well.
having said that, scope may be another hurdle here
when tracing into myModScript:onLoad i get self with 745 members and all is humming along
then breaking on another function self is populated with 27 excluding self.components ... I could use an explanation on what and why is going on here in a "gentle" but concise Bilbo kinda way ;)

Thank you

zip

Peter Farmer (zippyo) 14.03.2020 16:27
Having my silly issues sorted with the debugging environment I now have the FS17 Levitator script converted and functional in FS19. Trivial your info may have been Bilbo but it was the catalyst to all this weight lifting with my brain. Hoping someone else did this was futile so I went head first into the unknown.
of course there is a lot more and I'm sure I'll be back to get sum more guidance
once again

Thank You Bilbo for making me think I could


William Watkins (Watkins) 15.08.2020 09:37
you are saying you have the key to helicopters?

im just breaking through the first layer of functional xml creation, modification, blender-ing, chop shopping models and realizing the almost super power level content creation/integration possibilities. But once you get nice and internet famous among the fs19 mod community with that script - and rightfully.

Will you show me so I can attempt to rebuild my favorite vehicle of fs17, and maybe pull off one of the long term goals I originally set when embarking upon this quarantine induced semi educational jaunt into coding & modelling; to convert the gryphon heli - logging chopper for the forestry folks?

I was explicitly told by some seemingly knowledgeable people that because that levitate script couldnt be converted - we'd never have helicopters. But I just assumed that once i could tear the engine apart and watch it work for a bit - id find a way around that never.

Or maybe can I help you build a helicopter or whatever you are gonna do with that script?

Peter Farmer (zippyo) 15.11.2020 22:05
William I can explicitly tell You the levitator script IS converted and working in FS19.
so don't give up on realizing those possibilities

zip

David Zadnik (DzInLa) 28.12.2020 18:16
Hello Zippyo

Keep up the good work


Hello Watkins,

Check out Sketchfab website. Search "S-64", but be sitting down before hand. All cockpit gauges are 3d.




Peter Farmer (zippyo) 16.05.2021 16:50
Hi Bilbo!

How would i get variable for RPM at runtime for a rotating part animated in XML AnimatedParts tags?

zip

Bilbo Beutlin (BBeutlin) 17.05.2021 02:27
You must read the value of rotation each update() or onUpdate() cycle, eg. by
local rx, ry, rz = getRotation(transformId)
The values are in radians (not degrees), so a full turn is 2*Pi = 6.283185.
Since the values migth be negative, add 2*Pi.
Store the desired value in a static variable to get the difference between two update cycles, eg. "myMod.lastRot".
The update(dt) parameter 'dt' gives you the time since last update cycle in ms.

Now you can calculate
local rotFrac = math.abs(rot - myMod.lastRot) / 6.283185 -- rotation fraction
local rotPerMilliSec = rotFrac / dt -- rotation per millisecond
local rotPerMinute = rotPerMilliSec * 1000 * 60 -- rotation per minute

Peter Farmer (zippyo) 17.05.2021 14:49
Thank You Bilbo!
I had a feeling it'll be the way. I have the Rotation onupdate in rads, but I would have loved the physics engine to do the work and just getAngularVelocity from it but when I make the object kinematic or dynamic the friggin thing falls through the helicopter. Any thoughts on collisions maybe?
Also as I walk the i3d hierarchy in the scenegraph, it ends up with a whole bunch of other children at runtime appended to it.whats that all about?

Thank You for your unhindered will to help us in finding our ways mate!

zip

Bilbo Beutlin (BBeutlin) 17.05.2021 16:27
The type 'dynamic' will most probably cause problems with the physics engine.
If you want to give it a try, you could define the object as 'compound'. Or make it as separate main component and assemble in xml <base>.

However 'kinematic' should work. All vehicle triggers are kinematic, but must be 'compound' then.

You could also try 'compoundChild'. This is often used for auxiliary collision boxes. You cannot select this directly in editor, but add the attribute compoundChild="true" in the xml/text format.

For setup of other properties look into default vehicle i3d's. Use Notepad++ "search in files" to get examples.


I've no idea what you mean with "bunch of other children at runtime appended". Do you mean ingame? or editor?
All I know is, the GE (xml parser) gets confused by 'illegal' characters in labels (or filenames). The parser expects "A-Z", "a-z", "1-0" and '_' (underscore) instead spaces. All other can lead to unexpected behaviour upto crashes.
Just unexperienced modders often use their language specific special chars - that's very dangerous.

Peter Farmer (zippyo) 18.05.2021 19:08
some of this stuff still eludes me .... but all is well with the RPM calculation from rot as non rigid!
dynamic compound child would gimme getAngularVelocity but the part jitters in place not rotating so AVxyz is 0. Kinematic stuff just gives me nil for getAV. maybe sum collision masking issues?

the other topic: it is happening at runtime ingame. guessing its the loader appending transforms to the model for effects etc?

zip

Bilbo Beutlin (BBeutlin) 18.05.2021 19:48
Yes - some stuff is appended ingame, like effects, particle sources, .. and also external wheels, shared lights, etc.

Peter Farmer (zippyo) 31.05.2021 19:43
Hello Bilbo!

Treading new ground again so I figured I may need sum pointers....

I would like to make changes to how the engine handles playing sounds during motor starter sounds to incorporate pre start sounds for an inertial starter.
I have copied the motorized:startMotor into myMod:myFunc
then in myMod:onLoad I put

orig. func = utils.overwrittenFunction(orig.func, myfunc)
I traced into the call but with no source I only get the passed arguments (which check out), and on startMotor I break in myFunction

Now does this mean I can make changes in the code exclusively for my mod?
Before I make a mess of everything I thought i should ask.

Thank You

Bilbo Beutlin (BBeutlin) 31.05.2021 21:11
No - the 'Utils.overwrittenFunction()' does a global overwriting.
If you want to do some special stuff for your mod exclusively, you must check this at first. Then you can branch to normal or custom code. Alternatively, for minor changes, you can setup a flag and execute code sections accordingly.

Peter Farmer (zippyo) 10.06.2021 15:43
Greetings....

Maybe not so Bilbo? Just getting back to it I had a test run quick with other vehicles and my vehicle with the script and only mine breaks in my script. All others start without touching off my breakpoint. It would seem the Utils.overwrittenFunction just remaps the function entrypoint to my script?
Either way I'm gonna fiddle with it a bit more to make sure but it looks like what I'm after, unless I'm too thick to understand something important.

whats the diff between register overwrittenfunctions and this?

thanks

zip

Bilbo Beutlin (BBeutlin) 10.06.2021 17:29
The debugger breakpoints affect only the script which is defined explicitely in the breakpoints list.
Perhaps you should better try a debug 'print()' in your code to see if it becomes executed.

Concerning 'registerOverwrittenFunction()' I'm not sure. But I think it is a fallback at serious errors or used for superFunc().

Matthew Keast (Keastey3) 07.07.2022 01:58
Hey Peter, I was wondering how hard it would be to add sideways movement to the Levitation.lua script?


Note: Log in to post. Create a new account here.