Corona SDK crash when trying to combine filters/effects - lua

I am trying to create new effect by combining existing ones and Corona Simulator crashes.
Here is my code
graphics.defineEffect({
language = "glsl",
category = "filter",
name = "myEffect",
graph = {
gray = { effect = "filter.grayscale", input1 = "paint1" },
--final = { effect = "filter.contrast", input1 = "gray" },
},
output = "gray"
});
local rect = display.newRect(100, 100, 100, 100);
rect:setFillColor(1, 0, 0);
rect.fill.effect = "filter.myEffect";
Also question about arguments for filter. How can I specify arguments for filter contrast in this sample?
Thank you

This was recently bringing trouble to me too. I found it to be solvable by declaring the graph definitions of the effects in a nodes table.
I included the solution and corrected syntax below.
graphics.defineEffect({
language = "glsl",
category = "filter",
name = "myEffect",
graph = {
nodes = {
gray = { effect = "filter.grayscale", input1 = "paint1" }
--final = { effect = "filter.contrast", input1 = "gray" },
},
output = "gray"
}
})
local rect = display.newRect(100, 100, 100, 100);
rect:setFillColor(1, 0, 0);
rect.fill.effect = "filter.myEffect";
Regarding the contrast questions, excuse me if I misunderstood but this should be a viable solution
graphics.defineEffect({
language = "glsl",
category = "filter",
name = "myEffect",
graph = {
nodes = {
gray = { effect = "filter.grayscale", input1 = "paint1" },
final = { effect = "filter.contrast", input1 = "gray" }
},
output = "final"
}
})
local rect = display.newRect(100, 100, 100, 100);
rect:setFillColor(1, 0, 0);
rect.fill.effect = "filter.myEffect";
rect.fill.effect.final.contrast = 2
A good introduction to this is Tutorial: Multi-Pass Shaders in Graphics 2.0 by Bryan Smith

Related

lua setteam issue with another job

In the current example we have two different jobs, one is an ST, and the other is a Jedi, in this case Anakin Skywalker. The difference between the two professions, is in the code according to my opinion possibly none, I'm not sure in this regard, however, unlike the ST job in the game itself I can enter /setteam name ST to become the job, this does not happen with the job for the Jedi.
TEAM_ST = DarkRP.createJob("ST", {
color = Color(0, 0, 0),
model = "models/hazel/cg_models/1_et/cg_et.mdl",
description = [[
Ein ausgebildeter Klonsoldat
]],
weapons = {
"comlink_swep",
"cross_arms_swep",
"cross_arms_infront_swep",
"hololink_swep",
"point_in_direction_swep",
"salute_swep",
"surrender_animation_swep"
},
command = "ST",
max = 99,
salary = 10,
admin = 0,
vote = false,
hasLicense = false,
category = "Klon",
canDemote = false,
PlayerSpawn = function(ply)
ply:SetHealth(100)
ply:SetMaxHealth(100)
ply:SetArmor(100)
ply:SetMaxArmor(100)
end,
})
TEAM_AS = DarkRP.createJob("Anakin Skywalker", {
color = Color(0, 0, 0),
model = "models/kaiido/anakin/anakin.mdl",
description = [[
Ein mächtiger Jedi-Schüler
]],
weapons = {
"comlink_swep",
"cross_arms_swep",
"cross_arms_infront_swep",
"hololink_swep",
"point_in_direction_swep",
"salute_swep",
"surrender_animation_swep"
},
command = "AS",
max = 1,
salary = 15,
admin = 0,
vote = false,
hasLicense = false,
category = "Jedi",
canDemote = false,
PlayerSpawn = function(ply)
ply:SetHealth(5000)
ply:SetMaxHealth(5000)
ply:SetArmor(100)
ply:SetMaxArmor(100)
end,
})
Any idea about my problem?
I basically tried to recreate the job several times, looking for erroneous characters or blanks etc, I didn't find anything.

How to use values ​from one module script in another module script?

Faced such problem: it is necessary to use values ​​from other module script in one module script. Both module scripts contain tables with float, boolean and string values. How in theory can this be done and is it possible at all? And if not, what are the alternative solutions? I read on the forum that this can be done, but how exactly was not explained anywhere.
For example.
One module script:
local characters = {
["CharacterOne"] = {
["Health"] = 100,
["InGroup"] = false,
["Eating"] = {"Fruit", "Meat"}
};
["CharacterTwo"] = {
["Health"] = 260,
["InGroup"] = true,
["Eating"] = {"Meat"}
}
}
return characters
Two module script:
local food = {
["Fruit"] = {
["Saturation"] = 20,
["Price"] = 2
},
["Meat"] = {
["Saturation"] = 50,
["Price"] = 7
}
}
return food
The documentation for ModuleScripts tells you how to use them in other source containers: the require function.
So assuming that you've named your ModuleScripts Characters and Food respectively, and assuming that they are siblings in a folder, you could utilize the require function like this :
local Food = require(script.Parent.Food)
local characters = {
["CharacterOne"] = {
["Health"] = 100,
["InGroup"] = false,
["Eating"] = { Food.Fruit, Food.Meat }
};
["CharacterTwo"] = {
["Health"] = 260,
["InGroup"] = true,
["Eating"] = { Food.Meat }
}
}
return characters

