Help - Search - Members - Calendar
Full Version: LUA + MML
The Pfhorums > Marathon and Aleph One > Aleph One Discussion
irons
I've seen a lot of confused posts around here. Most of you make understandable assumptions about the extensions to Aleph One, Lua and MML. It is pretty easy to find out what each can or can't do by looking at the documentation, which is always included in the Aleph One download (although most Mac users probably only copy the App):However, many of you probably don't take the time to read the above documentation. Believe me, it's not that complicated; I had no programming experience a year ago, and I picked up Lua and got very far within six months--I had finished AORPG by then and was doing some work on Juggernauts.

For those of you who are still daunted by these extension languages--or just lazy--I'm going to include a few rules of thumb that can help you determine whether or not Lua or MML can make something possible.

Look at MML if you want to...
  • add substitute graphics or sounds (à la Texture Enhancement Package)
  • change a lot of defaults that are hard-coded in the engine (gravity, liquid color, strings, map colors, damage flash colors, other stuff)
  • make level-wide or engine wide modifications to environments, weapon order, item properties, etc.
  • release a modification that requires download to use (Including new shapes or something like that)--as long as both players are guaranteed to have the MML file. (In other words, you can prevent OOS by ensuring that all players in a multi-player game will have the same version of the MML
Look at Lua if you want to..
  • manipulate game mechanics on-the-fly (gravity in certain places, oxy drain in certain places, polygon heights, platform behavior, monster enemies + friends, etc)
  • replace complex map trickery with simpler solutions (stacked terminals vs. displaying multiple term text on a single terminal)
  • use accurate timers (a.k.a. variables as opposed to platforms)
  • manipulate the position, health, oxygen, angle-facing, etc. of individual players
  • place individual monsters and items on specific polygons
  • manipulate monster actions like attack and move
  • manipulate the position, yaw, pitch, or target of individual projectiles
  • distribute a modification that needs only be played by joining a net game (non-embedded Lua scripts are sent to all players)
Neither of these languages is capable of...
  • modifying the basic numbers of a Shapes file (ticks-per-frame, etc)
  • changing weapon behavior mid-game (burst count, recoil, etc)
  • writing to files other than Aleph One Log.txt
  • controlling monsters precisely (although this is improving)
  • altering map geometry by adding or removing polygons, switches, rechargers, and terminal locations
As you can see, MML is usually for static, configuration-like changes to the engine, such as those often used to make Total Conversions, etc. Lua, on the other hand, is useful for hacking in-game parameters in a dynamic fashion. Obviously, I haven't covered everything, but you can post here or simply look at the documentation if you really want to know about something. Both languages are still changing, but not neccessarily very quickly. If I encounter a new "rule of thumb," I'll add it here so that everyone can see. I'll try to keep this list up-to-date as well.
Samus
Could you upload a copy of your head shot lua?
irons
The Script
assassingao
What does this command do?

"prompt (player, prompt)"




(I read the lua documentaion but I don't seem to understand...)


How'd you give specific weapon to specific players with specific names/color with lua?
(Like in AORPG, But I looked in and kinda...not understand it....)

(It'll be important to the insta-gib script... To define player's beam color and stuff...)
Grayswandir
Wait, I thought earlier you said recoil was possible.
SirBlastalot
It says changeing recoil mid-game, not just changeing recoil. Also, recoil in this case probably refers to the player being pushed backwards, not looking up.
Grayswandir
I wonder if its possible to change Physics files mid game...
irons
Gao, the prompt basically asks a user to input something. I could have a Lua script do something like this:

the game: What is your name?
(enter name): irons
the game: Hello, irons.

It is not available in netgames so players can't use it to cheat.

Gao, if "instagib" is what I think it is (starting all players with some powerful weapon and ensuring that they die in one hit), it's easy to use a physics file only to make this "mode." Just make the pistol item give the player a super-powerful weapon that will kill in one shot.

Recoil the way I suspect Legacy means it, that is, making the view inch up as the player fires shots, is possible, but shoddy at best. And Legacy, you can't change physics files in-game.
assassingao
QUOTE
Gao, if "instagib" is what I think it is (starting all players with some powerful weapon and ensuring that they die in one hit), it's easy to use a physics file only to make this "mode." Just make the pistol item give the player a super-powerful weapon that will kill in one shot.


I thought of that first, but then I decided to use lua to let the player choose their beam/gun style. (Like in AORPG, different class, different weapons)


(There'll be Light Blue, Green, Flame, Yellow, Soul, Simulacrum, Poison warhead and BALL!, each beams will have different damage type and appearance, but have SAME AMOUNT of damage.)


Each guns will use SAME kind of ammo, though.

Still in testing...
(Forgot to decrease the theta error, forgot to change "alien weapon" contrail back to "lamp breaking" and change the soul to be a missile contrail since grenade was too small.)
Homocidal Ham
Q: can I change the player's monster type?
Don Merlin
QUOTE(irons @ Mar 10 2006, 10:24 AM) *
[/list]Neither of these languages is capable of...
  • modifying the basic numbers of a Shapes file (ticks-per-frame, etc)
  • changing weapon behavior mid-game (burst count, recoil, etc)
  • writing to files other than Aleph One Log.txt
  • controlling monsters precisely (although this is improving)
  • altering map geometry by adding or removing polygons, switches, rechargers, and terminal locations


If your weapons are Lua controlled to begin with, then you can actually use Lua to change weapon behavior mid-game. You can use counters to determine values for a weapon, and if you wanted to have these values saved in a saved game, then convert them to Forge parameters. I usually used lights to save booleans, and platforms to save numeric values.

To some degree, recoil can be emulated with Lua. The actual burst count from a gun cannot be altered, but you could have projectiles spawn other projectiles, and then change that value as the level progresses.

While there are limitations, I still think there is much more that can be done with Lua that people have yet to tap into. It requires a lot of creativity to work around the engine restrictions. It's a lot of fun when you get something working. :)
irons
You can't spawn projectiles directly.
Don Merlin
QUOTE(irons @ Jun 8 2007, 03:16 PM) *
You can't spawn projectiles directly.


You can spawn them in a number of ways. You can make the Forge projectile activate immediately, and upon activation, spawn a creature the sends out multiple projectiles (and then change the creature that gets spawned as the level progresses).

You can also spawn a normal projectile on detonation. For example, when Merlin's wand uses the firestorm spell, I could have made the spell more powerful as the level continued by:

A) spawning more fires for each fireball that landed, and
B) extended the life of the fire, and
C) actually change the spawned fire creature to another one that emits hotter fire.

