In-game definition editing

In-game definition editing

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

Moderator: Moderators

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

In-game definition editing

Post by trepan »

The recent lua library rewrite has brought along with it a new feature.
I've added the ".editdefs" command to allow editing unit definitions and
weapon definitions in-game (the commands have to be proxied through
one of the lua interfaces, very easy to do).

This mode is intended to help mod creators tweak their units. I'm not
going to guarantee that it won't crash your game. It's very likely that
it will. The other oddity is that it requires you to create a new unit for
certain parameters to take effect.

Example:

Code: Select all

.editdefs 1
/luaui setudef armcom radarRange 400
.cheat 1
.give armcom
The new armcom will have a radar range of 400.

There are some improvements that could be made (like copying changes
to existing units, and providing access to more complex types like table),
but that'll have to wait for a little while.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

I don't suppose this could be tied into the LUA-COB thing in any way, could it?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

I rewrote the UnitDefs and WeaponDefs table access methods so
that they have no appreciable loading time, and are normally write-
protected. This change also gave me access to the pointer offsets
for the definition parameters.
User avatar
Nemo
Spring 1944 Developer
Posts: 1376
Joined: 30 Jan 2005, 19:44

Post by Nemo »

So for the coding nubs among us, is that a yes (to linking it to the lua<->cob deal)?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

For the coding nubs:
The ".editdefs" feature is not functionally tied to the
LUA <--> COB features from the viewpoint of the end user.
Engine Of Darkness
Posts: 87
Joined: 23 Dec 2006, 21:36

Post by Engine Of Darkness »

is it also possible to change bonuses based on experience then ? For example damage, range, reload speed, accuracy etc (on the fly, without creating a new unit)?
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

those examples would involve weapon editing, though I suppose you could do something like this:

.editdefs 1
/luaui setudef armcom Weapon1 <weaponname>
.cheat 1
.give armcom

so that you switch weapon1 to another (premade) weapon that's a bit different in some way (ie, more accurate etc)
Engine Of Darkness
Posts: 87
Joined: 23 Dec 2006, 21:36

Post by Engine Of Darkness »

but wouldn't this involve creating a unit (atleast the example you gave would do this)?

I'm rather thinking about an E- Function so the first exp points 0.01 get most of the bonus, and it's then exponentially less (damage, health, range, reload speed, accuracy...) Also is there some kind of "tech level" variable? so you could say "tech level 1 unit" gets stronger boni then a tech level 3 unit (you probably could do this via "if hp>10000" but oh well)

For example for 0.00- 0.01 xp you get 50 hp life bonus, then later ingame you get a 5 hp bonus for 1.00- 1.01 (just as an example)

http://www.ieap.uni-kiel.de/plasma/ag-s ... nktion.jpg The blue line explains very well what I mean.

Change "f(x)" into health bonus in % (or whatever) and "x" into experience.

Basicially its like the exp system is now, just more rewards, less effective the higher exp is and more complicated to code I think.

However this was why I asked if this is possible in lua, so you don't have to recompile the game out of the source to do this.
j5mello
Posts: 1189
Joined: 26 Aug 2005, 05:40

Post by j5mello »

just to kinda clear things up but isn't the only point of this system to allow modders to tweak a variable ingame so they can check their effects without having to quit, change the variable, start a new game, etc??

EDIT: im pretty sure that in order to change the bounuses units recieve from exp you would have to do code work i.e. C++ not the FBI tweaking.
Engine Of Darkness
Posts: 87
Joined: 23 Dec 2006, 21:36

Post by Engine Of Darkness »

maybe not, you wouldn't have to change the fbi, rather the following(Also the weapon "damage" etc is stored in another file (in weapons.tdf)):


I'll just show it via code(no syntax and stuff (just made up while writing)) I've never written lua before I'll just use c#/ c++ as reference (no real syntax). I won't make any thouhts about 1000 problems now as I just want to describe it. I'm speaking of FBI (units) now.
you get their health via let's say "lua_get_maxdamage" (maxdamage represents health I guess) which is written into a variable called damage

