Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New callbacks for LUA #21744

Merged
merged 5 commits into from Sep 10, 2018

Conversation

Projects
None yet
5 participants
@ZhilkinSerg
Copy link
Contributor

commented Aug 29, 2017

Summary

SUMMARY: Features "Added more Lua callback (some with arguments)"

Purpose of change

Expand Lua-modding possibilites.

Describe the solution

Following Lua-callbacks were added:

game-related:

  • on_savegame_loaded runs when saved game is loaded;
  • on_weather_changed(weather_new, weather_old) runs when weather is changed.

calendar-related:

  • on_turn_passed runs once each turn (once per 6 seconds or 10 times per minute);
  • on_hour_passed runs once per hour (at the beginning of the hour);
  • on_year_passed runs once per year (on first day of the year at midnight).

player-related:

  • on_player_skill_increased(skill_increased_source, skill_increased_id, skill_increased_level) runs whenever player skill is increased (previously known as on_skill_increased);
  • on_player_dodge(source_dodge,difficulty_dodge) runs whenever player have dodged;
  • on_player_hit(source_hit, body_part_hit) runs whenever player were hit;
  • on_player_hurt(source_hurt, disturb) runs whenever player were hurt;
  • on_player_mutation_gain(mutation_gained) runs whenever player gains mutation;
  • on_player_mutation_loss(mutation_lost) runs whenever player loses mutation;
  • on_player_stat_change(stat_changed,stat_value) runs whenever player stats are changed;
  • on_player_effect_int_changes(effect_changed, effect_intensity, effect_bodypart) runs whenever intensity of effect on player has changed;
  • on_player_item_wear(item_last_worn) runs whenever player wears some clothes on;
  • on_player_item_takeoff(item_last_taken_off) runs whenever player takes some clothes off;
  • on_mission_assignment(mission_assigned) runs whenever player is assigned to mission;
  • on_mission_finished(mission_finished) runs whenever player finishes the mission.

mapgen-related:

  • on_mapgen_finished(mapgen_generator_type, mapgen_terrain_type_id, mapgen_terrain_coordinates) runs whenever builtin, json or lua mapgen is finished generating.

Some callbacks provide arguments which can be useful (see example mod).

Additional context:

I want to utilize this in in my dda-lua mod:

  • more granular processing of time-based events (when something is happening around the player each turn);
  • count how many missions player has started/finished/failed (for achievements);
  • chance to rip apart clothes when player with high STR or low DEX/INT tries to take off or wear some clothes (for fun);
  • simplify post-processing of mapgen terrain (like I did in Degrade Buildings mod, but without need to add lua node to mapgen json).

This was referenced Aug 29, 2017

@macrosblackd

This comment has been minimized.

Copy link
Contributor

commented Aug 30, 2017

You might want to consider passing the various arguments to the lua callbacks so that the lua code doesn't have to try and figure things out manually.

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2017

You might want to consider passing the various arguments to the lua callbacks so that the lua code doesn't have to try and figure things out manually.

Thanks for the suggestion. I've also considered this - some of the callbacks will greatly benefit from this (like, immediately knowing which stat was changed or which item was taken off will make lua-modding simplier).

I've already started looking into it, but it will only make sense if anything new regarding lua will be ever merged.

@ZhilkinSerg ZhilkinSerg changed the title [CR] Several callbacks for LUA [CR] New callbacks for LUA Aug 30, 2017

/**
* Execute a callback that can be overriden by all mods with 2 argument(s) put to global table (_G).
*/
void lua_callback( const char *callback_name, const char *callback_arg1, const char *callback_arg2 );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Aug 30, 2017

Contributor

Variables / parameters with numbers in them are a code smell - use a vector or similar instead. You don't need n callback functions, only one generic.

Even better would be a function template, so the caller doesn't need to convert everything into a string, which the Lua code has to convert back into whatever it actually is.

This comment has been minimized.

Copy link
@ZhilkinSerg

ZhilkinSerg Aug 30, 2017

Author Contributor

Variables / parameters with numbers in them are a code smell - use a vector or similar instead. You don't need n callback functions, only one generic.

Even better would be a function template, so the caller doesn't need to convert everything into a string, which the Lua code has to convert back into whatever it actually is.

I've tried using cstdarg and its ..., but didn't achieve good results - if I understood it right, all of the parameters should be of the same type, but it will be required to have multiple types in a single callback. Same goes for using vector - it can only contain variables of single type.

