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.
Related
So I am trying to make some code that gets information about games using the Roblox API. I do get data back when I send a request, but I can't figure out a way to use the data in the code. Because when I decode it, it looks like this:
{
["data"] = ▼ {
[1] = ▼ {
["allowedGearCategories"] = {},
["allowedGearGenres"] = ▶ {...},
["copyingAllowed"] = false,
["createVipServersAllowed"] = false,
["created"] = <creation date>,
["creator"] = ▶ {...},
["description"] = "",
["favoritedCount"] = 0,
["genre"] = "Comedy",
["id"] = <the id>,
["isAllGenre"] = false,
["isFavoritedByUser"] = false,
["isGenreEnforced"] = true,
["maxPlayers"] = 10,
["name"] = <the name>,
["playing"] = 0,
["rootPlaceId"] = <the id>,
["studioAccessToApisAllowed"] = false,
["universeAvatarType"] = "PlayerChoice",
["updated"] = <update date>,
["visits"] = 0
}
}
}
I censored some of the information about which game it is, but that information isn't important here. The important thing is that it says "1" under "data", and if I type that into the code, it uses it as a number. So I can't access anything further down in the list than "data".
Here is my code, if it helps:
local universe = Proxy:Get("https://api.roblox.com/universes/get-universe-containing-place?placeid="..placeId).body
local universeDecoded = http:JSONDecode(universe)
local universeId = universeDecoded.UniverseId
local placeInfo = http:JSONDecode(Proxy:Get("https://games.roblox.com/v1/games?universeIds="..universeId).body)
print(placeInfo.data)
Also, sorry for not knowing a lot of programming words, so I say stuff like "further down in the list". But I hope it's clear what I mean.
I figured it out myself. I just had to write
print(placeInfo.data[1])
I have the following table
scavenging =
{
{
type = "Greenskin|16",
fast_levelup = 20, --Number of levels with 75% chance to level up after required level
normal_levelup = 40, --Number of levels with 50% chance to level up after fast_levelup + required level
slow_levelup = 40, --Number of levels with 25% chance
drops = --Drops
{
{items = {"Linen", "Bolt of Linen", "Coarse Thread", "Feather", "Cotton"}, droprates = {60, 10, 10, 10, 2}},
},
},
}
This is one data value in a series. I use
function scavenge_meta(scavenge_name)
for _, meta in pairs(scavenging) do
if string.match(meta.type, scavenge_name) then
return meta
end
end
end
to pull the needed data. The question is, is there an easy way to get to the droprates value without having to do a few for (pairs)? Right now for example I can use:
local founditem = scavenge_meta("Greenskin|16")
And this works, and then I can use founditem.fast_levelup etc. I was hoping to access the drops table with founditem.drops.items for example, but this doesn't work, I need to do a pairs(founditem.drops) then pairs(valuefound.items) /etc.
Maybe there is a better way of doing this?
if you can change the table then do:
scavenging =
{
["Greenskin|16"] = {
type = "Greenskin|16",
fast_levelup = 20,
normal_levelup = 40,
slow_levelup = 40,
drops =
{
{items = {"Linen", "Bolt of Linen", "Coarse Thread", "Feather", "Cotton"}, droprates = {60, 10, 10, 10, 2}},
},
},
}
and get data directly by index
print(scavenging["Greenskin|16"].fast_levelup)
otherwise, just by searching as you did.
This may be easier than I'm making it on myself. I am relatively new to Lua, but experienced in other languages.
I have a table that looks like this:
local state = {}
state[1] = {
show = true,
changed = true,
progressType = "static",
value = 0,
total = 9,
name = "nine",
}
state[2] = {
show = true,
changed = true,
progressType = "static",
value = 0,
total = 7,
name = "seven",
}
state[3] = {
show = true,
changed = true,
progressType = "static",
value = 0,
total = 8,
name = "eight",
}
state[4] = {
show = true,
changed = true,
progressType = "static",
value = 0,
total = 6,
name = "six",
}
What I need to do is sort each table[] entry based on the value of table.value5. I can't find any functions in the docs that expressely say they do more than just a basic table.sort so I find myself a bit stuck. Do I need to manually sort by iterating through and creating a new table with the sorted data?
I can't find any functions in the docs that expressely say they do more than just a basic table.sort so I find myself a bit stuck.
I might be misunderstanding your issue, but table.sort is exactly what you need in this case:
local state = {}
state[1] = {
total = 9,
name = "nine",
}
state[2] = {
total = 7,
name = "seven",
}
state[3] = {
total = 8,
name = "eight",
}
state[4] = {
total = 6,
name = "six",
}
-- Use table.sort with a custom anonymous function
-- to specify how to compare the nested tables.
table.sort(state, function (a, b)
return a.total < b.total
end)
for i=1, #state do
print(i, state[i].name)
end
With table.sort you can provide an optional custom function, which can be as easy or complicated as you want it to be. In this case (as per your question) it is enough to simply compare the total values of your table.
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
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