-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edits and clarifications for lua-api.txt #272
Comments
Thanks! Committed as d1bb80c Minor edits and clarifications to lua-api.txt
Good question. I think I meant to use it to allow player ships to hail Lua controlled NPC channels when the player hailed the given name. However this is not totally implemented. If you grep for 'lua_channel.*name' you can find the places it is referenced. One of them is in meta_comms_hail() in snis_server.c, but the business end of that code just has a comment that says: "What to do here?" So I never finished it. However, the name does serve a purpose, as you can register multiple listening functions on the same channel, and unregister them separately by name. Lua scripts can hail the player (KALI.LUA does this as does DEMOLISHER.LUA.) It's a bit of a hack relying on knowing the special hailing message which snis_server snoops in process_comms_transmission().
That is a good question. I don't think there's a good way. You could move_object() them to the same coordinates as a planet, lol.
It is a ship type, one of these:
That list may be out of date, the real list is in share/snis/ship_types.txt, starting with 0 and counting up by 1 for each ship type. This looks like some ancient relic code here that controls the color of the sparks of the explosion depending on what type of victim was destroyed (see update_explosion() and do_explosion() in snis_client.c. Except it doesn't because the spark color is controlled by the material. This looks to be left over from before I even used opengl. Might control the spark color on the snis_limited_client, but now sparks are billboards, not meshes, so probably not even that. Probably need to update the API around that area. The explosion is purely cosmetic.
If you run
you will see the names and types (d = double, f = float, b = byte, w = 32bit int) of all the attributes. impulse_temp = get_ship_attribute(id, "temperature_data.impulse_damage");
Yeah sure, you can ask for more Lua API functions. |
Thanks, @smcameron , very helpful. I have one more:
then "closer_yet" will get called, but "pretty_close" will not, correct? |
Correct. In snis_server.c it does this:
|
Without seeing your code.... I think so. |
Updated lua-api.txt c12361f Clarify a few questions about lua-api.txt That addresses some of the things mentioned above. |
Is there a supported way to determine the population of Starbases and Planets? As far as planets, I think I'm seeing that population is not a 'real' property, but instead intended to exist at the lua level, so to speak. If that is so, maybe some kind of combination of planet description and presence or absence of government property? |
Not really. Planets don't have anything for population. starbases have a lifeform_count field, but I don't think it's accessible from lua. NPC ships also have a lifeform_count field which you can get from lua with get_ship_attribute(). The lifeform count is just something to show in science when you scan a ship or starbase, it doesn't really have any significance in the game. I don't know that it would make sense to show a population for a whole planet when scanning it. Maybe when you ask the computer to describe a planet. But those planet descriptions are pretty silly. You say "I think I'm seeing that population is not a 'real' property, but instead intended to exist at the lua level.." I don't see any mention of population in any lua scripts, so I think that "population" of planets just plain doesn't exist at all. It's possible I'm missing something... what are you looking at that makes you think there is some notion of population for planets? I'm not seeing anything regarding population of planets, so I don't think there was any intention about it. Could add a population count to planets pretty easily. The data for planets is only transmitted to the clients once I think because they never change (rotation is on the client only, I think.) OTOH, I don't know if adding a population count to planets adds very much to the game. |
Yes I see your point. This is wait I thought I was seeing. As far as the
"Lua level" I was looking at saving planet erph, but I guess that is
limited to whole cities of conceptual population.
…--Justin
On Thu, Mar 26, 2020, 13:57 smcameron ***@***.***> wrote:
Not really. Planets don't have anything for population. starbases have a
lifeform_count field, but I don't think it's accessible from lua. NPC ships
also have a lifeform_count field which you can get from lua with
get_ship_attribute(). The lifeform count is just something to show in
science when you scan a ship or starbase, it doesn't really have any
significance in the game. I don't know that it would make sense to show a
population for a whole planet when scanning it. Maybe when you ask the
computer to describe a planet. But those planet descriptions are pretty
silly.
You say "I think I'm seeing that population is not a 'real' property, but
instead intended to exist at the lua level.."
I don't see any mention of population in any lua scripts, so I think that
"population" of planets just plain doesn't exist at all. It's possible I'm
missing something... what are you looking at that makes you think there is
some notion of population for planets? I'm not seeing anything regarding
population of planets, so I don't think there was any intention about it.
Could add a population count to planets pretty easily. The data for
planets is only transmitted to the clients once I think because they never
change (rotation is on the client only, I think.) OTOH, I don't know if
adding a population count to planets adds very much to the game.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#272 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALAR5HRW5RDIDSZFFXB2PLRJO6SFANCNFSM4LPUP6FA>
.
|
Your guidance on the ship attributes was really helpful. One thing I couldn't figure out though: how to get science_selection (which appears to be part of the the bridge, not the ship, so to speak). It looks like bridge state and ship attributes are handles separately. I do not yet understand how separately. Is there a supported way for mission scripting to determine player's current science selection? |
There is an "object-scanned-event" that you can register a callback for. https://github.com/smcameron/space-nerds-in-space/blob/master/doc/lua-api.txt#L138 Something like:
Looks like none of the scripts currently use it though. Also looks like it doesn't work for waypoints. And I think it probably doesn't let you know when the player has deselected an object, so you can get notified at the time of selection, but you won't know if the object later got de-selected. |
I found a couple of minor errors in lua-api.txt such as example argument order error and spelling error.
patch for the ones I am confident about:
0001-Minor-edits-and-clarifications-to-lua-api.patch.txt
Here are some others that I am not so certain about:
What does "name" mean when listening?
Also, would this be a good place to discuss or request new lua api functions?
The text was updated successfully, but these errors were encountered: