Lua questions.

Lua questions.

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

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Lua questions.

Post by smoth »

I have grown fond on many of the C&C style construction features let's say I was going to add the following in for my mod(I am in the planing stage for this):

Repair icon:
click it then click unit to start unit repair

Sell icon:
sells building rather then self-d, small resource gain

Tech research:
you build up research points by diverting resourced to a resource building. The tech research points are built up and you may then spend them on a research item(which is a button in the gui)

Lua based building construction:
You click the defense or building icon in the hud, you then click the construction yard number(you will be able to have up to 10). Depending on what buildings are alive at the time(read requisites) You can que up construction TA style from lua to anywhere within your control proximity(los)

Factory Buildings(unit construction):
Would be a separate element, would need to have their build menus control via lua to lock or unlock units(is this possible). Otherwise same as above.

There would be 2 new resources:
Refined parts and research points

refined parts would be used in all mech construction.

Ota resources changed to:
metal:
being used to build more simplistic units and buildings utilizing metal as well.
Energy:
would be relegated to a C&C style powerbar that will shut down buildings when they are built if you lack the power

now, what would happen to an ai in this setup? Is all of this possible in lua? Does smoth need to stop designing before thinking of what is do-able in spring?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

AI can't interface with Lua at all AFAIK.

If you want to repurpose energy that much I'd suggest not using the hardcoded resource for that and instead keeping track of an energy value in Lua, if you don't use it for reclaiming and such you don't need a hardcoded resource. In fact I wonder why you still plan on using the hardcoded resources at all.

I think C&C style building would be trivially easy to do, most of it is a finger exercisse for the scripter and the only real interface with the engine would be the buttons and spawning the resulting units.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

My concern was mainly the ai.. what do you think about the unit locks via lua? how bad is that?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

What I outlined for NTai means that given say 20 minutes of work on the lua side, a set of new keywords for toolkit would be available for config makers.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

smoth wrote:what do you think about the unit locks via lua? how bad is that?
I don't think it's that bad, depends on whether you let the engine handle the build process (i.e. normal factory with workertime etc) or do it trough Lua (have a timer tick down, when it hits zero spawn the unit at the desired factory).
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

I am going to be doing a lot of conversion to lua however, I want to do it gradually. If I do not have to do the unit trees and constraints(requisites) in lua that would be good.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

You have to use Lua or a COB hack and I know you aren't fond of COB hacks.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

I'd have to use lua cob to effect a build menu? I am just talking about changing the item in the build menu to be allowed or not. Is it really that big a hassle?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

That's not enough, you could still issue a build order via other Lua code (notably LuaUI.) That's a detail, but an important one and quite possibly easily missed.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

so what is the proper way to lock a unit until I have a certain flag or research set?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

Apart from removing the build option, you also need to check for that command in AllowCommand. Negative command numbers should indicate that a build order has been issued. I think that's the case, as usual trepan knows better ^^
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

yeah, I hope this q&a thread isn't bothering you gents but I need to get information so I can properly plan this ui and project rules set.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Remember that although Mod widgets can use the Lua UI calls, its a one way street, you can output but there's no input, so you can do resource bars etc as long as you dont expect any input, user mouse clicks and keypresses go out the window.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Mod widgets can receive user input just like user widgets
(note how the deployment widget swaps display polarity
when clicked on in the video). Mod widgets are run in the
LuaUI environment.

P.S. Widget != Gadget
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

trepan, is a lua resource controlled research item that can be research to unlock a unit in the build menu be done?

locked meaning the unit cannot be built(greyed out or whatever)
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

You can block the build command, that much is sure. Hiding the build button will take some more work. Using research as the trigger should be simple.
j5mello
Posts: 1189
Joined: 26 Aug 2005, 05:40

Post by j5mello »

don't have to hide the units build button, just disable it and use that command that greys it out to show you that you can't build it yet..
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

Hiding it reduces clutter compared to greying it out, especially if the game's tech system is designed to make certain units mutually exclusive. I doubt it's harder to do hiding than greying out but it's probably harder than just intercepting the commands in AllowCommand.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

I'd rather a grey out so they can see they are missing units.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

You could use the deployment feature's code as an example for disabling commands.
Post Reply

Return to “Lua Scripts”