Phezel Framework (Object communication solution)(WIP)
Author
Message
phezel
Joined: Thu Sep 11, 2014 5:37 pm Posts: 16
Phezel Framework (Object communication solution)(WIP)
Phezel Framework
Hello everybody this is a framework I'm working on to help me program my mod, and I'm sharing it before the mod is finished to help other people make their own.
I will be adding more gifs and help on the use of the framework on the next days.
The Phezel Framework It consist on two things, Phezel Framework and Phezel Wall.
To use decompress the framework in your Cortex Command folder and paste on the top of your actor/s LUA file/s:
Code:
require("Phezel Framework/Phezel Framework");
Phezel Framework Phezel Framework has many helpful functions to make easily your mod. Note: All colors are CC Palette indexes and have a default if you don't set them.
Text This creates a text over the actor (only when active), useful for debugging.
To use this function use this on the Update() function of the actor: This adds a text line, you can add as many as you want
Code:
phezel_framework:add_text('Text');
This shows the text
Code:
phezel_framework:show_text_on_actor(self);
This clears the text list for the next frame
Code:
phezel_framework:clear_text(self);
Math
Get Top Distances This returns a table representing the distances on top of a point. Returns the highest, lowest, and every point it registered depending on the resolution. (see image)
Red Lines not shown in game, just for explanation Using 5 for resolution
pos central point range max distance to check width the width of the section to check resolution the quantity of distances to check root_id root_id of the actor, if any team team of the actor, if any h_flipped, rot_angle not working, don't use
Get Bottom Distances This returns a table representing the distances under a point. Returns the highest, lowest, and every point it registered depending on the resolution. (see images)
Red Lines not shown in game, just for explanation Using 6 for resolution
pos central point range max distance to check width the width of the section to check resolution the quantity of distances to check root_id root_id of the actor, if any team team of the actor, if any h_flipped, rot_angle not working, don't use
Angle to Vector This returns a vector representing an angle. To use this function use this:
Code:
phezel_framework:angle_vector(angle);
angle the angle to transform
Vector to Angle This returns an angle representing a vector. To use this function use this:
Code:
phezel_framework:vector_angle(vector);
vector the vector to transform
Draw
Draw Dotted Number This creates a number in the specified position.
pos position of the number number the number to draw radius size of the number color color of the number align 'c' or 'l', align center or left background if used draws a background of this color
Draw Dotted Text This creates a text in the specified position.
all letters, space, "|", "_", "+", "-", all numbers, ",", ".", "!", "?" With black(245) background
pos position of the text word the text to draw radius size of the characters color color of the text align 'c' or 'l', align center or left background if used draws a background of this color
Draw Smart Line This creates a line between two points leaving some space near the points.
pos_1 and pos_2 the points to connect with a line dot_color color of the dot line_color color of the line
Draw Zone Box This creates two dots and a box between the two leaving some space near the dots. It can be filled. Very useful for marking a zone or a selection box.
pos_1 and pos_2 the points to connect with a box dot_color color of the dot line_color color of the line fill_separation separation of fill lines, if not used draws empty box fill_color color of the fill lines
Draw Dotted Smart Line Same as Smart Line but non contiguous.
Equidistant (every dot keeps the same distance between each other)
pos_1 and pos_2 the points to connect with a line radius space to leave color color of the dots equidistant if the dots are equidistant or not, true or false
Draw Dotted Circle This creates a dotted circle in any position on the map.
pos position of the center of the circle radius radius of the circle color color of the dots equidistant if all the dots have the same separation between each other connect_each if set, connects dots for each #(connect_each)
Cursor This creates a cursor in any position on the map.
pos position of the cursor current_time relative number of current time central_dot if true draws a central dot outter_circle if true draws a circle cross if true draws a cross color color of the cursor
Draw Clock This creates a clock in any position on the map, it's very useful for timed explosives and cooldowns.
pos position of the clock current_time relative number of current time max_time number of max time size size, in the example gif the clocks have 15 and 5 body color of the body of the clock border color of the border of the clock arrow color of the arrow of the clock
Vertical Measure Bar, Gauge and Horizontal Measure Bar, they all show weight.
Draw Gauge This creates a gauge in any position on the map, it's very useful for weight. To use this function:
pos position of the gauge current_value relative current value min_value max number to display max_value min number to display size size, in the example gif the gauge is 15 body color of the body of the gauge border color of the border of the gauge arrow color of the arrow of the gauge min_point color of the mark of the minimum point mid_point color of the mark of the middle point max_point color of the mark of the maximum point
Draw Vertical Measure Bar This creates a vertical measure bar in any position on the map. To use this function:
pos position of the measure bar current_value elative current value max_value max number to display width width of the bar height height of the bar body color of the body of the measure bar border color of the border of the measure bar arrow color of the arrow of the measure bar fill color of the fill of the measure bar marks color of the marks of the measure bar
Draw Horizontal Measure Bar This creates an horizontal measure bar in any position on the map. To use this function:
pos position of the measure bar current_value elative current value max_value max number to display width width of the bar height height of the bar body color of the body of the measure bar border color of the border of the measure bar arrow color of the arrow of the measure bar fill color of the fill of the measure bar marks color of the marks of the measure bar
Phezel Wall Phezel Wall solves the problem of having to use sharpness to comunicate with the inside of every actor in the game.
To use paste this on the first lines of your actor/s Update function:
Code:
if not phezel_wall:check_actor_exist(self) then
phezel_wall:set_actor(self);
end
This returns true if the actor exists in the wall and false otherwise.
Code:
phezel_wall:check_actor_exist(self)
From the outside You can get any variable of the actor with this function:
actor Your actor var_name the name of the variable you want to get, even variables you created var_data the data in the variable You can get the whole actor using this, but I advice to get just the data you are gonna use:
self Your actor And update it at the end of the Update function, so you have updated data on the outside:
Code:
phezel_wall:set_actor(self);
You can use this code in the Destroy function of your actor to keep garbage data at a minimum:
Code:
phezel_wall:destroy_actor(self);
Anyone can use the framework to make their mod, just add a little thank you in the credits. Also don't modify it, it will cause problems with other mods that require it. If you want to add some functionality to the framework, you can create a LUA file in your mod (example, yourmodname_phezel_extention.lua) and create new functions in it:
Code:
function phezel_framework:your_new_function() ... end
Bad Boy for pointing out unnecesary stuff clunatic for helpping with the ID problem
Change Log
2014-09-12 Initial Release
2014-10-01 Framework deprecated rand and calculate_distance added get_distances_top and get_distances_bottom updated draw_zone_box to draw filled zones explained draw_dotted_circle and draw_cursor Wall added check_actor_exist
2014-10-06 Framework added draw_dotted_number and draw_dotted_word explained draw_gauge, draw_measure_bar and draw_measure_bar_hor Wall added destroy_actor
2014-10-07 Framework explained colors
2014-10-09 Framework changed draw_dotted_word to draw_dotted_text added minus symbol and background to draw_dotted_number and numbers, many symbols and background to draw_dotted_text Wall deleted create_actor, get_actor_phezel_id and get_actor_id updated check_actor_exist, set_actor, get_actor, set_actor_var, get_actor_var and destroy_actor fixed need to get a new ID from the Wall
Last edited by phezel on Thu Oct 16, 2014 12:06 am, edited 8 times in total.
Re: Phezel Framework (Object communication solution)(WIP)
Sweet stuff, the get distance stuff seem like they could be pretty useful in some circumstances and the draw stuff are always nice.
Just so you know, the wall stuff is going to be less necessary in the coming version since you'll be able to set a publicly accessible string variable for MOs. Though tables are of course nicer to use than string parsing.
Also, if you really wanted to do the wall thing more impressively than a table: viewtopic.php?f=73&t=19430
Thu Oct 02, 2014 11:00 pm
phezel
Joined: Thu Sep 11, 2014 5:37 pm Posts: 16
Re: Phezel Framework (Object communication solution)(WIP)
Update 2014-10-06 Now the framework let's you write text and numbers to the screen.
Framework added draw_dotted_number and draw_dotted_word explained draw_gauge, draw_measure_bar and draw_measure_bar_hor Wall added destroy_actor
Bad Boy wrote:
Sweet stuff, the get distance stuff seem like they could be pretty useful in some circumstances and the draw stuff are always nice.
Just so you know, the wall stuff is going to be less necessary in the coming version since you'll be able to set a publicly accessible string variable for MOs. Though tables are of course nicer to use than string parsing.
I really hope most of the stuff in the framework stop being necessary in the next builds.
I use the distance stuff for a WIP Floating Drone I'm making, to keep it low but let it 'climb' walls.
Mon Oct 06, 2014 10:43 pm
Arcalane
Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
Re: Phezel Framework (Object communication solution)(WIP)
Some neat stuff here- one thing I'm wondering, though, is what do you use for colour exactly? Looking at the top of the framework file itself suggests some more... unusual scheme (maybe using the CC palette itself?) than RGB/Hex.
Tue Oct 07, 2014 4:33 am
phezel
Joined: Thu Sep 11, 2014 5:37 pm Posts: 16
Re: Phezel Framework (Object communication solution)(WIP)
Arcalane wrote:
Some neat stuff here- one thing I'm wondering, though, is what do you use for colour exactly? Looking at the top of the framework file itself suggests some more... unusual scheme (maybe using the CC palette itself?) than RGB/Hex.
Thanks.
All colors are CC Palette indexes, forgot to mention it.
Update 2014-10-07 Framework explained colors
Tue Oct 07, 2014 4:25 pm
phezel
Joined: Thu Sep 11, 2014 5:37 pm Posts: 16
Re: Phezel Framework (Object communication solution)(WIP)
Mayor Update 2014-10-09 New symbols:
Fixed Wall (thanks clunatic)
Framework changed draw_dotted_word to draw_dotted_text added minus symbol and background to draw_dotted_number and numbers, many symbols and background to draw_dotted_text Wall deleted create_actor, get_actor_phezel_id and get_actor_id updated check_actor_exist, set_actor, get_actor, set_actor_var, get_actor_var and destroy_actor fixed need to get a new ID from the Wall
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum