Lua implimentation in mod.
Moderator: Moderators
Lua implimentation in mod.
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
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.
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.
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.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Lua implimentation in mod.
english isn't his first language...
Re: Lua implimentation in mod.
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

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
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

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.
Re: Lua implimentation in mod.
It's not KDR's eitherForboding Angel wrote:english isn't his first language...

(Though teaching of english in german schools is excellent)
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Lua implimentation in mod.
Thanks Daan for that.
(FYI Flozi, German shares a lot of similarities to English)
(FYI Flozi, German shares a lot of similarities to English)
Re: Lua implimentation in mod.
So does Dutch.Forboding Angel wrote:Thanks Daan for that.
(FYI Flozi, German shares a lot of similarities to English)
It is a bit unfair to berate him for not speaking English perfectly though - it's understandable enough.
Re: Lua implimentation in mod.
The change was actually to add before that line, the following:daan 79 wrote:Open the main.lua and add this line behind the last one.
VFS.Include("LuaGadgets/gadgets.lua",nil, VFS.BASE)
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)
- Guessmyname
- Posts: 3301
- Joined: 28 Apr 2005, 21:07
Re: Lua implimentation in mod.
Spelling is quite important. I mean, if you misspell something when you're coding... well, yeah...
Re: Lua implimentation in mod.
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.
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.
well tbh if your not good at coding then your code wont compile/work
Re: Lua implimentation in mod.
If any downloaded that movie and also cant play it like af tel me plz than i stop linking it