Page 3 of 5

Re: models then what?

Posted: 29 Dec 2009, 01:47
by FLOZi
Note that there are 4 types of lua (well, actually, there are more, but there are 4 main types for a fresh-out-the-box modder to concern themselves with) :wink:
  • Gadgets - (Mostly) Synced code, these implement your own game logic, they go in LuaRules/Gadgets directory.
  • Widgets - (Mostly) Unsynced code, generally UI elements and related things (like formation move orders), they go in LuaUI/Widgets directory.
  • Animations - These are unit animations, a new addition to replace the old TA BOS/COB animations, they go in Scripts directory (well, that is the de facto standard).
    N.B. lua animations are actually in 'gadget space' by which I mean they have access to the same callouts as gadgets which lets you do some nifty things once you know what you're doing and is why lua anims are superior to BOS/COB
  • Defs - Weapon, features and unit defs, go in Weapons, Features and Units directories respectively, these are just a big table of tags which control your unit and weapon attributes.
    (N.B. It is quite common to combine weapon and (corpse) feature defs into the unit def)

Re: models then what?

Posted: 29 Dec 2009, 10:21
by aGorm
Quick question... assuming that your unitdef and movedef's are correct, should your unit need a script to move about? (I mean, sure I know it will act as one solid lump, but should the solid lump be able to move about?)

Re: models then what?

Posted: 29 Dec 2009, 12:05
by Pressure Line
you need a script. but you dont really need a heck of a lot in there.

Re: models then what?

Posted: 29 Dec 2009, 14:37
by FLOZi
If its cob it just needs the Create(), though it won't self destruct properly without a Killed(). A lua anim can be totally blank, but the file needs to exist.

Re: models then what?

Posted: 29 Dec 2009, 18:22
by aGorm
humm, well the blank lua file exists... so maybe I have somthing wrong in my def's... I'll post them up when I get back...

Re: models then what?

Posted: 29 Dec 2009, 22:30
by oksnoop2
My units move around with a blank lua script. They don't shoot and they are not animated. I still can't get this stupid lua script right...

Re: models then what?

Posted: 31 Dec 2009, 00:56
by oksnoop2
http://pastebin.com/m52a9ace6 This is what i think is my animation lua. It's called "hovertank" and it's in the scripts folder. My tank is still not behaving correctly. I'm sure my script is wrong or not complete but i don't know how to fix it. Any suggestions?

Re: models then what?

Posted: 31 Dec 2009, 10:36
by Tobi
You're using a variable (piece?) 'body' in QueryWeapon, AimWeapon and Killed, but it's not declared anywhere.

Also note that in the script you can use Spring.Echo(...) statements to display debugging output on the in game console. (and in infolog.txt)

Re: models then what?

Posted: 01 Jan 2010, 01:50
by oksnoop2
After changing my code, i'm still not getting my unit to fire or look animated. Am I correct in my assumption that there are, at the bare minimum, two files that are supposed to animate the unit and control how it fires? The two files i'm referring to are the file in the scripts folder and the file in the units folder.

Re: models then what?

Posted: 01 Jan 2010, 04:35
by Pressure Line
yes. it needs a weapon.

Code: Select all

  weapons             = {
    {
      def                = [[LIGHTNING]],
      badTargetCategory  = [[FIXEDWING]],
      onlyTargetCategory = [[FIXEDWING LAND SINK SHIP SWIM FLOAT GUNSHIP HOVER]],
    },

  },


  weaponDefs          = {

    LIGHTNING      = {
      name                    = [[LightningGun]],
      areaOfEffect            = 8,
      beamWeapon              = true,
      craterBoost             = 1,
      craterMult              = 2,
      cylinderTargetting      = 0,

      damage                  = {
        default = 160,
        planes  = 160,
        subs    = 8,
      },

      duration                = 10,
      explosionGenerator      = [[custom:LIGHTNINGPLOSION]],
      fireStarter             = 50,
      impactOnly              = true,
      impulseBoost            = 0,
      impulseFactor           = 0.4,
      intensity               = 12,
      interceptedByShieldType = 1,
      lineOfSight             = true,
      noSelfDamage            = true,
      range                   = 280,
      reloadtime              = 1.8,
      renderType              = 7,
      rgbColor                = [[0.5 0.5 1]],
      soundHit                = [[lashit]],
      soundStart              = [[lghthvy1]],
      soundTrigger            = true,
      startsmoke              = [[1]],
      targetMoveError         = 0.3,
      texture1                = [[lightning]],
      thickness               = 10,
      turret                  = true,
      weaponType              = [[LightingCannon]],
      weaponVelocity          = 400,
    },
  },
example from CA

Re: models then what?

Posted: 01 Jan 2010, 09:27
by oksnoop2
I'm sorry if this seems increasingly lazy of me but i just want to show you the state of my two files. Because it's to my limited understanding that I have everything in working order. It's just not animated or firing though, it's just driving around. Here is my file that goes in the scripts folder: http://pastebin.com/m36ab3670 Here is my file that's in my units folder: http://pastebin.com/m3f5faeb5 . Both are called "hovertank".

Re: models then what?

Posted: 01 Jan 2010, 10:08
by Pressure Line

Code: Select all

function script.AimWeapon1( heading, pitch )
Signal( aim )
SetSignalMask( aim )
return true
end
for a unit to look animated, you have to animate it ;)

eg:

Code: Select all

function script.AimWeapon1( heading, pitch )
Signal( aim )
SetSignalMask( aim )
        Turn(turret, y_axis, heading, math.rad(90))
        Turn(barrel, x_axis, -pitch, math.rad(50))
        WaitForTurn(turret, y_axis)
        WaitForTurn(barrel, x_axis)
return true
end
thats assuming you have a unit thats set up like this:
Image

otherwise you will have to pop back into your modeling suite, export the pieces separately and re-form them in upspring

Re: models then what?

Posted: 01 Jan 2010, 21:49
by oksnoop2
[img=http://img193.imageshack.us/img193/5475 ... gss.th.png]

Still no luck after implementing your suggestions. Should my math.rad values be different since my tank is not exactly like yours?

Re: models then what?

Posted: 02 Jan 2010, 00:21
by FLOZi
Those values are simply rotational speed

Re: models then what?

Posted: 02 Jan 2010, 00:57
by Pressure Line
Nothing to do with that. I couldnt get lua unit scripts to work either...

*Pressure Line wanders back off to bosland and burbles happily

Re: models then what?

Posted: 02 Jan 2010, 01:16
by oksnoop2
So does Lua work?

Re: models then what?

Posted: 02 Jan 2010, 02:13
by FLOZi
It works fine. Do you have the required gadget lua to activate lua unit anim scripts?

http://spring1944.svn.sourceforge.net/v ... iew=markup

Is an example of the required code. Put it in the LuaRules/Gadgets directory of your mod.

(N.B. Really all you need is a gadget that has the [code]return include("LuaGadgets/Gadgets/unit_script.lua")[/code] line in it)

Re: models then what?

Posted: 02 Jan 2010, 06:40
by oksnoop2
I added that widget but it made no difference. Are they other things i'm not aware of? Is there any part of what i have that someone would like to examine?

Re: models then what?

Posted: 02 Jan 2010, 12:08
by Tobi
Check in infolog.txt that it is loaded properly.

There should be lines like this:
[ 0] Loading gadget: Lua unit script framework <unit_script.lua>
[ 0] Loading unit script: scripts/gbr/tanks/gbrchurchillmkvii.lua
[ 0] Loading unit script: scripts/gbr/tanks/gbrcromwell.lua
[ 0] Loading unit script: scripts/gbr/tanks/gbrcromwellmkvi.lua
...snip...
[ 0] Loaded gadget: Lua unit script framework <unit_script.lua>

Re: models then what?

Posted: 03 Jan 2010, 00:50
by oksnoop2
http://pastebin.com/m18430f7b

This is my infolog.txt A week ago my game was not loading because it could not find the laser ..something or other. So i had to drag and drop some stuff from CA into it and it started up. Folders I pulled are:
gamedata
bitmaps
luarules

Is there a file in these folders that is undermining what i'm trying to do?