I've decided to use string for test purposes for the time being as it nicely fits for various numbers and string identifiers, but I will definitely need to rework this as I will need references to certain objects.

I didn't work with function templates previously, but I believe it is something about preprocessor magic, right?

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2017

../cataclysm.a(game.o): In function `game::start_game(std::string)':

game.cpp:(.text+0x3a727): undefined reference to `lua_callback(char const*, char const*, char const*, char const*)'

Very strange - build compiles via MSYS2 in Code::Blocks on Windows locally without such issues...

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Sep 1, 2017

So, following code compiles, runs and works perfectly when, but when same code is put to catalua.cpp it gives out compilation error:

undefined reference to `void lua_callback<char const*>(char const*, char const*)`.
#include <iostream>

template<typename ArgType> void lua_callback_store_arg(
    const int callback_arg_idx, ArgType callback_arg )
{

    const char *callback_arg_name = std::string( "callback_arg" + std::to_string(
                                        callback_arg_idx ) ).c_str();

    std::cout << callback_arg_name << ": " << callback_arg << std::endl;
}

void lua_callback_store_args( const int callback_arg_idx )
{
    std::cout << "callback_arg_count: " << callback_arg_idx - 1 << std::endl;
}

template<typename ArgType, typename... Args> void lua_callback_store_args(
    const int callback_arg_idx, ArgType callback_arg,
    Args... callback_args )
{
    lua_callback_store_arg( callback_arg_idx, callback_arg );
    lua_callback_store_args( callback_arg_idx + 1, callback_args... );
}

void lua_callback( const char *callback_name )
{
    std::cout << "callback_last: " << callback_name << std::endl;
}

template<typename ... Args> void lua_callback( const char *callback_name, Args... callback_args )
{

    lua_callback_store_args( 1, callback_args... );
    lua_callback( callback_name );
}

int main()
{

    lua_callback( "callbacktest", 1, 3, '1', "234234", 1.67f );

    lua_callback( "callbacktest2" );
    lua_callback( "callbacktest3", "test" );


}
@Coolthulhu

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2017

It's rather massive, padded due to the styling.
I wouldn't consider small size a prerequisite to merging, but it's hard to separate changes from padding here.
Here are some hints to help make it easier for us (and thus to get this thing through faster):

  • Push a PR astyling catalua.cpp. In the PR here, a lot of lines are just styling, thus heavily padding the overall size
  • If there are any non-styling changes left to the C++ side of the game, PR those second.
  • Finally, push the new lua hooks and the mod that verifies they work. The mod should probably be in docs/sample_mods, not data/mods
@BevapDin

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2017

So, following code compiles, runs and works perfectly when, but when same code is put to catalua.cpp it gives out compilation error:
undefined reference to void lua_callback<char const*>(char const*, char const*).

Yes, because that function template is never instantiated as it's only defined in the cpp file. You can force an instantiation by adding this line to the cpp file:

template void lua_callback<const char*>( const char*, const char* );
@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Sep 2, 2017

Yes, because that function template is never instantiated as it's only defined in the cpp file. You can force an instantiation by adding this line to the cpp file:

template void lua_callback<const char*>( const char*, const char* );

Thanks, it really helped.

@ZhilkinSerg ZhilkinSerg changed the title [CR] New callbacks for LUA [WIP] New callbacks for LUA Oct 3, 2017

// possible callback arguments: skill_increase_type, skill_id, skill_level_new
const static auto skill_increase_type = "training";
const static auto skill_id = skill.ident().c_str();
const static auto skill_level_new = std::to_string( new_skill_level ).c_str();

This comment has been minimized.

Copy link
@BevapDin

BevapDin Oct 4, 2017

Contributor

This creates a dangling pointer. to_string returns a value that only exists until the end of the expression. The pointer from c_str is invalid after that. Why don't you put all those values directly into the function call instead of having several variables that are used only once anyway?

This comment has been minimized.

Copy link
@ZhilkinSerg

ZhilkinSerg Oct 4, 2017

Author Contributor

Thanks, will change that.

That is just a stub, btw. I'm trying to figure out convinient way of transferring callback arguments (which come in different type and numbers) to lua. I'm not sure yet what is the best approach.

// possible callback arguments: skill_increase_type, skill_id, skill_level_new
const static auto skill_increase_type = "book";
const static auto skill_id = skill.c_str();
const static auto skill_level_new = std::to_string( originalSkillLevel + 1 ).c_str();

This comment has been minimized.

Copy link
@BevapDin

BevapDin Oct 4, 2017

Contributor

Same here. Btw. please use to_string without the std:: prefix. See "src/compatibility.h", some systems seem to have trouble with std::to_string (it is called without the prefix throughout the code).

// possible callback arguments: skill_increase_type, skill_id, skill_level_new
const static auto skill_increase_type = "practice";
const static auto skill_id = skill.ident().c_str();
const static auto skill_level_new = std::to_string( newLevel ).c_str();

This comment has been minimized.

Copy link
@BevapDin

BevapDin Oct 4, 2017

Contributor

And here.

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Oct 4, 2017

Still struggling with Travis...

The error is the following:

../cataclysm.a(mapgen.o): In function `mapgen_function_lua::generate(map*, int_id<oter_t> const&, mapgendata const&, int, float)':

mapgen.cpp:(.text+0xad43): undefined reference to `void lua_callback<char const*, char const*>(char const*, char const*, char const*)'

I've added following code to catalua.cpp and as I understand that should've been enough to instantiate my template functions, but it isn't so for Travis.

template void lua_callback<const char *>( const char *, const char * );
template void lua_callback<const char *>( const char *, const char *, const char * );
template void lua_callback<const char *>( const char *, const char *, const char *, const char * );
@BevapDin

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2017

The error is the following:
../cataclysm.a(mapgen.o): In function `mapgen_function_lua::generate(map*, int_id<oter_t> const&, mapgendata const&, int, float)':

mapgen.cpp:(.text+0xad43): undefined reference to `void lua_callback<char const*, char const*>(char const*, char const*, char const*)'

I've added following code to catalua.cpp and as I understand that should've been enough to instantiate my template functions, but it isn't so for Travis.
template void lua_callback<const char *>( const char *, const char * );
template void lua_callback<const char *>( const char *, const char *, const char * );
template void lua_callback<const char *>( const char *, const char *, const char *, const char * );

Look carefully at the error message. The linker expected a function named lua_callback<char const*, char const*>, you instantiated lua_callback<const char *> (several times). In other words: you need to add matching template parameters there:

template void lua_callback<const char *>( const char *, const char * );
template void lua_callback<const char *, const char *>( const char *, const char *, const char * );
template void lua_callback<const char *, const char *, const char *>( const char *, const char *, const char *, const char * );

And it may be required to put those lines after the definition of lua_callback (at the end of the file, into the part that is compiled with and without LUA enabled, because those functions are required for both build types).

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Oct 4, 2017

And it may be required to put those lines after the definition of lua_callback (at the end of the file, into the part that is compiled with and without LUA enabled, because those functions are required for both build types).

Thanks a lot! That was the case. My fault was that I tried to compile only LUA build locally and skipped non-LUA. The latter one failed to build on my workstation too until I moved template instantiation to block shared between both builds.

const int callback_arg_idx, ArgType callback_arg )
{
const char *callback_arg_name = std::string( "callback_arg" + std::to_string(
callback_arg_idx ) ).c_str();

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 18, 2018

Contributor

You should probably avoid all the raw C-strings and use std::string (and for parameters const std::string &) instead.

The usage of callback_arg_name below invokes undefined behaviour as it is no longer a valid pointer. c_str here is invoked on a temporary object and the result is only valid as long as that std::string object stays unchanged, but it's deconstructed at the end of this expression.

This comment has been minimized.

Copy link
@ZhilkinSerg

ZhilkinSerg Mar 18, 2018

Author Contributor

There were some issues with ellipsis ... and non c_str, so I used it everywhere. Anyway I decided to refactor the way attributes are transfered to callbacks.

lua_callback("on_minute_passed");
}

// Run a LUA callback once per turn
if( calendar::once_every( 1_turns ) ) {

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 18, 2018

Contributor

This check is a bit pointless as it will be true all the time. (game::do_turn is called once for each turn, it actually increments the turn counter.)

} else {
add_msg( m_good, _( "%s increases their %s level." ), learner->disp_name().c_str(),
skill.obj().name().c_str() );
skill.obj().name().c_str(), skill.obj().name().c_str() );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 18, 2018

Contributor

The message foprmat string only contains two "%s", and there are already two arguments for thos placeholders. Why have you added a third argument (identicaly to the second one), that is never used?

This comment has been minimized.

Copy link
@ZhilkinSerg

ZhilkinSerg Mar 18, 2018

Author Contributor

I do not remember why I duplicated this :)

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Mar 18, 2018

Is it CLANG only warning (-Wnon-pod-varargs)?

