There's a new script function game.pushMessage(MsgType, dictionary@) which allows you to do practically any state change within the game (load/unload terrain, actor, connect/disconnect multiplayer). The parameters are passed as dictionary. Documentation will be available at http://developer.rigsofrods.org/ after this PR is merged; for now here is a reprint:
/**
* Pushes a message to internal message queue. Parameters are listed in `Script2Game::MsgType` comments.
* @return True if the message was pushed, false if it was rejected.
*/
bool pushMessage(MsgType type, dictionary@ dict);
// Application
MSG_APP_SHUTDOWN_REQUESTED, //!< Immediate application shutdown. No params.
MSG_APP_SCREENSHOT_REQUESTED, //!< Capture screenshot. No params.
MSG_APP_DISPLAY_FULLSCREEN_REQUESTED, //!< Switch to fullscreen. No params.
MSG_APP_DISPLAY_WINDOWED_REQUESTED, //!< Switch to windowed display. No params.
MSG_APP_MODCACHE_UPDATE_REQUESTED, //!< Rescan installed mods and update cache. No params.
MSG_APP_MODCACHE_PURGE_REQUESTED, //!< Request cleanup and full rebuild of mod cache.
// Networking
MSG_NET_CONNECT_REQUESTED, //!< Request connection to multiplayer server specified by cvars 'mp_server_host, mp_server_port, mp_server_password'. No params.
MSG_NET_DISCONNECT_REQUESTED, //!< Request disconnect from multiplayer. No params.
MSG_NET_REFRESH_AI_PRESETS, //!< Request refresh of AI presets menu in top menubar. No params.
// Simulation
MSG_SIM_PAUSE_REQUESTED, //!< Pause game. No params.
MSG_SIM_UNPAUSE_REQUESTED, //!< Unpause game. No params.
MSG_SIM_LOAD_TERRN_REQUESTED, //!< Request loading terrain. Param 'filename' (string)
MSG_SIM_LOAD_SAVEGAME_REQUESTED, //!< Request loading saved game. Param 'filename' (string)
MSG_SIM_UNLOAD_TERRN_REQUESTED, //!< Request returning to main menu. No params.
MSG_SIM_SPAWN_ACTOR_REQUESTED, //!< Request spawning an actor. Params: 'filename' (string), 'position' (vector3), 'rotation' (quaternion) 'config' (string, optional), 'skin' (string, optional), 'enter' (bool, optional, default true), , 'free_position' (bool, default false)
MSG_SIM_MODIFY_ACTOR_REQUESTED, //!< Request change of actor. Params: 'type' (enum ActorModifyRequestType)
MSG_SIM_DELETE_ACTOR_REQUESTED, //!< Request actor removal. Params: 'instance_id' (int)
MSG_SIM_SEAT_PLAYER_REQUESTED, //!< Put player character in a vehicle. Params: 'instance_id' (int), use -1 to get out of vehicle.
MSG_SIM_TELEPORT_PLAYER_REQUESTED, //!< Teleport player character anywhere on terrain. Param 'position' (vector3)
MSG_SIM_HIDE_NET_ACTOR_REQUESTED, //!< Request hiding of networked actor; used internally by top menubar. Params: 'instance_id' (int)
MSG_SIM_UNHIDE_NET_ACTOR_REQUESTED, //!< Request revealing of hidden networked actor; used internally by top menubar. Params: 'instance_id' (int)
// GUI
MSG_GUI_OPEN_MENU_REQUESTED,
MSG_GUI_CLOSE_MENU_REQUESTED,
MSG_GUI_OPEN_SELECTOR_REQUESTED, //!< Use `game.showChooser()` instead.
MSG_GUI_CLOSE_SELECTOR_REQUESTED, //!< No params.
MSG_GUI_MP_CLIENTS_REFRESH, //!< No params.
MSG_GUI_SHOW_MESSAGE_BOX_REQUESTED, //!< Use `game.showMessageBox()` instead.
// Editing
MSG_EDI_ENTER_TERRN_EDITOR_REQUESTED, //!< No params.
MSG_EDI_LEAVE_TERRN_EDITOR_REQUESTED, //!< No params.
The demo script now displays a button "Launch simple test terrain" when in menu, as small test. To try it, open ingame console and say 'loadscript demo_script.as'.
There's a new script function
game.pushMessage(MsgType, dictionary@)
which allows you to do practically any state change within the game (load/unload terrain, actor, connect/disconnect multiplayer). The parameters are passed as dictionary. Documentation will be available at http://developer.rigsofrods.org/ after this PR is merged; for now here is a reprint:The demo script now displays a button "Launch simple test terrain" when in menu, as small test. To try it, open ingame console and say 'loadscript demo_script.as'.
This is an example how to spawn https://forum.rigsofrods.org/resources/1996-dodge-viper-gts-coupe.88/
This console snippet spawns Viper GTS directly in front of you:
as quaternion qrot = quaternion((radian(3.14) - game.getPersonRotation()), vector3(0,1,0)); vector3 v3pos = game.getPersonPosition() + (qrot*vector3(-5,0,0)); game.pushMessage(MSG_SIM_SPAWN_ACTOR_REQUESTED, {{'filename', 'vipergts.car'}, {'position', v3pos}, {'rotation', qrot}, {'enter', false}});