HOOK_TARGETOBJECT hook not working.

Mulligun

Still Mildly Glowing
I'm trying to use the HOOK_DESCRIPTIONOBJ hook but it seems to not work. I've teased other hooks (like the HOOK_TARGETOBJECT or HOOK_MOUSECLICK) and it does work.
 
The hook works, you are doing something wrong. Nobody can help you if you don't post your script.
 
The hook works, you are doing something wrong. Nobody can help you if you don't post your script.
I's just so simple, but ok, here You have:
Code:
procedure my_item_desc begin
  display_msg("Item new desc");
end
...
procedure start begin
   variable who, cur_dmg_thresh, cur_dmg_resist, color, msg, m;

   if(game_loaded) then begin
     register_hook_proc(HOOK_DESCRIPTIONOBJ, my_item_desc);
   end
...
end
 
It works for me.
kaQqVAV.jpg
 
I's just so simple

Well, it's simply wrong. You don't understand how the Sfall function works.

Code:
procedure my_item_desc begin
   variable
      item := obj_pid(get_sfall_arg),
      description;
  
   if (item == PID_MyItem) then begin
         description := get_string_pointer(message_str(SCRIPT_FARMPART, 101));
         set_sfall_return(description);
   end
end

/Edit: NovaRain's post now had me question if you want to change the text in the message log or on the item itself? In any case, you need to add a condition to check which item should be changed, otherwise all will be.
 
Last edited:
I's just so simple, but ok, here You have:
Code:
procedure my_item_desc begin
  display_msg("Item new desc");
end
...
procedure start begin
   variable who, cur_dmg_thresh, cur_dmg_resist, color, msg, m;

   if(game_loaded) then begin
     register_hook_proc(HOOK_DESCRIPTIONOBJ, my_item_desc);
   end
...
end
And now when i click on an scenery object, say a pot and select "examine" nothing happens...
What i'm doing wrong?
 
You give way too little details of what you actually want to do. Also where are you running the hook? Item script or global script? Are you testing ingame or in the mapper?
 
You give way too little details of what you actually want to do. Also where are you running the hook? Item script or global script? Are you testing ingame or in the mapper?
I'm running it in a global script. Testing ingame.
Ok, i seems that I've misunderstand the hook triggering conditions (https://github.com/phobos2077/sfall/issues/293). It indeed does work with the inventory items but i'd like it to work for a scenery objects as i said a pot or a wall...
 
Uh, but you don't need a hook script for that. You just write a new scenery script and overwrite the description in there.
 
Ok, but what/which hook i have to use to handle events:
1. hovering over a critter
2. clicking on the critter (not in a combat mode like with HOOK_TARGETOBJECT!)
???
 
Are you serious? Is this still about changing the message log text? There is no hook needed for that. Just look at the Fallout 2 scripts, that stuff is everywhere.

Code:
procedure look_at_p_proc begin
   script_overrides;
   display_msg("my text on mouse over");
end

procedure description_p_proc begin
   script_overrides;
   display_msg("my text on binocular");
end
 
Are you serious? Is this still about changing the message log text? There is no hook needed for that. Just look at the Fallout 2 scripts, that stuff is everywhere.

Code:
procedure look_at_p_proc begin
   script_overrides;
   display_msg("my text on mouse over");
end

procedure description_p_proc begin
   script_overrides;
   display_msg("my text on binocular");
end
Ok, thx
Another question. Can You provide me an working example of the interface_print function? I've tried setting the text with all of the defined interface windows (WINTYPE_INVENTORY, WINTYPE_DIALOG, WINTYPE_IFACEBAR an so on) but in all cases no text was displayed anywhere...
 
Code:
// print
SetFont(103);
overlay_create(WINTYPE_IFACEBAR);
interface_print("Hello World!", WINTYPE_IFACEBAR, 10, 10, 105);

// clear
overlay_clear(WINTYPE_IFACEBAR);
b0rDuM9.png
 
Never used it before, so can't really help with that.
 
Code:
// print
SetFont(103);
overlay_create(WINTYPE_IFACEBAR);
interface_print("Hello World!", WINTYPE_IFACEBAR, 10, 10, 105);

// clear
overlay_clear(WINTYPE_IFACEBAR);
b0rDuM9.png
Sorry, but getting: Unknown name identifier overlay_create...
 
Sorry, but getting: Unknown name identifier overlay_create...
Oh, I forgot I use a new function in the coming release.
Just ignore overlay_create/clear for now, the two lines can print the text as well.
Code:
SetFont(103);
interface_print("Hello World!", WINTYPE_INVENTORY, 10, 10, 105);
mfMV1dX.png
 
Oh, I forgot I use a new function in the coming release.
Just ignore overlay_create/clear for now, the two lines can print the text as well.
Code:
SetFont(103);
interface_print("Hello World!", WINTYPE_INVENTORY, 10, 10, 105);
mfMV1dX.png
Ok, thx, that's work:-)
But I'm still wondering if is there a way to modify/rewrite the float_msg function to respect the control chars?
 
Back
Top