Skip to content

Commit

Permalink
allow writing to pause state
Browse files Browse the repository at this point in the history
  • Loading branch information
spacek531 committed May 23, 2024
1 parent ce626b6 commit e55766a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/openrct2/scripting/bindings/game/ScContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ namespace OpenRCT2::Scripting
return GameIsPaused();
}

void paused_set(const bool& value)
{
# ifndef DISABLE_NETWORK
if (NetworkGetMode() != NETWORK_MODE_NONE)
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
duk_error(ctx, DUK_ERR_ERROR, "Setting paused state is not network safe. Use the pausetoggle game action instead.");
return;
}
# endif
if (value != GameIsPaused())
PauseToggle();
}

void captureImage(const DukValue& options)
{
auto ctx = GetContext()->GetScriptEngine().GetContext();
Expand Down Expand Up @@ -438,7 +452,7 @@ namespace OpenRCT2::Scripting
dukglue_register_property(ctx, &ScContext::sharedStorage_get, nullptr, "sharedStorage");
dukglue_register_method(ctx, &ScContext::getParkStorage, "getParkStorage");
dukglue_register_property(ctx, &ScContext::mode_get, nullptr, "mode");
dukglue_register_property(ctx, &ScContext::paused_get, nullptr, "paused");
dukglue_register_property(ctx, &ScContext::paused_get, &ScContext::paused_set, "paused");
dukglue_register_method(ctx, &ScContext::captureImage, "captureImage");
dukglue_register_method(ctx, &ScContext::getObject, "getObject");
dukglue_register_method(ctx, &ScContext::getAllObjects, "getAllObjects");
Expand Down

0 comments on commit e55766a

Please sign in to comment.