TannerRogalsky / love.js

LÖVE ported to the web using Emscripten
MIT License
493 stars 53 forks source link

Question: Is it possible to make my game interact with the index? #69

Open rafael-lua opened 4 years ago

rafael-lua commented 4 years ago

I couln't find a solution (if there is any) with my limited skills, so I am here to see if someone could help.

It is possible to make my game interact with scripts in the index page? So I could use things like https://docs.kongregate.com/docs/javascript-api

Everything works fine with the build. But I would really want to be able to integrate the kong api or even to execute some javascript code and retrieve the result to my game. Love2d is a engine I really like and I don't want to change it and start all over in another place.

Is there any way to my game code communicate with the outside page?

MrcSnm commented 4 years ago

Okay, you got my day today, I spent my day trying this and found out how to do it, basically, what it does is wrap the console log function and then use it to evaluate, it is really easy to use, and I'm also doing it with kongregate

https://github.com/MrcSnm/Love.js-Api-Player

This is an example of how to use it

if(key == "p") then
        callJS("kongregate.stats.submit('Score', 1000);")
    end

apiTest

Be sure to watch it, I'll post one PR later for the focus problem when uploading your game onto kongregate

rafael-lua commented 4 years ago

Be sure to watch it, I'll post one PR later for the focus problem when uploading your game onto kongregate

I don't believe, someone actually did it! This is so amazing, thank you so much!!! I can keep working with love and Lua even for web, I'm truly grateful.

I will make sure to keep watching it!

MrcSnm commented 4 years ago

Be sure to watch it, I'll post one PR later for the focus problem when uploading your game onto kongregate

I don't believe, someone actually did it! This is so amazing, thank you so much!!! I can keep working with love and Lua even for web, I'm truly grateful.

I will make sure to keep watching it!

You're welcome, I'm doing a kongregate game myself so I needed to implement it anyway The new PR is ready, added some easier compiling function and it already comes with the Githubissues.

  • Githubissues is a development platform for aggregating issues.