It kicks me with coding this script.
function attach()
-- Will be called when a backdoor is found
notify("Backdoor Found")
settings.Found = true
STATUS.Text = "Attached: "..settings.BackdoorRemote:GetFullName()
for _, button in pairs(SIDEBAR:GetChildren()) do
if button.ClassName == "ImageButton" and button ~= uiIndex.CurrentButton then
button.ImageColor3 = Color3.fromRGB(255, 255, 255)
end
end end
How?
I tried to attach it with my own gui button, when i press that button. it doesnt work, It kicks me with "nil" value.
Do not tell me ImageColor3, ImageButton, Color3, etc is not displayed
I want to exploit into my game. or Inactive Backdoored Games.
Like is there no argument or something?
Related
The below is a self-explanatory love2d program sample of mine. The variable 'state' determines the state of the game, i.e, 'play' & 'menu'. The initial state is 'menu' and what is expected to happen here is when first right-clicked, the state changes to 'play', and on further second right-click the variable printMsg is set to true as a result of which a message is printed inside function love.draw().
function love.load()
state = 'menu'
end
function love.draw()
if printMsg == true then
love.graphics.print('mousepressed')
end
end
function love.mousepressed(x, y, button)
if state == 'menu' and button == 1 then
state = 'play'
end
if state == 'play' and button == 1 then
printMsg = true
end
end
I have 2 issues here:
On the first click itself the message is printed because the program tends to think that the first click is also the second click.
Without having to create a variable printMsg to actually print the message, I want to print the message at the instance the button is pressed. What I mean is:
function love.load()
state = 'menu'
end
function love.draw()
end
function love.mousepressed(x, y, button)
if state == 'menu' and button == 1 then
state = 'play'
end
if state == 'play' and button == 1 then
love.graphics.print('mousepressed')
end
end
but unfortunately, this prints nothing.
You enter the second if statement because you assign 'play' to state. hence the condition of the second if statement is true.
If only one of those things should happen:
if state == 'menu' and button == 1 then
state = 'play'
elseif state == 'play' and button == 1 then
love.graphics.print('mousepressed')
end
or
if button == 1 then
if state == 'menu' then
state = 'play'
elseif state == 'play' then
love.graphics.print('mousepressed')
end
end
or if you can only have those two options you can omit one of the conditions:
if button == 1 then
if state == 'menu' then
state = 'play'
else
love.graphics.print('mousepressed')
end
end
Note that this print will not result in any output. By default Love2d will clear the screen befor invoking love.draw. So anything you print outside love.draw is not taken into account.
Either exclusively draw in love.draw or avoid clearing the frame buffer by implementing your own love.run.
The standard color for text is: Black
And the standard color for background is: Black
I guess therefore it is printed but you cant see it.
Try love.graphics.setColor(1, 1, 1, 1) before love.graphics.print() in love.draw().
( Before each drawable )
Look: https://love2d.org/wiki/love.graphics.setColor
I'm working on a game in which I have a bunch of overlays and one scene which is called game.lua. I wanted to make it, when I press back button (hardware button on Android device), game would, if there's an overlay, close the overlay and if there's no overlay (just game.lua scene), it would show exitmenu.lua(simple pop-up menu).
function onKeyEvent( event )
if(event.keyName == "back") then
local CurrentScene = composer.getSceneName("current")
local CurrentOverlay = composer.getSceneName("overlay")
if CurrentScene == "Scenes.game" and CurrentOverlay == nil then
composer.showOverlay("Scenes.exitmenu", {isModal = true})
return true
elseif CurrentOverlay ~= nil and CurrentOverlay ~= "Scenes.exitmenu" then
composer.hideOverlay("fade", 500)
return true
end
end
end
Runtime:addEventListener("key", onKeyEvent)
What happens is, when I press back button while overlay is on, function hides the overlay and also shows exitmenu.lua overlay. I have no idea what is wrong with my code, any advice is highly appreciated.
EDIT: I've fixed it! I needed to add and event.phase == "down", which makes my button press do function only once. That was the fix.
I have this script in a brick:
local giver = 1
function onClicked()
game.Players.[I NEED THE PLAYER NAME HERE].leaderstats.Clicks.Value = game.Players.[I NEED THE PLAYER NAME HERE].leaderstats.Clicks.Value + giver
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Now I need to somehow get the player's name that clicked it and put it where I need to.
The ClickDetectors's MouseClick event have the "Clicking Player" as parameter, so you can do it like this:
local giver = 1
function onClicked(Player)
Player.leaderstats.Clicks.Value = Player.leaderstats.Clicks.Value + giver
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
However, this requires the FilteringEnabled to be set to false (not recomended).
To solve this, make a LocalScript in the brick with the code:
script.Parent.ClickDetector.MouseClick:connect(function(Player)
game.ReplicatedStorage:WaitForChild("BrickClick"):InvokeServer(script.Parent)
end)
And in a Script placed in the ServerScriptService put:
local Listener = game.ReplicatedStorage:FindFirstChild("BrickClick")
if Listener == nil then
Listener = Instance.new("RemoteFunction")
Listener.Name = "BrickClick"
Listener.Parent = game.ReplicatedStorage
end
function Listener.OnServerInvoke(Player,Brick)
Player.leaderstats.Clicks.Value = Player.leaderstats.Clicks.Value + 1
end
I won't point you to the wiki page for further reading, even thought it contains a bit of what you need, it contains too little information.
The ClickDetector's MouseClick info, the guide about FilteringEnabled and the guide about RemoteFunctions are better.
Try this!
script.Parent.MouseClick:Connect(function(Player)
-- Kill The Player
-- The parameter is referring to game.Players So if you want to do a kill button use .Character
Player.Character:BreakJoints()
-- Change The Color To Red (Other details)
script.Parent.Parent.BrickColor = BrickColor.new("Really red")
script.Parent.MaxActivationDistance = 0
-- Wait 4 Secs
wait(5)
-- Change The Color To Green
script.Parent.Parent.BrickColor = BrickColor.new("Lime green")
script.Parent.MaxActivationDistance = 50
end)
I'm trying to have a different amount of force applied to an object when the screen is tapped a different amount of times ( only once and twice ).
I'm not sure what I'm doing wrong. Here is the code:
local function moveUp(event)
if event.numTaps > 1 then
jumper:applyForce( 0, 250, jumper.x, jumper.y )
elseif event.numTaps < 1 then
jumper:applyForce( 0, 0, jumper.x, jumper.y )
else
jumper:applyForce( 0, 200, jumper.x, jumper.y )
end
end
-- start game
createPlayScreen( )
system.setTapDelay( 2 )
Runtime:addEventListener("tap", moveUp)
I've tried moving the Runtime:addEventListener into the function. I've also tried have the event.numTaps == 2 and event.numTaps == 1, but to no avail.
The issue is that the TapDelay refuses to wait for the second tap.
Any and all help is greatly appreciated
P.S. I have the seconds set to two for testing purposes, but once I find that this works, I will be lowering the time to like 0.3 or something
There are several issues with the strategy you are using. For one, it is not scalable (to more than two taps). But ok, maybe you are 100% sure you will never ever need more than 2 taps. The next problem is that event.numTaps can only be 1 or 2, yet your listener tests for < 1! This can never happen. The next problem is that when you tap twice, at least in the simulator (did not test on device) you get two events: one for the first tap with numTaps = 1, and another for 2nd tap with numTaps = 2. In other words, the Corona engine does not wait before emitting a one-tap event to know if a second tap event occurs within some time range. So you get two tap events for a two-tap event, there is no way of knowing in the handler whether you should "wait" to see if another tap might occur within an allowable delay to constitute a "two-tap" event instead.
What you will have to do is create your own N-tap event generator. Whenever a tap occurs, check if your timer has been started. If so, increase the tap count and reset the timer. If not, start the timer that expires some short delay later. If no other tap occurs in that delay, the count you have saved is your tap number. Reset the counter if your timer expires. I have created some functions that do this and I have put them all in a table "object":
local tapEvents = {
measureInterTapTime = false, -- set to true to measure how fast you can tap!
onTapHandler = nil, -- set this to your handler
-- implementation details
tapTimer = nil,
tapCounter = 0,
tapEventTime = 0,
doneTap = function(self, event)
self.tapTimer = nil
if self.onTapHandler then
self.onTapHandler(self.tapCounter)
end
self.tapCounter = 0
self.tapEventTime = 0
end,
-- end implementation details
tap = function(self, event)
self.tapCounter = self.tapCounter + 1
if self.tapTimer ~= nil then
timer.cancel(self.tapTimer)
self.tapTimer = nil
end
local delayMS = 250
self.tapTimer = timer.performWithDelay(delayMS, function(e) self:doneTap(e) end, 1)
-- check how much time between taps, for interest:
if self.measureInterTapTime then
if self.tapEventTime ~= 0 then
local interTapTime = system.getTimer() - self.tapEventTime
print("Time (ms) between taps:", interTapTime)
end
self.tapEventTime = system.getTimer()
end
end,
}
tapEvents.onTapHandler = function(tapCounter)
print(tapCounter .. "-tap event")
end
-- because tapEvents contains a 'tap' function, will get called automatically with self:
Runtime:addEventListener('tap', tapEvents)
This captures N-tap events without limit!! I have included a flag you can set to true if you want to print out the ms delay between single taps so you can determine what the optimum delay should be (you don't want delay to be too short or you might inadvertently break an N tap into two smaller events; you don't want it to be too long either, or user will have to noticeably wait to indicate "end of my multitap").
Tap events must be added to a display object, not to the Runtime.
If you have a display object jumper for example, use:
jumper:addEventListener("tap", moveUp)
More documentation here: http://docs.coronalabs.com/api/event/tap/index.html
Is there a way to ask the users a question in the middle of gaming or after the users won/lost the game? The code below is a code i wrote to ask for the players for consent and I changed it a bit. I'm not sure how should I change it though, plus I wanted to send the response as a email to myself.
--Asking user a question, response is printed out in the Simulator Output and emailed to me
local alert = native.showAlert( "Question", "Are the controls difficult to master?", { "Yes", "No" }, gameFun )
local function gameFun( event )
print( "User's decision is ".. event.index .. " User answered the question " .. event.action )
local action = event.action
if "clicked" == event.action then
if 2 == event.index then
end
elseif "cancelled" == event.action then
-- our cancelAlert timer function dismissed the alert so do nothing
end
end
Ok, i have now changed my codes a bit, i think i could use an alert box only once so i've done this:
function gameFun()
balloonText.isVisible = false
balloonTextt.isVisible = false
balloonTexttt.isVisible = false
questionText.isVisible = false
askUser = display.newText(
'Is the cannon hard to use? Rate it at a scale of 1-5(5 the best)',
display.contentCenterX,
display.contentWidth / 4,
native.systemFont, 20 )
askUser:setFillColor(135, 75, 44)
yesBtn = display.newImage("Yes.png",120,290)
noBtn = display.newImage("No.png",190,290)
end
function gameFunListener(action)
if (action=='add') then
yesBtn:addEventListener ('tap', sendMail())
noBtn:addEventListener ('tap', sendMail())
else
yesBtn:removeEventListener ('tap', sendMail())
noBtn:removeEventListener ('tap', sendMail())
end
end
I've created a new function which will ask users a question, if the users press yes or no, they will go to the email option where they could send a email and tell me. But for some reason the buttons don't work and it jumps to write a email.
Some place in your game (like an enterFrame event handler, or other event handler) your game determines that user has won or lost. This is where you call your askQuestion() (or survey) function. There are many ways to do this, but basically
if you are using storyboard, you would make the question a new scene that you transition to (currentScene.gotoScene("newscene"));
otherwise (no storyboard) you could make some of the visible display objects invisible, instantiate some question widgets (text for question, buttons for answers, etc) and make those visible
When last question answered, you restore the view to what it was before questions (or show a "game over" page etc). Corona, as other GUI, is based on events that result from user action (press button, enter text, move an object to collide with another, etc), and system events (enterFrame, orientation, suspend/resume, etc), so the trigger that causes the display of your questions is in one of those event handlers.
For example:
function gameFun()
balloonText.isVisible = false
...
askUser = display.newText(
'Is the cannon hard to use? Rate it at a scale of 1-5(5 the best)',
display.contentCenterX,
display.contentWidth / 4,
native.systemFont, 20 )
askUser:setFillColor(135, 75, 44)
yesBtn = display.newImage("Yes.png",120,290)
noBtn = display.newImage("No.png",190,290)
yesBtn:addEventListener ('tap', processAnswer)
noBtn:addEventListener ('tap', processAnswer)
end
function processAnswer(event)
if event.target == noBtn then
...
else
...
end
sendMail()
askUser.isVisible = false
yesBtn.isVisible = false
...
yesBtn:removeEventListener ('tap', processAnswer)
noBtn:removeEventListener ('tap', processAnswer)
end
Beware than when you register a listener, you must not call the function that you are registering (no () after the function name)! Also, if you create your question display objects at the beginning and then just toggle their visibility on in gameFun and off in processAnswer, then you don't need to worry about removeEventListener: they will respond to tap only while visible.