Much you can do!
irons
QUOTE(Don Merlin @ Jun 8 2007, 06:28 PM) *
You can also spawn a normal projectile on detonation.


What do you mean?
Don Merlin
QUOTE(irons @ Jun 8 2007, 03:43 PM) *
What do you mean?


I mean that instead of using an invisible immediate projectile to spawn a creature, you can also use a normal projectile. In my example, the fireball is a standard projectile in the game, but for this particular spell, it spawns fire creatures upon detonation.
irons
Where's the function to spawn projectiles?
Don Merlin
QUOTE(irons @ Jun 8 2007, 06:47 PM) *
Where's the function to spawn projectiles?


To spawn projectiles, you first spawn a creature, whether a special creature like a fire, or an invisible creature, and that creature is set to launch whatever projectile you define for it.
Pfhortipfhy
QUOTE(Samus @ May 5 2006, 03:44 AM) *
Could you upload a copy of your head shot lua?


EDIT: not asking, still interested. Edit: forget that.
irons
Bill, from the form of your original message, it seemed that there were two ways of spawning projectiles: one using monsters, and another "normal" way. Hence this confusion.

Phortiphy, don't ask about the head shot script again.
Volcanon
Is there a way to have the player be interlevel warped from any polygon immediately after finishing the objective?
Also, how do I get a monster to warp in only if X happens, like I kill a trooper or something?
irons
Your first request is easy: teleport_player_to_level(player, level). The second is not so easy, because monsters can't normally teleport, unless they've reached a goal polygon or get activated (teleporting out immediately).
Drictelt
The lua guide i found here(http://www.cebix.net/viewcvs/alephone/aleph/docs/Lua.html?rev=1.6) is very unclear at some points, and the fact that it contains remarks everywhere makes me think it can be edited somehow. Im wondering, is this possible and how? I think we could spare a lot of double work if everyone that uses the guide helps to extend it. The wiki principle actually... But currently the wiki points at this guide.

Same probably counts for the mml guide.
Treellama
You can send patches to me as diffs against the files in CVS, and I'll commit them. Or, you can re-write the guide in Wiki format on s.b.o., and I'll include a printable version in releases.

The first way is less work for me (because CVS version control makes it easier to figure out what Lua and MML is available in what release). The second way might encourage people to help out, or, like the manual, it might go a little ways then die.
Pfhortipfhy
Just flipping through the LUA documentation, it seems like there's no trigger for simply checking to see if a switch has been used at all, the only triggers are for players hitting the action key. Why would this be, and/or could there be a trigger for if the switch has been used by anything?
Treellama
Do you mean you want to check a switch's state? If it's a tag switch, check the tag's state; if it's a light switch, check the light's state; if it's a platform switch, the platform's state.

The engine doesn't actually keep a log of "this monster pressed this switch", so you have to do it yourself.

I think this should have been in a new thread :)
Skirge
What might one enter in a .lua script to make a net scoring system for killing monsters?
VladTepes
QUOTE(Treellama @ Jul 22 2009, 09:14 PM) *
I think this should have been in a new thread :)


