Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,33 @@ bool Game_Interpreter::CommandControlSwitches(lcf::rpg::EventCommand const& com)
}

bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com) { // code 10220

if (!com.string.empty()){
std::string periodName = Utils::LowerCase(ToString(com.string));
int32_t outputVariable = ValueOrVariable(com.parameters[0], com.parameters[1]);

std::time_t t = std::time(nullptr);
std::tm* tm = std::localtime(&t);

int32_t dateOutput{};

if (periodName == "getyear") dateOutput = tm->tm_year + 1900;
if (periodName == "getmonth") dateOutput = tm->tm_mon + 1;
if (periodName == "getday") dateOutput = tm->tm_mday;
if (periodName == "gethour") dateOutput = tm->tm_hour;
if (periodName == "getminute") dateOutput = tm->tm_min;
if (periodName == "getsecond") dateOutput = tm->tm_sec;
if (periodName == "getweekday") dateOutput = tm->tm_wday + 1;
if (periodName == "getyearday") dateOutput = tm->tm_yday + 1;
if (periodName == "getdaylightsavings") dateOutput = tm->tm_isdst + 1;
if (periodName == "gettimestamp") dateOutput = t;

Main_Data::game_variables->Set(outputVariable, dateOutput);
Game_Map::SetNeedRefresh(true);

return true;
}

int value = 0;
int operand = com.parameters[4];

Expand Down
1 change: 1 addition & 0 deletions src/game_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class Game_Interpreter
bool CommandManiacChangePictureId(lcf::rpg::EventCommand const& com);
bool CommandManiacSetGameOption(lcf::rpg::EventCommand const& com);
bool CommandManiacCallCommand(lcf::rpg::EventCommand const& com);
bool CommandGetTime(lcf::rpg::EventCommand const& com);

int DecodeInt(lcf::DBArray<int32_t>::const_iterator& it);
const std::string DecodeString(lcf::DBArray<int32_t>::const_iterator& it);
Expand Down