Now you create 2 new variables lets say tempmax and finalmax (all variables are initialised in lua).

Now do something like this:


Tempmax=damage

(do calculations with tempmax)

finalmax=tempmax

lua_set_maxdamage(finalmax)
However I think spring wouldn't really like this, because the internal experience system still works, too(I guess). So this may cause overwriting, crashing, bladibla. Mainly because I don't think spring's experience system was designed with this in mind (I may be wrong though).

Well I'm no good coder, atleast not compared to most people here who work on good lua scripts or code the game.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

You'll need to add callbacks to the AIs for when properties are changed, else AIs that precache this data like AAI will be seriously f*cked over by certain changes.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Nope, don't need to add callbacks for AIs, or to notify lua clients, or
anything else. All I need to add is a warning that goes a little something
like:

WARNING: will likely cause crashes and desyncs

Congrats to jm5ello for being one of those that "gets it".
Engine Of Darkness
Posts: 87
Joined: 23 Dec 2006, 21:36

Post by Engine Of Darkness »

My question was more of a general question if it would be possible to do this, because I though it would fit into this topic and I didn't want to start a new one.

Maybe I should've started a new one though, my bad.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: In-game definition editing

Post by Pendrokar »

What has changed with this function(exept that .editdefs needs cheats and that there is radardistance not radarrange now)? I tried trepans given example and Guessmyname given example no changes after creating the unit!
Furthermore will the definitions have the new values if I create a unit with LUA? And how to give this command "/luaui setudef armcom radardistance 1000"?
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: In-game definition editing

Post by Gota »

This is great.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: In-game definition editing

Post by Pendrokar »

Gota wrote:This is great.
So it worked for you?
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: In-game definition editing

Post by Gota »

no,havent tryed it but have been wishing for such a thing for a while.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re:

Post by Forboding Angel »

Engine Of Darkness wrote:maybe not, you wouldn't have to change the fbi, rather the following(Also the weapon "damage" etc is stored in another file (in weapons.tdf)):


I'll just show it via code(no syntax and stuff (just made up while writing)) I've never written lua before I'll just use c#/ c++ as reference (no real syntax). I won't make any thouhts about 1000 problems now as I just want to describe it. I'm speaking of FBI (units) now.
you get their health via let's say "lua_get_maxdamage" (maxdamage represents health I guess) which is written into a variable called damage

Now you create 2 new variables lets say tempmax and finalmax (all variables are initialised in lua).

Now do something like this:


Tempmax=damage

(do calculations with tempmax)

finalmax=tempmax

lua_set_maxdamage(finalmax)
However I think spring wouldn't really like this, because the internal experience system still works, too(I guess). So this may cause overwriting, crashing, bladibla. Mainly because I don't think spring's experience system was designed with this in mind (I may be wrong though).

Well I'm no good coder, atleast not compared to most people here who work on good lua scripts or code the game.
Unless I'm mistaken, it's for luadefs only and you are talking about FBI and TDF.
User avatar
Pendrokar
Posts: 658
Joined: 30 May 2007, 10:45

Re: In-game definition editing

Post by Pendrokar »

WHERE IS TREPAN!?!
Image

EDIT:
With some luck it will be in 77b2, but atm trepan works for bzFlag again :/
Why now!
Image
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: In-game definition editing

Post by jK »

Pendrokar wrote:What has changed with this function(exept that .editdefs needs cheats and that there is radardistance not radarrange now)? I tried trepans given example and Guessmyname given example no changes after creating the unit!
Furthermore will the definitions have the new values if I create a unit with LUA? And how to give this command "/luaui setudef armcom radardistance 1000"?
you know you have first to .cheat and then .editdefs (it will then even give ya a message)?
Post Reply

Return to “Lua Scripts”