Skip to content

Commit

Permalink
add weather_manager binding
Browse files Browse the repository at this point in the history
  • Loading branch information
ChainsawGarden committed Apr 20, 2022
1 parent b575edd commit f9ce5fb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
21 changes: 21 additions & 0 deletions lua/class_definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,27 @@ classes = {
{ name = "symbol", rval = "int", args = { } },
}
},
weather_manager = {
new = {},
attributes = {
-- placeholder = { type = "", writable = true },
temperature = { type = "int", writable = true },
lightning_active = { type = "bool", writable = true },
winddirection = { type = "int", writable = true },
windspeed = { type = "int", writable = true },
nextweather = { type = "time_point", writable = true },
weather_override = { type = "weather_type_id", writable = true },
},
functions = {
-- { name = "", rval = nil, args = { } },
{ name = "update_weather", rval = nil, args = { } },
{ name = "get_temperature", rval = nil, args = { "tripoint" } },
{ name = "clear_temp_cache", rval = nil, args = { } },
{ name = "set_nextweather", rval = nil, args = { "time_point" } },
{ name = "", rval = nil, args = { } },
-- { name = "", rval = nil, args = { } },
}
},
Creature = {
attributes = {
},
Expand Down
7 changes: 3 additions & 4 deletions src/catalua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,12 @@ void CallbackArgument::Save()
case CallbackArgumentType::Reference_Character:
LuaReference<Character>::push( L, value_character ); // CAT_CHARACTER_ID
break;

case CallbackArgumentType::Weather:
LuaReference<weather_type>::push( L, value_weather ); // CAT_WEATHER_ID
break;
// case CallbackArgumentType::Character:
// LuaValue<Character>::push( L, value_character ); // CAT_CHARACTER_ID
// break;
// case CallbackArgumentType::Weather:
// LuaValue<weather_type>::push( L, value_weather ); // CAT_WEATHER_ID
// break;
default:
lua_pushnil( L );
break;
Expand Down
7 changes: 6 additions & 1 deletion src/catalua.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern "C" {

// modern additions
#include "weather_type.h" // for weather typing stuff
#include "weather.h"
#include "string_input_popup.h" // for string input
#include "item_factory.h" // for item factory stuff
#include "monstergenerator.h" // for mongen stuff
Expand Down Expand Up @@ -59,7 +60,7 @@ enum CallbackArgumentType : int {
Location,
Reference_Character
// Character_Type,
// Weather
Reference_Weather_Manager
};
// callback args
struct CallbackArgument {
Expand All @@ -78,6 +79,7 @@ struct CallbackArgument {
weather_type_id value_weather_id; // value weather is modern
location *value_location; // value location is modern
Character *value_character;
weather_manager *value_weather_manager;

// the below `CallbackArgument` "things" are constructors with various overloads.
// The weird syntax spooked me, but rest assured, ":type(xyz)" & ":value_integer(xyz)" initialize private variables.
Expand Down Expand Up @@ -131,6 +133,9 @@ struct CallbackArgument {
CallbackArgument( Character *arg_value ) :
type( CallbackArgumentType::Reference_Character ), value_character( arg_value ) {
}
CallbackArgument( weather_manager *arg_value ) :
type( CallbackArgumentType::Reference_Weather_Manager ), value_weather_manager( arg_value ) {
}
// CallbackArgument( arg_value ) :
// type( CallbackArgumentType:: ), value_placeholder( arg_value ) {
// }
Expand Down

0 comments on commit f9ce5fb

Please sign in to comment.