is that an offer Ed?
I don’t have any money . That’s why I’m doing it myself
You think you can help ?
That is not an offer. Only a suggestion.
I may be completely wrong, but as I read these questions I see a lack of understanding relative to the things @comeUp264 (changed to HRH…) wants to accomplish. So much so, that for anyone to help would require a significant expenditure of time and effort as well as a series of very long answers with accompanying downloadable content, links to resources, et al.
These questions are being asked simply, but the topics are not simple.
In short, I don’t see progress being made on these questions any time soon w/o some dedicated and direct assistance.
Again, I’m not offering but I do think it may be time for @comeUp264 (changed to HRH…) to:
- Simplify goals.
- OR -
- Get a pro (i.e. paid person) to help.
I offer firebase plugins ( not including corona fcm plugin)
https://marketplace.coronalabs.com/search?search=Firebase
I don’t know how decated you are you own server but it is a great option if you don’t want to do any code setup.
My networking skills are very limited, so I don’t think I can help much.
Thanks .
I don’t know what else I have to say when I ask a question . I always say what I need to .
Even when you think this, there is is always a little more everyone can do.
It seems like right now you need some basic PHP knowledge. Try going to udemy.com and look for a cheap, introductory level, PHP course.
Instead of putting everything in an array , can I just select them one by one ? For example : select username from the users table , later select the news feed posts from the posts table , pictures from pictures table etc .
Also how do I block someone on here ?
Can you share some code?
It’s really t same as last time .
auth_login.php:
if(!isset($\_SESSION['username'])){ echo"Download the app"; die(); }
profile.php:
include("auth\_login.php"); echo $\_SESSION['username'];
profile.lua:
local userName local userNameText local userName = tostring(userName) display.newText( userName, display.contentCenterX, display.contentCenterY, native.systemFont, 20 ) local function networkListener( event ) if ( event.isError ) then local alert = native.showAlert( "Error Loading .", "Check your internet connection .", { "Try again" } ) end end function scene:create(event) local screenGroup = self.view local background = display.newImageRect("insta.jpg",display.contentWidth,display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY screenGroup:insert(background) local userNameText = display.newText(userName, 200, 200, native.systemFont, 30 ) userNameText:setFillColor( 1, 0, 0 ) screenGroup:insert(userNameText) end
Per Forum Rules https://coronalabs.com/forum-rules/ #2 - Post only once, I’ve locked your other thread. The discussion needs to stay here. Also important is rule #13 - “Please limit bumping”.
While we want to limit bumping, it is preferable than creating a new post. Just understand that it takes time for the right people to see your post and you need to respect that. Therefore we ask that you give your threads a couple of days without a response before you ask for more help on the thread. This has the effect of bringing it back to the top of the recent posts lists (i.e. bumping it to the top).
These rules exist so that we have a strong community.
You asked “How can I block someone on here?” You can go to “Your Settings” at the top of the page. From there click on ‘Ignore’ preferences. You can then add people to block. See:
In your other post, you said the answer offered here was too complex and then you posted code that may not really help anyone answer your question.
Now looking at the code in the other post (which may have been useful to post here instead), in your network request listener, you are not sending any information to profile.lua. You have these two lines of code:
composer.gotoScene("newsfeed")
That line of code will cause your “newsfeed.lua” scene to load. No information is being sent to it since you didn’t provide the extra parameters.
params = { username , score=currentScore }
This line of code creates a global variable named params that contains a table with an array-like element with the username variable and a key-value pair named score with the current score. There are several issues with this. First it’s global. Secondly you shouldn’t mix key-value type tables and array-like index tables in the same table. However I honestly don’t believe that’s what you’re trying to do. What I think you wanted to do is pass that information to the newsfeed scene. In that case your composer.gotoScene should look like:
composer.gotoScene( "newsfeed", { params = { username = username, score = currentScore } } )
Now that still may not work because it makes a huge assumption that you have a variable named “username” that is scoped so this function can see it and that it has a value in it. You’ve not shown enough code to let us know if this will work. But assuming that username exists, it should work. Note: There is additional work to do in newsfeed.lua.
One thing when you look at this is that you see username = username. The left side one is a key name in a table. The right one is the value to store in the keyname. It might be more helpful for you to learn this in a different way:
local parametersToSend = {} parametersToSend = username parametersToSend = currentScore composer.gotoScene( "newsfeed", { params = parametersToSend } )
Again you have to make sure at this point in your code “username” is a real variable that can be seen from this function (scope) or this won’t work.
In your other post you talk about profile.lua, which doesn’t look like a scene, but perhaps you only showed a small portion of it. Your code above is trying to go to newsfeed.lua. We need to see that.
Generically speaking if you’re going to pass parameters this way, you have to do more work in the scene:create() of the scene you are going to:
function scene:create(event) local screenGroup = self.view local passedInParams = event.params --\<------ important. This is how you get the passed values local background = display.newImageRect("insta.jpg",display.contentWidth,display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY screenGroup:insert(background) local userName = passedInParams.username --\<---- store the username in a local variable. local userNameText = display.newText(userName, 200, 200, native.systemFont, 30 ) userNameText:setFillColor( 1, 0, 0 ) screenGroup:insert(userNameText) end
This may seem to go contrary to previous advice about making userName local at the top. That was suggested under the assumption that you were getting the username from some source in *this scene*. Since it’s coming from a different scene, we have to take a different approach.
Rob
I just got help on stack overflow . I did this :
login.lua :
local function networkListener( event ) if ( event.isError ) then local alert = native.showAlert( "Error Logging In", "Check your internet connection .", { "Try again" } ) else if event.response == "success" then -- put the code here to go to where the user needs to be -- after a successful registration composer.setVariable( "username", username.text ) composer.gotoScene( "profile", { params = parametersToSend } ) else -- put code here to notify the user of the problem, perhaps -- a native.alert() dialog that shows them the value of event.response -- and take them back to the registration screen to let them try again local json = require("json") print( json.prettify( event ) ) local alert = native.showAlert( "Error Logging In", event.response , { "Try again" } ) end end end
profile.lua :
-- at the top local userName = composer.getVariable( "username" ) function scene:create(event) local screenGroup = self.view local background = display.newImageRect("insta.jpg",display.contentWidth,display.contentHeight) background.x = display.contentCenterX background.y = display.contentCenterY screenGroup:insert(background) local passedInParams = event.params --\<------ important. This is how you get the passed values local userNameText = display.newText(userName, 200, 200, native.systemFont, 30 ) userNameText:setFillColor( 1, 0, 0 ) screenGroup:insert(userNameText) end
and now I see the username .
In your composer.gotoScene() are you going to profile.lua or newsfeed.lua?
The error means your userName variable is still nil. You need to figure that out. In the scene where you are calling composer.gotoScene() perhaps print out the value of username to make sure it’s set to a valid value. If it’s not you need to figure out why.
This sounds a whole lot like a “scope” problem in your scene where you’re calling composer.gotoScene(). Do you understand scope? (when variables are visible or not)? It’s a really important concept (when to use local, when not to, how to get variables in one function available in others). You probably should read: https://docs.coronalabs.com/tutorial/basics/scope/index.html
To help you understand this, perhaps this example will illustrate:
local function networkListener( event ) print( username ) -- will be nil end local username = "abc123" network.request( ... )
This will fail. When Lua scans the code and comes to the network listener function, username hasn’t bee defined yet. Here’s another version:
local function networkListener( event ) print( username ) -- will be nil end local function logUserIn() local username = "abc123" network.request( ... ) end
This will result in the same issue, but “username” is more hidden since it’s local inside of a function. The solution is to make username local at a higher block before it gets used.
Consider this:
local username --\<---- now exists local function networkListener( event ) print( username ) -- will be nil end username = "abc123" --\<----- not local here, it's defined at the top, but it exists throughout the whole scene network.request( ... )
You really need to grasp this concept. It will solves one of the most common and frustrating problems that Lua developers run in to.
Rob
That’s a perfectly acceptable way to pass data between scenes.
Rob