v1.0.21 - The LUA Functions Update!
Author: Deltars,
published 4 years ago,
[img]https://clan.cloudflare.steamstatic.com/images//28842908/54152cca2654e25eca8e7fa8f2381d2ec8617637.png[/img]
Dear Stormworkers,
This week we are releasing a series of new and updated LUA functions that we have been developing in collaboration with players on the experimental branch!
With high demand, we have added many new functions for getting info about the world, as well as spawning and removing various objects. Many of these new functions have huge implications for what can be done with the scripting API, and many of these functions serve as a keystone for your projects.
We have been releasing these changes to the experimental branch as we have developed them. Now, with the benefit of player feedback, we are releasing them as a pack of functions in a minor update.
See the technical data below for a full list of changes to the API. This information is also reflected in the in-game API reference.
[img]https://clan.cloudflare.steamstatic.com/images//28842908/9ebdb86e530a15a6e5299c403cb1bb29ba6c023c.jpg[/img]
Meanwhile, we continue to work hard on the new modular engines and look forward to sharing the new features discussed last week. These new features will be released on experimental branch as we develop them, to give all players the chance to provide feedback.
We also have many new minor updates on the way, many of which use these new LUA functions!
We look forward to seeing what players build with the new API functions, as well as seeing other players complete their projects now the functions they requested are available.
[img]https://clan.cloudflare.steamstatic.com/images//28842908/fa47ebb9727302188b17e924d9f9e71d0f4b2b6a.jpg[/img]
As always, we look forward to your thoughts and feedback!
Much love <3,
The Stormworks Developers
[b]v1.0.21[/b]
[b]Full API Changes[/b]
=================
object_id, is_success = server.spawnFire(matrix, size, magnitude, is_lit, is_initialized, is_explosive, parent_vehicle_id, explosion_magnitude)
server.addMapObject(peer_id, ui_id, POSITION_TYPE, MARKER_TYPE, x, y, z, parent_local_x, parent_local_y, parent_local_z, vehicle_id, object_id, label, vehicle_parent_id, radius, hover_label)
server.addMapLabel(peer_id, ui_id, LABEL_TYPE, name, x, y, z))
PLAYER_LIST = server.getPlayers()
PLAYER_LIST |
{ [peer_index] = { ["id"] = peer_id, ["name"] = name, ["admin"] = is_admin, ["auth"] = is_auth, ["steam_id"] = steam_id }}
is_on = server.getVehicleButton(vehicle_id, button_name)
server.setVehicleSeat(vehicle_id, seat_name, axis_w, axis_d, axis_up, axis_right, button1, button2, button3, button4, button5, button6)
server.teleportPlayer(peer_id, matrix) is_success = server.setPlayerPos(peer_id, matrix)
server.teleportVehicle(matrix, vehicle_id) is_success = server.setVehiclePos(vehicle_id, matrix)
is_success = server.setObjectPos(object_id)
EQUIPMENT_ID, is_success= server.getCharacterItem(object_id, SLOT_NUMBER)
name, is_success = server.getPlayerName(peer_id)
matrix, is_success = server.getPlayerPos(peer_id)
x, y, z , is_success = server.getPlayerLookDirection(peer_id)
object_id, is_success = server.spawnObject(matrix, OBJECT_TYPE)
object_id , is_success = server.spawnCharacter(matrix, (OUTFIT_TYPE))
object_id, is_success = server.spawnAnimal(matrix, ANIMAL_TYPE, size_multiplier)
matrix, is_success = server.getObjectPos(object_id)
vehicle_id, is_success = server.spawnVehicle(matrix, playlist_index, component_id)
vehicle_id, is_success = server.spawnVehicleSavefile(matrix, save_name)
matrix, is_success = server.getVehiclePos(vehicle_id, voxel_x = 0, voxel_y = 0, voxel_z = 0)
name, is_success = server.getVehicleName(vehicle_id)
matrix, is_success= server.spawnMissionLocation(matrix, playlist_index, location_index)
is_success = server.spawnThisPlaylistMissionLocation(name)
matrix, is_success = server.getOceanTransform(matrix, min_search_range, max_search_range)
server.createPopup(peer_id, ui_id)
server.setPopup(peer_id, ui_id, name, is_show, text, x, y, z, is_worldspace, render_distance)
server.setPopupScreen(peer_id, ui_id, name, is_show, text, horizontal_offset, vertical_offset)
object_id, is_success = server.getPlayerCharacterID(peer_id)
[i]The following functions were reworked to be more general for player and non-player characters, this functions gives you a player's object_id[/i]
server.killPlayer(peer_id) server.killCharacter(object_id)
server.reviveCharacter(object_id)
server.setSeated(peer_id, vehicle_id, seat_name) server.setCharacterSeated(object_id, vehicle_id, seat_name)
[i]Can now set non-player characters to be seated[/i]
server.despawnCharacter(object_id, is_instant)
server.despawnMissionObject(object_id, is_instant)
[i]These functions performed the exact same task as server.despawnObject(object_id, is_instant)
hp, matrix, is_incapacitated, is_dead, is_interactable = server.getCharacterData(object_id)
[i]Character position can be obtained with server.getObjectPos(object_id)[/i]
[i]Mission objects have been renamed to components to avoid confusion with game objects[/i]
LOCATION_DATA, is_success = server.getLocationData(playlist_index, location_index)
LOCATION_DATA |
{ ["name"] = name, ["tile"] = tile_filename, ["env_spawn_count"] = spawn_count, ["env_mod"] = is_env_mod, ["object_count"] = object_count ["component_count"] = component_count })");
COMPONENT_DATA, is_success = server.getLocationComponentData(playlist_index, location_index, *component_index*)
COMPONENT_DATA |
{ ["name"] = name, ["display_name"] = display_name, ["type"] = TYPE_STRING, ["id"] = component_id, ["dynamic_object_type"] = OBJECT_TYPE, ["tags"] = { [i] = tag }, ["transform"] = matrix, ["character_outfit_type"] = OUTFIT_TYPE }
OBJECT = server.spawnMissionObject(matrix, playlist_index, location_index, object_index)
COMPONENT, is_success = server.spawnMissionComponent(matrix, playlist_index, location_index, component_index)
COMPONENT |
{ ["name"] = name, ["display_name"] = display_name, ["type"] = TYPE_STRING, ["x"] = x, ["y"] = y, ["z"] = z, ["transform"] = matrix, ["id"] = object_id/vehicle_id}
function onSpawnMissionObject(object_id/vehicle_id, name, TYPE_STRING, playlist_index)
function onSpawnMissionComponent(object_id/vehicle_id, component_name, TYPE_STRING, playlist_index)
function onVehicleSpawn(vehicle_id, peer_id, x, y, z, cost)
[i]Cost is currently only calculated for player spawned vehicles[/i]
function onChatMessage(peer_id, sender_name, message)
is_success = server.despawnObject(object_id, is_instant)
is_success = server.despawnVehicle(vehicle_id, is_instant)
playlist_index, is_success = server.getPlaylistIndexByName(name)
location_index, is_success = server.getLocationIndexByName(playlist_index, name)
path, is_success = server.getPlaylistPath(playlist_name, is_rom)
server.onCharacterSit(object_id, vehicle_id, seat_name)
[b]Quick info for updating old scripts[/b]
===================================
Removed Functions:
despawnCharacter [i]did the same thing as despawnObject
despawnMissionObject [i]did the same thing as despawnObject
Renamed Functions:
-teleportPlayer(peer_id, matrix) -> setPlayerPos(peer_id, matrix)
-teleportVehicle(matrix, vehicle_id) -> setVehiclePos(vehicle_id, matrix)
[i]Please note the teleportVehicle arguments are swapped to be the same as other functions[/i]
-onSpawnMissionObject -> onSpawnMissionComponent
-spawnMissionObject -> spawnMissionComponent
-setSeated(peer_id, vehicle_id, seat_name) -> setCharacterSeated(object_id, vehicle_id, seat_name)
[i]As seen above setCharacterSeated (and other character based functions) now use an object_id. To get a player's object id a new function has been added: getPlayerCharacterID(peer_id)[/i]
Functions that now return an is_success value will requre an extra set of brackets if used as arguemnts as lua will attempt to pass all return values unless the function is evaluated
old `local x, y, z = matrix.position(server.getPlayerPos(player_object.id))`
new `local x, y, z = matrix.position((server.getPlayerPos(player_object.id)))`
Rework - Cargo container design rework (Toggle buttons for connectors)
Rework - Added voice audio volume boost
Rework - Slightly increased player ground collider radius to aid getting stuck in small gaps
Rework - Added key type support for lua data saving (Now supports string(default) and unsigned)
Fix - CTD when returning a vehicle on fire via the map
Fix - Dedicated server ?save always saving to autosave
Fix - Vehicle editor currency display not apperaing after toggling infinite money
Fix - Playlist Lua callbacks errors are now cleared (Callbacks are not blocked after they error)
Fix - Script duplication when reloading scripts
Fix - onPlayerDie event resending when dropping a dead body
Fix - Client character objects not updating their internal peer_id when reconnecting to a server (Wrong peer_id Lua bug)
Fix - Several crashes from playlist Lua
Fix - Missing notification for loot crates
Fix - CTD with out of range outfit for spawnCharacter
Fix - CTD with out of range item for setCharacterItem
Fix - onPlayerSit now only triggers for player characters
Fix - Unable to place blocks on certain sides of doors
Fix - spawnFire() rejecting correct number of arguments
Fix - CTD on Lua failing to find vehicle data
Fix - Dev Train Junction MC showing in inventory