TylerH Posted December 3, 2009 Share Posted December 3, 2009 I would like some people to look at and find some ways to test out my math_counter entity. Attached Downloads section links are included to an improved base.lua file and the Counter.zip file archive. base.lua just has an added function entity:RelayMessage(message,delay,extra), which simply sends the message to all 8 targets of the entity that you call RelayMessage for. ZIP: http://leadwerks.com...ads&showfile=25 Base Lua: http://leadwerks.com...ads&showfile=26 The Counter folder should be placed in SDK Root/Models/Entities/Math/. (Idea/Icon/Names entirely stolen from Source Engine's Hammer -> math_counter on Source Engine Dev Wiki) Here is a little write-up the entity, what it does, and how to use it: Name: Math Counter Icon: Description: Stores a number (integer or floating point) value and manipulates it via Increments, Decrements, forced Set, Add, Subtract, Multiply, and Divide. It has a startvalue, which is what value will reset to if reset is true and it hits the max or min values. Keys: Start Value, Value, Minimum Legal Value, Maximum Legal Value, Reset (Code friendly: startvalue, value, min, max, reset) Receivable Messages: add(number) - Adds the given number to the value. Triggers outvalue always and passes value as extra. Triggers onhitmin and/or onhitmax if the value is now >= max or <= min. Resets value to startvalue if reset is true. subtracts(number) - Subtracts the given number from the value. Triggers outvalue always and passes value as extra. Triggers onhitmin and/or onhitmax if the value is now >= max or <= min. Resets value to startvalue if reset is true. multiply(number) - Multiplies value by the given number. Triggers outvalue always and passes value as extra. Triggers onhitmin and/or onhitmax if the value is now >= max or <= min. Resets value to startvalue if reset is true. divide(number) - Divides the value by the given number. NOTE: If number is 0, it is set to 1 to prevent divide by zero errors. Triggers outvalue always and passes value as extra. Triggers onhitmin and/or onhitmax if the value is now >= max or <= min. Resets value to startvalue if reset is true. setvalue(number) - Sets the value to the given number. Triggers outvalue always and passes value as extra. Triggers onhitmin and/or onhitmax if the value is now >= max or <= min. setvaluenofire(number) - Sets the value to the given number. Triggers no other events. Use this or directly set the entity key to set the value for future checks and operations. setmin(number) - Sets the minimum legal value to the given number. Triggers no other events. setmax(number) - Sets the maximum legal value to the given number. Triggers no other events. getvalue - Sends the "ongetvalue" message to the entity that sent the "getvalue" message, and passes value. This is best used for entities that are not a target of the counter and need to know the counter's value, or for target's that want to circumvent "setvaluenofire"'s purpose. Sent Messages: onhitmax(self) - Sent when value is >= max. Passes the entity itself as extra. onhitmin(self) - Sent when value is <= min. Passes the entity itself as extra. outvalue(number) - Sent anytime the value is set (exceptions for entity key directly or via setvaluenofire). Passes the value as extra. ongetvalue(number) - Sent to any entity that sends the counter the getvalue message. Passes the value as extra. Please try this out! Thanks, Tyler Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
TylerH Posted December 17, 2009 Author Share Posted December 17, 2009 Bump. Feedback please? Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Rick Posted December 17, 2009 Share Posted December 17, 2009 I think this is a great idea. I haven't had a chance to test/use it though. I don't have a need for this just yet and working on a few other things. The only issue I have is the need for a custom base lua file. This isn't really your fault though as the way this was presented to us wasn't the best solution, but I think it's a big problem for distributing objects. Quote Link to comment Share on other sites More sharing options...
TylerH Posted December 17, 2009 Author Share Posted December 17, 2009 You don't really need the custom base.lua file, you can just move the implementation of entity:RelayMessage into the math_counter.lua script itself. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Rick Posted December 17, 2009 Share Posted December 17, 2009 Why didn't you do that instead of making a new base lua file? It's much more attractive if the entity is all inclusive. Quote Link to comment Share on other sites More sharing options...
TylerH Posted December 18, 2009 Author Share Posted December 18, 2009 Because I made the modified base.lua 3 days before I made math_counter, in an attempt to expand the base of the framework to support a Hammer-Like Input/Output system. Ofcourse. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer ----- Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.