Anyway, look for the monster_killed(monster, aggressor_player, projectile) trigger, or the whole lua documentation in general...
WastdJamacan
is this the mml for changing the view angle for up/down? I really want to know so I can texture properly in VML

half_vertical_visual_arc: the vertical angle from horizontal that the guided-projectile targeting will use0 to look for in a target; it is in Marathon's angle units, where 90 degrees = 128 (default: 28/3 = 42)

it talks about guided projectiles, but i dint know if it also included your view
irons
No. Changing how far up or down it is possible to look occurs in the "physics" section of the Physics file.
WastdJamacan
Oh. That's easier than I anticipated it would be.
irons
Just be warned that extreme variations on the 42.66666 +/- degrees look really, really bad. You'll see what I mean.
WastdJamacan
dammit. i cant find it. PhysicsEditorEnglish is so hard to understand, and the numbers aren't the same as anvil. I may have to get on my old desktop and sheepshaver and make one in anvil

EDIT: I think I know what will happen. the camera that you view through is placed roughly inside the head of the player. if you look up more than the norm, you begin to view his face/body. is that correct?
irons
QUOTE(WastdJamacan @ Sep 13 2009, 12:33 PM) *
EDIT: I think I know what will happen. the camera that you view through is placed roughly inside the head of the player. if you look up more than the norm, you begin to view his face/body. is that correct?


No. The worldview becomes increasingly distorted as you look farther up or down. Also, landscapes get cut off at the top or bottom. It doesn't sound so bad, but it is so disorienting that almost anything more than the default is useless. Feel free to mess around, because that's how I learned, but I'm warning you now not to expect much.
Treellama
QUOTE(WastdJamacan @ Sep 13 2009, 01:33 PM) *
dammit. i cant find it. PhysicsEditorEnglish is so hard to understand, and the numbers aren't the same as anvil. I may have to get on my old desktop and sheepshaver and make one in anvil

EDIT: I think I know what will happen. the camera that you view through is placed roughly inside the head of the player. if you look up more than the norm, you begin to view his face/body. is that correct?

Not in the slightest.
WastdJamacan
Yeah, I figured it out. But, I can live with it because it helps me texture hard to reach places
WastdJamacan
Lua doc is gone. Me gustaría tenerlo.

EDIT: Does this go through what the other one did?
Treellama
No that's superold. Click on my blog, there's a link on the left hand side. It also comes with Aleph One, if you have that.
WastdJamacan
So this?
Treellama
That's not the one linked from my blog.

http://marathon.svn.sourceforge.net/viewvc...k/docs/Lua.html

It has new stuff that isn't in the release, but it's all marked as such.
Kurinn
Is it possible to output all of the values for custom fields in a lua script to a text file? I think this might be very useful for checking bugs when a print check would be impractical.
Treellama
Hmm--Lua I/O is enabled for solo scripts in SVN, so that's half of what you need. I don't know that there's a way to access the tables to iterate custom fields, though.

But! If you save the game, they're all there in the SLUA chunk. Get out your hex editor? :)

Edit: Lua 5.2 will respect a __pairs metatable method that will enable us to allow you to iterate through custom fields. Unfortunately, Lua 5.2 isn't done yet, and definitely won't make it into the next release.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.