What is the meaning of "mode" in the following code?

function setup()
return {
properties = {
default_mode = mode.driving,
default_speed = 10,
oneway_handling = true,
side_road_multiplier = 0.8,
turn_penalty = 7.5,
speed_reduction = 0.8,
turn_bias = 1.075,
cardinal_directions = false
}}
I'm reading a piece of code and got deeply confused about the meaning of "default_mode = mode.driving". I mean, what is this "mode"? Is it a variable a maybe a table? A not-defined table I guess? Any comments are greatly appreciated.

Formating lua code - any tool?

Hi so i recently decoded some game scripts written in lua. But it looks like this
My code looks like this
PlayerTable = { JOGO = 0, BALANCE = 0, BALANCE_P = 0, PROFIT = 0, XXX = 0, XXX_Count = 0, XXX_Player = 0, AH, AL, NUM, LOSETOP = { Times = 0, Money = 0, Name }, WINTOP = { Times = 0, Money = 0, Name } } end if PlayerTable.JOGO == Games.NULL then if 0 < PlayerTable.BALANCE then if table.contains(words.H, Message) then PlayerTable.JOGO = Games.HIGH if HL_ENABLED then Last_Payout = os.time() MinOption = BetOption[PlayerTable.JOGO].Min MaxOption = BetOption[PlayerTable.JOGO].Max PayoutOption = BetOption[PlayerTable.JOGO].Payout else if not table.contains(LimitSay.DISABLED, name) then Self.Say(Disabled_G[PlayerTable.JOGO]) table.insert(LimitSay.DISABLED, name) end PlayerTable.JOGO = Games.NULL end elseif table.contains(words.L, Message) then PlayerTable.JOGO = Games.LOW if HL_ENABLED then
I know there are HTML, JS etc. beautifiers so Is there any tool i can use to beautify this code ?
Or do i need to do it manually ? Its almost 2000 lines of code so i would rather not to do this manually.
You could use ZeroBrane. Basically select the code and then Edit-> Source -> Correct Indentation

Microsoft charts: transparency

I want a chart with transparent background, and therefore PNG seems a good choice. But when I set transparent background, the quality of the axis labels falls dramatically. How do I fix this? See the following code. As it stands, the chart has a transparent background, as I want, but the text quality is atrocious. If I comment out the two "Color.Transparent" settings, then the text quality is nice, but the background is not transparent.
How do I get transparency and nice text?
public static void Main(string[] args)
{
Chart c = new Chart();
c.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
Series s = new Series("Series1");
c.Series.Clear();
c.Series.Add(s);
s.ChartType = SeriesChartType.Line;
s.Color = Color.Black;
ChartArea chartArea = new ChartArea("ChartArea1");
c.ChartAreas.Clear();
c.ChartAreas.Add(chartArea);
chartArea.BackColor = Color.FromArgb(255, 255, 255);
chartArea.BackSecondaryColor = Color.FromArgb(220, 220, 220);
chartArea.BackGradientStyle = GradientStyle.TopBottom;
chartArea.AxisX.LineColor = Color.Gray;
chartArea.AxisX.LineWidth = 2;
chartArea.AxisX.LineDashStyle = ChartDashStyle.Solid;
chartArea.AxisY.LineColor = Color.Gray;
chartArea.AxisY.LineWidth = 2;
chartArea.AxisY.LineDashStyle = ChartDashStyle.Solid;
chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
c.BackColor = Color.Transparent;
chartArea.BackColor = Color.Transparent;
double[] x = new double[] { 1999, 2005 };
double[] y = new double[] { 3210, 13456 };
Axis ay = chartArea.AxisY;
ay.Maximum = 13456;
ay.Minimum = 3210;
Axis ax = chartArea.AxisX;
ax.Maximum = 2005;
ax.Minimum = 1999;
for (int i = 0; i < x.Length; i++)
{
double xvalue = x[i];
double yvalue = y[i];
s.Points.AddXY(xvalue, yvalue);
}
// Save chart-image to disk:
c.SaveImage("chartimage.png", ChartImageFormat.Png);
}
Set chart's AntiAliasing to AntiAliasingStyles.Graphics to disable the antialiasing on text.
Taken from this thread.
Maybe this help you
in your .aspx file where your chart code is, look for the asp:ChartArea tag. then add BackColor = "Transparent".
<asp:ChartArea Name="ChartArea1" BackColor="Transparent"
</asp:ChartArea>
Hope this help.
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.SystemDefault;
I read this from here: http://forums.asp.net/p/1656335/4315304.aspx?Re%20Chart%20transparency%20and%20text%20quality

Resources