View unanswered posts | View active topics It is currently Sun Apr 23, 2017 8:55 am



Reply to topic  [ 6 posts ] 
 Phezel Framework (Object communication solution)(WIP) 
Author Message

Joined: Thu Sep 11, 2014 5:37 pm
Posts: 16
Reply with quote
Post Phezel Framework (Object communication solution)(WIP)
Image 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.

Here is a link to the mod:
Phezel Industries

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)

To use this function use this:
Code:
phezel_framework:get_distances_top(pos, range, width, resolution, root_id, team, h_flipped, rot_angle);
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)

To use this function use this:
Code:
phezel_framework:get_distances_bottom(pos, range, width, resolution, root_id, team, h_flipped, rot_angle);
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.

To use this function:
Code:
phezel_framework:draw_dotted_number(pos, number, radius, color, align, background);
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.

To use this function:
Code:
phezel_framework:draw_dotted_text(pos, text, radius, color, align, 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.

To use this function:
Code:
phezel_framework:draw_smart_line(pos_1, pos_2, radius, color);
pos_1 and pos_2 the points to connect with a line
radius space to leave
color color of the line

Draw Dot
Just draws a filled circle, but it overrides the color of it if not set, mostly for internal use.
To use this function:
Code:
phezel_framework:draw_dot(pos, radius, color);
pos position of the dot
radius radius of the dot
color color of the dot

Draw Dot Line
This creates two dots and a line between the two leaving some space near the dots.

To use this function:
Code:
phezel_framework:draw_dot_line(pos_1, pos_2, dot_color, line_color);
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.

To use this function:
Code:
phezel_framework:draw_zone_box(pos_1, pos_2, dot_color, line_color, fill_separation, fill_color);
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.

To use this function:
Code:
phezel_framework:draw_dotted_smart_line(pos_1, pos_2, radius, color, equidistant);
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.

To use this function:
Code:
phezel_framework:draw_dotted_circle(pos, radius, color, equidistant, connect_each);
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.

To use this function:
Code:
phezel_framework:draw_cursor(pos, central_dot, outter_circle, cross, color);
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.

To use this function:
Code:
phezel_framework:draw_clock(pos, current_time, max_time, size, body, border, arrow);
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:
Code:
phezel_framework:draw_gauge(pos, current_value, min_value, max_value, size, body, border, arrow, min_point, mid_point, max_point);
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:
Code:
phezel_framework:draw_measure_bar(pos, current_value, max_value, width, height, body, border, arrow, fill, marks);
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:
Code:
phezel_framework:draw_measure_bar_hor(pos, current_value, max_value, width, height, body, border, arrow, fill, marks);
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:
Code:
var_data = phezel_wall:get_actor_var(actor, 'var_name');
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:
Code:
phezel_wall:get_actor(actor);

Then you can save that variable with new data:
Code:
phezel_wall:set_actor_var(actor, 'var_name', new_data);
new_data the new data to save in the variable

From the inside
Finally you can get the external data inside the actor using these in the Update function:
Code:
self.var_name = phezel_wall:get_actor_var(self, 'var_name');
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

Then require it after the framework:
Code:
require("Phezel Framework/Phezel Framework");
require("Your Mod/yourmodname_phezel_extention");



Files:
Attachment:
File comment: Compressed folder containing the framework. 2014-10-09 Update.
Phezel Framework.rar [4.87 KiB]
Downloaded 98 times

Old:


Thanks to ...

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.



Thu Oct 02, 2014 6:17 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 608
Location: Halifax, Canada
Reply with quote
Post 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
Profile

Joined: Thu Sep 11, 2014 5:37 pm
Posts: 16
Reply with quote
Post Re: Phezel Framework (Object communication solution)(WIP)
Update
2014-10-06
Now the framework let's you write text and numbers to the screen.
Image
Image

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
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1608
Location: UK
Reply with quote
Post 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
Profile YIM

Joined: Thu Sep 11, 2014 5:37 pm
Posts: 16
Reply with quote
Post 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
Profile

Joined: Thu Sep 11, 2014 5:37 pm
Posts: 16
Reply with quote
Post Re: Phezel Framework (Object communication solution)(WIP)
Mayor Update
2014-10-09
New symbols:
Image
Image
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


Thu Oct 09, 2014 8:19 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.045s | 18 Queries | GZIP : Off ]