Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mrowrpurr/7bd786ac8ab6a94a6955ea056021d352 to your computer and use it in GitHub Desktop.
Save mrowrpurr/7bd786ac8ab6a94a6955ea056021d352 to your computer and use it in GitHub Desktop.
procedure call_me(variable x) begin
display_msg("OMG YOU CALLED ME with: " + x);
return "THIS IS THE RETURN RESULT! " + x;
end
// SETUP CODE
variable __setup_dialogue_procs_compiler_trick_variable = true;
#define setup_dialogue_procs \
__setup_dialogue_procs_compiler_trick_variable = false; \
if __setup_dialogue_procs_compiler_trick_variable then
#define dialogue_proc call
// INVOCATION CODE
variable __dialogue_currently_calling_proc_compiler_trick_variable = true,
__dialogue_currently_calling_proc_fn_name = "",
__dialogue_currently_calling_proc_result;
#define call_dialogue_proc1(fn, arg) \
__dialogue_currently_calling_proc_fn_name = fn; \
__dialogue_currently_calling_proc_result = fn(arg); \
__dialogue_currently_calling_proc_compiler_trick_variable = false; \
if __dialogue_currently_calling_proc_compiler_trick_variable then debug_msg(__dialogue_currently_calling_proc_result)
procedure get_dialogue_proc_result1(variable fn, variable arg) begin
__dialogue_currently_calling_proc_fn_name = fn;
return fn(arg);
end
procedure start begin
if game_loaded then begin
setup_dialogue_procs begin
dialogue_proc call_me(0);
end
display_msg("Calling....");
call_dialogue_proc1("call_me", "YAY!");
display_msg("Called!");
display_msg("Getting....");
variable x = get_dialogue_proc_result1("call_me", "get this!");
display_msg("Got: " + x);
end
end
rocedure call_me(variable x) begin
display_msg("OMG YOU CALLED ME with: " + x);
end
procedure start begin
variable foo = false;
if foo then begin
variable result = call_me("maybe");
debug_msg(result);
end
if game_loaded then begin
variable fn = "call_me";
variable x = fn("Second");
debug_msg("" + x);
display_msg("DID IT WORK?");
end
// if game_loaded then call startup;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment