Lua implimentation in mod.

Lua implimentation in mod.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
daan 79

Lua implimentation in mod.

Post by daan 79 »

I wanna make her a topic for maybe a guideline how to impliment gadgeds and widgets in a mod or in game. I tried today using the morfing gadged but did something wrong in the process.

My idea of putting it is is probelly wrong but here is what i did.
1 copy past the gadget to the luarules/gadged folder. Than in the Luarules/config/folder i started editing the morph_conf.lua(or something) file so it would morph my units.

I had a few questions.

1. Should i always put main.lua or draw.lua in the luarules folder?
2. Is it enough with these files in right place and the config files changed to let the gedged do its job.
3. Widgeds are unsyceble i believed so basically adding a widged should never included to also adding some files?
4. Is it try that luacob. luaui and another one provided by trepan arent necessery to put in modfile since they allready are on most computers spring installs?

Tx alot in advantages. I hope it starts raining in spring soon. Is ther a rain map yet BTW?

greetz daan
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: Lua implimentation in mod.

Post by KDR_11k »

SPELLING, MAN, Spring won't get WTF you mean if you spell it "gadged".

The thing trepan put into Spring is the gadgethandler, that means you can use main and draw.lua files that are just simple includes instead of using a full local copy of the handler.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Lua implimentation in mod.

Post by Forboding Angel »

english isn't his first language...
daan 79

Re: Lua implimentation in mod.

Post by daan 79 »

Hi well i am sorry about my english,

Here is was i did.

First of all i start with the simple things that probelly most gadgets just get in mod. Alot tx to Lurker. You wanna have a LuaRules folder. That folder probelly contains a Configs and a Gadgets folder. With introducing a simple gadget like morphing you only need to add a file called unit_morph.lua in to gadgets folder and a file called morph_defs.lua in the configs folder.
The config file you need to edit to your demands of morphing.

Than there are like main.lua and draw.lua you want to impliment in the luaRules folder. NOTE this files if you are inplimenting the morphing gadget, you should take those from a mod where also the LuaRules folder only contains out of these two folders and files. If the folder contains more ya might be in trouble. Than the colour.h.lua also needs to be in here for it to work.

If you set this all up right your gadgets should work. If it doesnt work you will be needing to do this next step.(bit more complicated.)

Open the main.lua and add this line behind the last one.

VFS.Include("LuaGadgets/gadgets.lua",nil, VFS.BASE)

This brings it out in unsave mode or the otherway around.

Than for my feature i wanted to have two options to morph to. Now it becomes complicated. You probelly want some script from ca to use because they have some units that can do this. I was planning of having a unit that moves to different alltitudes. (make more units with different alltitude levels and let morphing kick in)

See pic
Image

So i wanted to have units when morphing hold positions and drift to new position. First the units after pressing morf would slide back to survace than start climbing. Tx to Lurker it was made to work.

This askes for a couple of lines changed in the unit_morph.lua Witch excectly i might be wrong about but i think its something like this.

Change this:
local newUnit = Spring.CreateUnit(defName, px, py, pz, 0, unitTeam)
local h = Spring.GetUnitHeading(unitID)

into this
local px,py,pz = GetUnitBasePosition(unitID)
if (px==nil) then
return
end
local unitTeam = morphData.teamID

Basically better ask me for the file if ya want it, or i could pastbin it here.

So taking a bit of script from anoter config file probelly will give you all the things you have to have for this gadget to work.

I try to upload a video of this (100 mb ) o0 It will fit really nice i my mod. And i found out having units on alltitude 1000 is very playeble.

Next thing will be how to edit the morf bottons

daan
Last edited by daan 79 on 03 May 2008, 15:30, edited 1 time in total.
daan 79

Re: Lua implimentation in mod.

Post by daan 79 »

http://www.cuneiforme.nl/piro/spring%20 ... -06-46.avi

This is huge file sorry 113 mb.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Lua implimentation in mod.

Post by FLOZi »

Forboding Angel wrote:english isn't his first language...
It's not KDR's either :wink:

(Though teaching of english in german schools is excellent)
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Lua implimentation in mod.

Post by Forboding Angel »

Thanks Daan for that.

(FYI Flozi, German shares a lot of similarities to English)
tombom
Posts: 1933
Joined: 18 Dec 2005, 20:21

Re: Lua implimentation in mod.

Post by tombom »

Forboding Angel wrote:Thanks Daan for that.

(FYI Flozi, German shares a lot of similarities to English)
So does Dutch.

It is a bit unfair to berate him for not speaking English perfectly though - it's understandable enough.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Lua implimentation in mod.

Post by lurker »

daan 79 wrote:Open the main.lua and add this line behind the last one.
VFS.Include("LuaGadgets/gadgets.lua",nil, VFS.BASE)
The change was actually to add before that line, the following:
AllowUnsafeChanges("USE AT YOUR OWN PERIL")

To make units spawn in the same spot in midair, you change:
local px,py,pz = GetUnitBasePosition(unitID)
into:
local px,py,pz = GetUnitPosition(unitID)
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Re: Lua implimentation in mod.

Post by Guessmyname »

Spelling is quite important. I mean, if you misspell something when you're coding... well, yeah...
daan 79

Re: Lua implimentation in mod.

Post by daan 79 »

http://www.cuneiforme.nl/piro/spring%20 ... -06-46.rar

I packed the file aswell(i am starting to learn)

I will try to do better at my english, in the mean time, read my code.

And i have no intentions to be good at coding.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Lua implimentation in mod.

Post by AF »

well tbh if your not good at coding then your code wont compile/work
daan 79

Re: Lua implimentation in mod.

Post by daan 79 »

If any downloaded that movie and also cant play it like af tel me plz than i stop linking it
Post Reply

Return to “Lua Scripts”