TetroniMike's Recent Forum Activity

  • I got it working! First, whenever I call my function that captures the windows [X] close button, I first release control (to help prevent duplicate "listeners") by removing all listeners from the 'close' signal. You'll note the below code is very similar to previous solutions, but adds an extra line that I guess was a recent requirement to listen for 'close' signals: var gui = require("nw.gui")

    Browser -> Execute javascript:

    "var gui = require(""nw.gui""); var win_main=gui.Window.get(); win_main.removeAllListeners('close');"

    Then, I run a second command that listens for the 'close' signal.

    Browser -> Execute javascript

    "var gui = require(""nw.gui""); var win_main = gui.Window.get(); win.on('close', function() { c2_callFunction('nw.js close',[]); });"

    I have a Function titled "nw.js close" where I run the code I want to run when the player clicks the window [X] close button.

    And then when I want to release control I run just that code at the top of my post, removeAllListeners.

    This works in the latest NWJS 0.84.0 on Windows, and I'll be testing my update on Mac and Linux next week.

  • This is in response to this post, which I cannot reply to as it is over 1 year old:

    https://www.construct.net/en/forum/new-post?topicID=157025

    in turn, that post was a response to this post:

    https://www.construct.net/en/forum/construct-2/how-do-i-18/window-close-113911

    The above mentioned Browser -> Execute Javascript solution works on NWJS v0.54.0, but I can't get this to work with NWJS v0.84.0 - now I recognize that version is not officially supported by Construct 2, but everything else NWJS-related works just fine, this is the only item that is not working. Any ideas?

    This is for the game Hypnospace Outlaw, and before you suggest it we cannot port to Construct 3 for a number of reasons. I'm trying to update the game to fix (1) Steam Cloud Saves, (2) mod.io integration, and (3) issues with newer graphics cards that new NWJS versions seem to resolve. While I was at it I figured I'd add some quality-of-life fixes and additions, like overriding clicking the [X] button so that players don't accidentally close the game when they're trying to click something at the top-right corner of the window.

  • I did some Googling and found this, so take this answer with a grain of salt: if you have not, you may need to "Publish to the web". Via this article: philipdev.se/ideas/google-spreadsheet-data

  • Alright so I've learned a few things:

    1) AdvancedRandom can take a string of presumably any length - I used Update Seed and put in a string with over 1,000 characters and it worked as expected.

    2) Repeating the random() function 1,000,000 times BARELY noticeably lags, maybe 1/20 of a second.

    3) Updating the seed each time I use random() to "MYSEED_[n]" has no noticeable effect on FPS, even if calling it 100 times every single tick. (n = number of times I've used random())

    For both 2 and 3 I enabled "Replace system random" in the AdvancedRandom properties.

    So it looks like my current implementation will work fine (unless the player has been playing on a single save file for literally days without a game over). And so will your idea of updating to MYSEED_[n] each time random() is used :)

  • Well... More than 7 characters.

    "MYSEED_1234567" is 14 characters, hence why I ask. I suppose I can test myself and figure it out :P

  • So pre-generating numbers is great but what if I need like 8,000,000,000 of them? Since the game generates as you progress, I can't be sure how far players will make it. Granted, 8 billion will most definitely be enough, but yeah.

    Now that I've thought about it, re-seeding each step is an idea, I'll look into it. Does Advanced Random have a seed string maximum length? Because like I mentioned the game could potentially get into the millions of steps.

  • Ok so let's simplify the problem. When using seeded randomness I am guaranteed to always get the same numbers in the same order, if I use the same seed. So let's say I do the following:

    Start of Frame:

    - Set AdvancedRandom Seed to "SOMESEED"

    Repeat 10 times:

    - Set Var to Floor(Random(0,10))

    - Set Text to Text.Text & " " & Var

    AdvancedRandom has now generated 10 random numbers. The above code will output the following, for example:

    1 5 7 6 3 8 3 2 4 6

    Now, let's say at this point I want to save my game and come back later. So I save the seed "SOMESEED", I save the string of output numbers (in bold above), and I quit. When I load up this save file, and generate 10 more numbers using the same string, my string will be:

    1 5 7 6 3 8 3 2 4 6 1 5 7 6 3 8 3 2 4 6

    Which is just the 1st 10 numbers twice.

    If I do all of the above without saving, quitting, and loading the save file, I'll have 20 random numbers. The intended functionality would allow me to save, quit, and load while resuming at the "step" that AdvancedRandom left off at. But there's no way to do that that I can find.

    Basically, I'd like a player that uses "SOMESEED" and plays for 20 steps to get the same results as a player who plays for 10 steps, then quits, then resumes and plays for 10 more steps.

    Does that make sense?

  • Are you familiar with tokens? You could load in the CSV as a string variable (myCSV) and use one other variable to iterate through rows (thisRow).

    I tried to copy/paste in my code but "Copy as Text" is not working for me for some reason... here's a screenshot:

    https://1drv.ms/u/s!AnfGCnwpFF_Yg8YoDCB6uA5KXGoflQ?e=tL6KHs

  • I'm making a minesweeper clone where levels are of infinite size and generated as you progress, and I'd like to implement "seeded" randomness so that you can, for example, compete against others with the same exact grid.

    I've figured out how to implement custom seeds, but when saving then loading the custom seed the AdvancedRandom object's random sequence of numbers will "start over" instead of resuming at the seed's step where you saved and quit.

    How can I resume at the same point I saved at within my sequence of seeded random values?

    My current solution works like so, but this is inelegant:

    1) Player loads up their game

    2) Game loads in the grid with player's progress

    3) Repeat [n] times: Set someVariable to random(0,1)

    4) Player continues at the point where they left off

    #3 is the inelegant part... variable [n] in #3 is the number of times I've had AdvancedRandom give me a random value since starting the save file. Looping "output random value" n times puts us back at the step where the player left off.

    Thanks for any help you can give me here!

  • Found a workaround!!! You can use the Browser plugin's Execute JavaScript action and "win.close()" instead of the Browser Close action :)

    I have yet to test this on Mac and Linux, I will see if the problem persists there and if the same solution works next week.

  • Same problem here. It appears to have started in NWJS 0.47.0, I think, and the latest version 0.49.0 definitely has this issue as well.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Sorry to bring this back from the grave, but does anyone have the PlatformInfo.SafeAreaInsetTop/Bottom/Right/Left expressions working? They just return 0 for me no matter what I do :/

    Edit: Using Cordova export to Android on a Pixel 3XL (which has a notch).

    Viewport Fit: Cover

    Fullscreen Mode: Scale outer

    Hide Status Bar: True

TetroniMike's avatar

TetroniMike

Member since 18 Sep, 2016

None one is following TetroniMike yet!

Connect with TetroniMike

Trophy Case

  • 8-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

10/44
How to earn trophies