Page 1 of 1

Lua implimentation in mod.

Posted: 03 May 2008, 00:25
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

Re: Lua implimentation in mod.

Posted: 03 May 2008, 10:00
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.

Re: Lua implimentation in mod.

Posted: 03 May 2008, 11:23
by Forboding Angel
english isn't his first language...

Re: Lua implimentation in mod.

Posted: 03 May 2008, 14:25
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

Re: Lua implimentation in mod.

Posted: 03 May 2008, 15:14
by daan 79
http://www.cuneiforme.nl/piro/spring%20 ... -06-46.avi

This is huge file sorry 113 mb.

Re: Lua implimentation in mod.

Posted: 03 May 2008, 17:46
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)

Re: Lua implimentation in mod.

Posted: 05 May 2008, 22:05
by Forboding Angel
Thanks Daan for that.

(FYI Flozi, German shares a lot of similarities to English)

Re: Lua implimentation in mod.

Posted: 05 May 2008, 22:11
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.

Re: Lua implimentation in mod.

Posted: 05 May 2008, 22:14
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)

Re: Lua implimentation in mod.

Posted: 05 May 2008, 22:43
by Guessmyname
Spelling is quite important. I mean, if you misspell something when you're coding... well, yeah...

Re: Lua implimentation in mod.

Posted: 05 May 2008, 23:15
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.

Re: Lua implimentation in mod.

Posted: 05 May 2008, 23:50
by AF
well tbh if your not good at coding then your code wont compile/work

Re: Lua implimentation in mod.

Posted: 06 May 2008, 00:31
by daan 79
If any downloaded that movie and also cant play it like af tel me plz than i stop linking it