DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • December 18, 2018, 09:06:45 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: things that will need core modifications  (Read 6651 times)
0 Members and 1 Guest are viewing this topic.
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« on: August 20, 2004, 07:38:41 AM »

the goal is to get away from having to edit any code at all right?
what about things like lonny's medallion contest?
how about the commons addition?
...those are just examples, i am sure there are applications for other mods too.
how about emoticons?  is it possible to add a hook in the the comentary function?

yes, i am back to 'newb' status with .9.8.  let's just get that back in the open. Tongue
Logged

TazRebel
Guest
« Reply #1 on: August 20, 2004, 07:48:21 AM »

yeppers
Logged
lonnyl
Guest
« Reply #2 on: August 20, 2004, 08:01:40 AM »

I have actually been working on replacing the commons location code with a function that strips everthing down to the page name and uses the page name for the location.... so.... to put the other players here message on a page all you have to do is drop in the funcion.... my next step was/is some other funcions that can be used for reporting location in other areas.... setting location without the who's here message...  a function for checking who's there for interaction.... etc..... but.... with 0.9.8 I haven't been doing much new with 0.9.7... I've kind of been on vacation from modding.. with only small changes here or there.
Logged
Kendaer
Guest
« Reply #3 on: August 20, 2004, 08:03:24 AM »

All of the things you mentioned there should be possible to do with the current hooks

The commons stuff would mostly likely be done with 'header-*' hooks (yes, you'd need to hook on the 'header-<whatever>' hook for every place you wanted, but it is doable.

Similarly the medallion stuff can be done with the various hooks existant.

There might need to be a commentary hook, but it's doable (I have a vague recollection of there being one, but cannot check for the second).
Logged
lonnyl
Guest
« Reply #4 on: August 20, 2004, 08:04:24 AM »

the goal is to get away from having to edit any code at all right?
what about things like lonny's medallion contest?
how about the commons addition?
...those are just examples, i am sure there are applications for other mods too.
how about emoticons?  is it possible to add a hook in the the comentary function?

yes, i am back to 'newb' status with .9.8.  let's just get that back in the open. Tongue

the medallion contest  and commons addition would simply need hooks.... maybe a pagehook function could be made.... that would read the page (village.php) name and make a hook automatically..... so one could simply hook into a page by adding the function.... etc... (this may already exist, I haven't had time to look too closely at the 0.9.8 code)....   Maybe a checkday hook could be made.... so many possibilities...
Logged
sixf00t4
Mod God
*****
Offline Offline

Posts: 1916



View Profile WWW
« Reply #5 on: August 20, 2004, 08:10:49 AM »

thanks lonny and kendaer.  I'm trying to grasp this 'hooks' concept.  I hate not being able to just sit down and understand everything, i just take this 15 minute crash sessions looking at the code and such.

There is no master list of all the hooks available are there Kendaer?
Logged

Kendaer
Guest
« Reply #6 on: August 20, 2004, 10:02:28 AM »

the medallion contest  and commons addition would simply need hooks.... maybe a pagehook function could be made.... that would read the page (village.php) name and make a hook automatically..... so one could simply hook into a page by adding the function.... etc... (this may already exist, I haven't had time to look too closely at the 0.9.8 code)....   Maybe a checkday hook could be made.... so many possibilities...

Those already exist Lonny.

header-page (ie, header-village, header-bank, header-forest, etc)
footer-page (ie, footer-village, etc)

« Last Edit: August 20, 2004, 10:03:04 AM by Kendaer » Logged
Kendaer
Guest
« Reply #7 on: August 20, 2004, 10:07:59 AM »

thanks lonny and kendaer.  I'm trying to grasp this 'hooks' concept.  I hate not being able to just sit down and understand everything, i just take this 15 minute crash sessions looking at the code and such.

There is no master list of all the hooks available are there Kendaer?

No, there is no master list.
Hooks are effectively arbitrary constructs.
Some place registers as listening for a hook (addhook("foo") in a module)
Now, if someone goes and adds modulehook("foo") (or modulehook("foo", somearrayofargs)) somewhere in the code, those modules which have registered for hook foo will get a call to their module_dohook function with the hookname of foo and the args array being the array passed (or an empty array if none were).  Each hook is free to define what it expects as part of the args array, etc.

Hooks can be added just by adding calls to modulehook() somewhere in the code with whatever name.  They effectively do nothing unless and until someone adds a call to addhook from a module with the same name.

They are an extremely powerful mechanism for tying code together indirectly and that's exactly what we're doing here.  They aren't necessarily easy to grasp, but the expenditure of time to do so is well worth it.

Let me know if you need more explanation and I'll try to provide it, but the actual arbitrary nature of it (and the fact that modules can define their own hooks to call!) make it impossible to have a 'master list'.
Logged
strider
Guest
« Reply #8 on: August 20, 2004, 12:42:22 PM »

You know, I think we'd all probably benefit from a little more schooling on the hooks concepts, m'dear JT.
Logged
Kendaer
Guest
« Reply #9 on: August 20, 2004, 12:58:55 PM »

The problem, strider, is that to me it's such an obvious and intuitive concept that I don't quite know how to explain it.  This is why I'm not a good teacher Smiley

If you have specific questions I can try to answer them, but just hope I won't confuse you in the process Smiley
Logged
Talisman
Administrator
Mod God
*****
Offline Offline

Posts: 5481



View Profile WWW
« Reply #10 on: August 20, 2004, 02:17:18 PM »

Correct me if I'm wrong...

1. The module installation line for addhook creates an entry in either the module_hooks or module_event_hooks table as appropriate.  Each entry in the table has three fields:  module name, hook name and function.

   -  Module name is obviously the name of the module
   -  hook name is the hook(s) defined in the moduleinstall function.  For example, something run on the player at newday, such as a check to see if Audrey leaves you, points to the newday hook.
   -  function is the function within the module which is executed when the hook is called.  Seems to normally be modulename_dohook

2.  When a page loads (I'll stick with newday) and parses it's lines, it comes to 'modulehook("nameofhook",array)', which is a function in /lib/modules.php.  Pages may have several hooks, for example newday has newday-intercept, setrace, chooserace, pre-newday, newday-runonce and newday.

3.  The modulehook function checks the module_hooks table for entries meeting the page/hook criteria, then runs the indicated function of each module.
Logged

Play the latest beta version here on DragonPrime
Kendaer
Guest
« Reply #11 on: August 20, 2004, 03:05:18 PM »

That's exactly correct Talisman.
Logged
Spider
Guest
« Reply #12 on: August 22, 2004, 09:36:55 AM »

There might need to be a commentary hook, but it's doable (I have a vague recollection of there being one, but cannot check for the second).

I was just thinking about some LotGD things and I remembered this discussion...

emoticons should be easy enough using the same approach as the drinks module takes to making people drunk should it not?
Logged
Kendaer
Guest
« Reply #13 on: August 22, 2004, 12:23:32 PM »

I was just thinking about some LotGD things and I remembered this discussion...

emoticons should be easy enough using the same approach as the drinks module takes to making people drunk should it not?

Yup.. in fact that was the commentary hook I was talking about Smiley
I was pretty sure it was there for doing things like drunk speech, but since someone asked I waffled and didn't have time to check.. yes, there is a hook called commentary.
Look at the code around it in drinks.php and you should even be able to figure out how to use it to do emoticons if you *really* want.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Please take the time to read the FAQ and browse the DragonPedia

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
23 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search