Welcome, Guest. Please login or register.
Did you miss your activation email?
November 25, 2024, 07:16:46 PM
Home Help Login Register
News: Trouble in Terrorist Town? Site here, forum here.

Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Custom scoring event.
Pages: [1]
Author Topic: Custom scoring event.  (Read 3149 times)
ljdp
Poster

Posts: 13


« on: January 02, 2011, 10:57:24 AM »

There doesn't seem to be a way of creating a custom event for the endgame review, without touching core files.
If there isn't, it'd be nice if there was was just an EVENT_CUSTOM.
For example SCORE:AddEvent( { id = EVENT_CUSTOM, text = "Custom event happened" } )
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #1 on: January 02, 2011, 12:36:50 PM »

It's possible, but you'd have to override a number of CLSCORE functions.

EVENT_PANTS = 800 -- unique number that I won't be using anytime soon

-- ... during the round at some point
if SERVER then SCORE:AddEvent({id=EVENT_PANTS, num=23}) end
-- ...

if CLIENT then
  -- reroute CLSCORE function to handle our custom event
  local oldTextForEvent = CLSCORE.TextForEvent
  function CLSCORE:TextForEvent(e)
     if e.id == EVENT_PANTS then
        return "Someone wore " .. e.num .. " pants."
     end

     -- process other events as usual
     return oldTextForEvent(self, e)
  end

  -- do the same for IconForEvent

end


Still, would be nice to have a better way.

I don't like the idea of an EVENT_CUSTOM where the server has to send the entire text to clients, that's quite a lot of data.

It would be pretty easy to have something like this:
CLSCORE.DeclareEventDisplay(EVENT_PANTS,
                           { text = function(e)
                                       return "Someone wore " .. e.num .. "pants."
                                    end,
                             icon = function(e)
                                       return myiconmaterial, "MyTooltip"
                                    end
                          })

I believe all the existing events could be implemented this way, so it should be sufficient.
« Last Edit: January 11, 2011, 01:18:07 PM by Bad King Urgrain »
Bad King Urgrain
Administrator
*****
Posts: 12276



« Reply #2 on: January 11, 2011, 01:18:57 PM »

This has been added in SVN r770.
Pages: [1]
Zombie Master  |  Other  |  Trouble in Terrorist Town  |  Topic: Custom scoring event. « previous next »
Jump to:  


Login with username, password and session length

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.014 seconds with 17 queries.