src/mapgen.cpp:214:76: error: cannot pass object of non-trivial type 'const string_id<oter_t>' through variadic function; call will abort at runtime.

I do not have error during compilation or in runtime when compiled in Visual Studio and it works pretty good:

image

image

@ZhilkinSerg ZhilkinSerg force-pushed the ZhilkinSerg:lua-callbacks branch from 263fea8 to e0fa5ae Mar 19, 2018

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Mar 19, 2018

Haha! And it finally compiles in Jenkins, Travis and locally. Thanks to @BevapDin - you past suggestions and feedback helped me a lot. I really appreciate this!

image

image

Output from `\config\dda-lua-test-callback.log`
2018-03-19 23:29:26|<color_cyan>     function: </color><color_ltcyan>on_game_loaded</color>
2018-03-19 23:29:26|callback_last: <color_yellow>nil</color>
2018-03-19 23:29:26|callback_arg_count: <color_red>nil</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_stat_change</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_stat_change</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>2</color>
2018-03-19 23:29:28|stat_changed: <color_green>pain</color>
2018-03-19 23:29:28|stat_value: <color_green>0</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_mutation_gain</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_mutation_gain</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:28|mutation_gained: <color_green>TERRIFYING</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_mutation_gain</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_mutation_gain</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:28|mutation_gained: <color_green>FLEET</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_mutation_gain</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_mutation_gain</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:28|mutation_gained: <color_green>SPIRITUAL</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_stat_change</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_stat_change</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>2</color>
2018-03-19 23:29:28|stat_changed: <color_green>thirst</color>
2018-03-19 23:29:28|stat_value: <color_green>0</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_stat_change</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_stat_change</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>2</color>
2018-03-19 23:29:28|stat_changed: <color_green>hunger</color>
2018-03-19 23:29:28|stat_value: <color_green>0</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_stat_change</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_stat_change</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>2</color>
2018-03-19 23:29:28|stat_changed: <color_green>fatigue</color>
2018-03-19 23:29:28|stat_value: <color_green>0</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_stat_change</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_stat_change</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>2</color>
2018-03-19 23:29:28|stat_changed: <color_green>pkill</color>
2018-03-19 23:29:28|stat_value: <color_green>0</color>
2018-03-19 23:29:28|<color_cyan>     function: </color><color_ltcyan>on_stat_change</color>
2018-03-19 23:29:28|callback_last: <color_yellow>on_stat_change</color>
2018-03-19 23:29:28|callback_arg_count: <color_red>2</color>
2018-03-19 23:29:28|stat_changed: <color_green>perceived_pain</color>
2018-03-19 23:29:28|stat_value: <color_green>0</color>
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BC02B8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>pair of socks (fits)
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BBF538</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>briefs (fits)
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BC04F8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>suit (fits)
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BBFE38</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>skinny tie
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BBF1D8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>tie clip
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BC0198</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>pair of dress shoes (fits)
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BC0078</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>knit scarf
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BBFF58</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>wrist watch (left)
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_item_wear</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_item_wear</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>1</color>
2018-03-19 23:29:53|item_last_worn: <color_green>userdata: 0000020805BBFAD8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C4060</color>
2018-03-19 23:29:53|LUA:You put on your <color_light_green>|| </color>briefcase (right)
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>json</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>shelter</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020807C87048</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002087EE8A188</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002087EE944C8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002087EE9E908</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 00000208097E1E48</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 00000208097EC0C8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 00000208097F5508</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809B49C58</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809B52F18</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809B5CDD8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809B45918</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 00000208095657D8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080956EED8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809557F18</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080969E508</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809687F88</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020809690C88</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A2784C8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A282788</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>road_ns</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A26BA88</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>road_ns</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A274F48</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>road_end_south</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A0A9948</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A0B3608</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080A09C308</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080883F108</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 00000208088472C8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020808830188</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080883ADC8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020808950B58</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 000002080895B158</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020808964418</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]
2018-03-19 23:29:53|<color_cyan>     function: </color><color_ltcyan>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_last: <color_yellow>on_mapgen_finished</color>
2018-03-19 23:29:53|callback_arg_count: <color_red>3</color>
2018-03-19 23:29:53|mapgen_generator_type: <color_green>builtin</color>
2018-03-19 23:29:53|mapgen_terrain_type_id: <color_green>field</color>
2018-03-19 23:29:53|mapgen_terrain_coordinates: <color_green>userdata: 0000020808A805D8</color>
2018-03-19 23:29:53|callback_function: <color_magenta>function: 00000208062C39A0</color>
2018-03-19 23:29:53|LUA:tripoint is [nil;nil;nil]

@ZhilkinSerg ZhilkinSerg changed the title [WIP] New callbacks for LUA New callbacks for LUA Mar 19, 2018


lua_callback("on_skill_increased");
CallbackArgumentContainer lua_callback_args_info;
lua_callback_args_info.emplace_back( CallbackArgument( "skill_increased_source", "training" ) );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 21, 2018

Contributor

When you use one of the emplace functions of a standard container, you don't need to create an object of the contained type. The emplace functions construct such an object on their own and forward all there arguments to its constructor.

In short: some_container.emplace_back( 1, 2, 3, 4 ) is (mostly) the same as some_container.push_back( Type( 1, 2, 3, 4 ) ).

lua_delete_global( "mutation_gained" );
lua_delete_global( "mutation_lost" );
lua_delete_global( "stat_changed" );
lua_delete_global( "stat_value" );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 21, 2018

Contributor

This looks wrong. Why should there be a global list of all possible parameters to the callback functions? What if someone adds a new callback and forgets to add the parameter name here?

Your CallbackArgumentContainer type already knows the names of all parameters, so it can be used to remove only those variables in Lua that were actually set up.

This comment has been minimized.

Copy link
@ZhilkinSerg

ZhilkinSerg Mar 21, 2018

Author Contributor

Actually, I want to clean existing callback arguments whenever new callback is raised. Maybe I should simply create a table in _G named callback_arguments, store all callback arguments there and clean this table?

* Execute a callback that can be overridden by all mods,
* storing provided callback arguments in _G.
*/
void lua_callback( const char *callback_name, CallbackArgumentContainer callback_args );

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 21, 2018

Contributor

Why does this function take a copy of the CallbackArgumentContainer object and not just a const reference?

std::string GetValueString() {
return value_string;
}
tripoint GetValueTripoint() {

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 21, 2018

Contributor

All these getter functions are non-const, why? They don't change the object in any way.

type = "double";
value_double = arg_value;
};
CallbackArgument( std::string arg_name, float arg_value ) {

This comment has been minimized.

Copy link
@BevapDin

BevapDin Mar 21, 2018

Contributor

Lua does not have separate float and double types. Creating a CallbackArgument with a float will behave the same as one with a double (in both cases lua_pushnumber is called).

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Jul 7, 2018

@BevapDin, I've commented in your BevapDin:lua-callbacks branch - e4df085#r29628987

@ZhilkinSerg ZhilkinSerg reopened this Sep 6, 2018

@ZhilkinSerg ZhilkinSerg force-pushed the ZhilkinSerg:lua-callbacks branch from e7d09df Sep 6, 2018

@ZhilkinSerg ZhilkinSerg closed this Sep 6, 2018

@lispcoc

This comment has been minimized.

Copy link
Contributor

commented Sep 8, 2018

Do you still plan to mainline these callbacks? I would like to use these.

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Sep 8, 2018

Yes. They will be mainlined, but I wanted to refactor something first.

@ZhilkinSerg ZhilkinSerg reopened this Sep 9, 2018

@ZhilkinSerg ZhilkinSerg closed this Sep 9, 2018

@ZhilkinSerg ZhilkinSerg reopened this Sep 10, 2018

@ZhilkinSerg ZhilkinSerg force-pushed the ZhilkinSerg:lua-callbacks branch to 83b4caa Sep 10, 2018

@ZhilkinSerg ZhilkinSerg force-pushed the ZhilkinSerg:lua-callbacks branch from 8bdf49e to 2959ace Sep 10, 2018

@ZhilkinSerg ZhilkinSerg merged commit 17101c4 into CleverRaven:master Sep 10, 2018

1 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
gorgon-ghprb Build finished.
Details
@lispcoc

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2018

good job! but i am a little concerned about player-related callback runs when npc satisfies conditions.

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Sep 11, 2018

good job! but i am a little concerned about player-related callback runs when npc satisfies conditions.

These are player-specific callbacks which should not affect npcs.

Edit: You were right though - callbacks are raised for npcs too. I will update callbacks to be player-only.

@ZhilkinSerg

This comment has been minimized.

Copy link
Contributor Author

commented Sep 11, 2018

See #25540 for follow-up.

@lispcoc

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2018

OH, thx!!!

@ZhilkinSerg ZhilkinSerg deleted the ZhilkinSerg:lua-callbacks branch Sep 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.