Docs / Plugins / Plugin API reference
People
omsi.people.* reads the pedestrians and passengers, and lets a plugin set a boarding passenger's ticket. See Passengers' tickets for the full flow.
omsi.people.counts#
omsi.people.counts() → walking, waiting, riding
The people of the map near the camera: walking, waiting at stops, riding a bus.
Since 0.2.22.
omsi.people.density#
omsi.people.density() → number or nil
The people setting: 0 to 3, 1 the map's own amount.
Since 0.2.22.
omsi.people.get#
omsi.people.get(id) → table or nil
One person by id, as people.list gives them, more:
stop_name- the timetable's name of the stop they wait or waited at
ticket- the name of the ticket they ask for
ticket_kind"none","stamp","buy"ticket_index- the ticket pack's, from 1; 0 none
ticket_by- the plugin that changed it
ticket_asked- asked for at the cash desk already
tagpeople.set_ticket'smodel- the
.humfile voice- its voice folder
people.list gives the same fields.
Parameters: id integer.
Since 0.3.
omsi.people.list#
omsi.people.list([radius]) → list of tables
The people (within radius m of the player's bus, when given): {id, x, y, z, state, aboard, ai_bus, stop, destination, ticket, complaint}. state: "strolling", "idle", "standing", "waiting", "to_bus", "boarding", "riding", "seated", "leaving", "to_stop"; aboard in the player's bus; complaint 0 to 3 (3: they leave); and the fields people.get describes.
Parameters: radius number, optional.
Since 0.2.22.
omsi.people.set_density#
omsi.people.set_density(value) → boolean
Changes the people setting (0 to 3).
Parameters: value number.
Since 0.2.22. Permission: traffic_write.
omsi.people.set_ticket#
omsi.people.set_ticket(id, ticket) → true, or false and the reason
Changes the ticket of a passenger boarding the player's bus (the passenger_ticket event names them): {kind, ticket, name, price, payment, voice, tag}, each optional.
kind ("none": a pass, "stamp", "buy") can only be changed until they are in the bus; ticket selects another ticket from the pack (starting at 1, with its name and price; a buyer must have a ticket: 0 is refused, and a buyer created without ticket gets the pack's ticket for their age).
name and price set the ticket name and ticket price, respectively, until the passenger has asked at the cash desk. payment specifies the amount of money handed over for a ticket purchase; it does not change the ticket price and is raised to at least the ticket price. It must be set before the passenger reaches the cash desk.
If the currency's denominations cannot represent the requested amount exactly, the amount handed over may be higher.
voice selects a line from the passenger's voice folder to use instead of Ticket_<n>_<k> ("Zone_4" selects Zone_4.wav; if the file is missing, the usual line is used; "" also falls back to the usual line), until the passenger has asked at the cash desk.
tag is plugin-defined text kept with the person (people.get), and can be set at any time. Returns false and the reason when nothing changed.
Parameters: id integer; ticket table.
Since 0.3. Permission: traffic_write.
omsi.on("passenger_ticket", function(p)
if p.kind == "buy" then
omsi.people.set_ticket(p.id, { name = "Single", price = 3, tag = "my_tariff" })
end
end)omsi.people.spawn#
omsi.people.spawn(at, [to]) → the person's id, or nil
A person of the map's kinds appears at {x, y, z, heading} (on the walkway there) and, with to {x, y, z}, walks there and stands: a crowd at an event, a passenger at a stop, a pedestrian crossing. nil when the people are off or full.
Parameters: at table; to table, optional.
Since unreleased. Permission: traffic_write.
omsi.people.stops#
omsi.people.stops() → list of tables
The stops near the camera where people wait: {id, name, x, y, z, waiting}.
Since 0.2.22.
omsi.people.waiting#
omsi.people.waiting(stop) → integer
How many people wait at a stop (its map object id).
Parameters: stop integer.
Since 0.2.22.
local waiting = omsi.people.waiting(stop_id)Something wrong or missing? Fix it on GitHub or open an issue.