Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 3 4 [5] 6 7 ... 93

Author Topic: [0.96a] Console Commands v2023.05.05  (Read 1558123 times)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #60 on: September 23, 2012, 02:35:32 PM »

I'm not sure if the Keyboard class is threadsafe, if that's what you mean. Might be, but I just don't know.

Also: how would you execute something on the main thread while paused? The spawn point/combat plugin wouldn't get called until the unpause. Just trying to understand :)
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #61 on: September 23, 2012, 02:57:34 PM »

I'm not sure if the Keyboard class is threadsafe, if that's what you mean. Might be, but I just don't know.

Hmm, would that matter if all I'm calling are isKeyDown() queries? Nothing should be changing in the static Keyboard instance, correct?

To be honest, I'm not that familiar with multi-threading (I've only worked with it a few times, and most of the libraries I've used were thread safe). This update is partially an excuse to learn. :)

Quote
Also: how would you execute something on the main thread while paused? The spawn point/combat plugin wouldn't get called until the unpause. Just trying to understand :)

The keyboard handler was previously in the spawn point, and the keyboard checks were done once per advance(). It's not implemented that way anymore.

Now, the keyboard handler is its own thread with a custom framerate (and thus no longer reliant on Starfarer calling advance()). This is the change that allows it to be used while paused or in a menu. All the spawn point advance()/combat plugin init() methods do is tell the console if the player is on the campaign map or in a battle so it can select which commands are available.

It's kind of a messy workaround, but I believe it will work (I'm still in the prototype phase right now). That said, I would love to see something like a Global.getCampaignState(CampaignState state) API method that tells us where the current focus is. ;D
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #62 on: September 23, 2012, 04:24:40 PM »

where does one learn all of this

If you have the funds to spare or the academic achievements for a scholarship, university is a good route. If not, no worries. A university degree isn't as big a deal in game development as it is in other IT industries. Sign up for some cheap college courses. Buy multiple textbooks and read them in your free time. Study the documentation that comes with the language. Whatever you want. It depends on how you learn best.

Most importantly, once you've learned the basic syntax of a language and are comfortable coding on your own, experiment. If something even slightly interests you, make a simple project to learn how it works. If you stumble on another topic that interests you while working on that, start another project. Don't feel bad about abandoning projects that no longer interest you; the goal here is to learn, not create a polished product (my personal code directory contains hundreds of projects, of which about a dozen are complete). This is, in my opinion, the best way to learn a language's libraries quickly and accurately. And a strong portfolio impresses potential employers just as much as a piece of paper that says you can follow instructions for a few years.

Don't hesitate to go online if you get lost. Every problem you face, many others have faced before you and at least one of them asked for help. Hang out on sites like StackOverflow. Read every question you comprehend, even - especially - if you think you know the answer already. The experts often have tricks and better ways of doing things than you were taught.

Join community projects. Most larger, established teams have experienced modders who will be willing to give you a hand, and can point out your mistakes before they become ingrained. A mod team is probably the best option for learning game development, and mods looks great on a résumé.

And above all, remember: it's never too late to learn something new.
Thank you, very inspirational
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #63 on: September 23, 2012, 05:00:35 PM »

I'm not sure if the Keyboard class is threadsafe, if that's what you mean. Might be, but I just don't know.

Hmm, would that matter if all I'm calling are isKeyDown() queries? Nothing should be changing in the static Keyboard instance, correct?

To be honest, I'm not that familiar with multi-threading (I've only worked with it a few times, and most of the libraries I've used were thread safe). This update is partially an excuse to learn. :)

Well, that depends on how the Keyboard class is implemented. It may or may not be thread-safe - I don't know what the methods do under the hood.


Quote
Also: how would you execute something on the main thread while paused? The spawn point/combat plugin wouldn't get called until the unpause. Just trying to understand :)

The keyboard handler was previously in the spawn point, and the keyboard checks were done once per advance(). It's not implemented that way anymore.

Now, the keyboard handler is its own thread with a custom framerate (and thus no longer reliant on Starfarer calling advance()). This is the change that allows it to be used while paused or in a menu. All the spawn point advance()/combat plugin init() methods do is tell the console if the player is on the campaign map or in a battle so it can select which commands are available.

It's kind of a messy workaround, but I believe it will work (I'm still in the prototype phase right now). That said, I would love to see something like a Global.getCampaignState(CampaignState state) API method that tells us where the current focus is. ;D

Hmm. So the console calls API methods from that thread, right? The API is definitely not thread-safe. It'll probably work most of the time, but it may die horribly every so often.

For example, suppose you try to add a ship while the main thread is iterating over it because, oh, I don't know, it has to show the fleet tooltip - and that's not even getting into the guts of multithreading.

A particularly evil example - the JVM isn't actually required to make changes made by one thread visible to another, unless those changes are made in a thread-safe way. So if you have a member variable in an object and two threads change it, they could each end up seeing their own value. As far as I know most JVM implementations don't do this - but according to the language spec, they could.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #64 on: September 23, 2012, 05:20:03 PM »

Well, that depends on how the Keyboard class is implemented. It may or may not be thread-safe - I don't know what the methods do under the hood.

Viewing the source, it looks like it should be safe.
Spoiler
Code
	        public static boolean isKeyDown(int key) {
               synchronized (OpenGLPackageAccess.global_lock) {
                       if (!created)
                               throw new IllegalStateException("Keyboard must be created before you can query key state");
                       return keyDownBuffer.get(key) != 0;
               }
       }
[close]

Quote
Hmm. So the console calls API methods from that thread, right?

No, the other thread doesn't call any Starfarer code directly. The only thing that it does is check if the 'summon console' key is down, and notifies the Console object in the main thread if it is.
« Last Edit: September 23, 2012, 05:23:27 PM by LazyWizard »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #65 on: September 23, 2012, 05:23:40 PM »

Ah, alright. It probably sounds like I'm interrogating you, sorry about that :)
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #66 on: September 23, 2012, 05:25:23 PM »

No worries, I appreciate the help. I actually learned a lot from your explanations. :)
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #67 on: September 24, 2012, 09:19:05 AM »

WAS FINALLY ABLE TO TRY THIS OUT ANNNNNNNNNNND:

WOW, Friggin epic mod here man, It's beautiful, shame there isn't a GUI capable of being hooked up to the console :/, And maybe make it a little less case sensitive :)
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #68 on: September 24, 2012, 11:59:02 AM »

I can't really do much about that, Starfarer itself is case-sensitive. I can change a few commands to automatically try with different capitalization if they fail, though.
Logged

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #69 on: September 24, 2012, 04:28:07 PM »

I can't really do much about that, Starfarer itself is case-sensitive. I can change a few commands to automatically try with different capitalization if they fail, though.
Yes please
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

CrashToDesktop

  • Admiral
  • *****
  • Posts: 3876
  • Quartermaster
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #70 on: September 24, 2012, 04:34:16 PM »

OT topic, but whatever happened to the Economy mod?

Anyways, I've been playing around with it more and more with the Ironclads mod enanbled.  Mothership, here I come. >:D Very useful tool, makes dev mode look almost like a baby. ;D
Logged
Quote from: Trylobot
I am officially an epoch.
Quote from: Thaago
Note: please sacrifice your goats responsibly, look up the proper pronunciation of Alex's name. We wouldn't want some other project receiving mystic power.

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #71 on: September 24, 2012, 05:46:54 PM »

I can't really do much about that, Starfarer itself is case-sensitive. I can change a few commands to automatically try with different capitalization if they fail, though.
Yes please

I'll put that together right now, along with writing the 'help' for commands that lack it.

------------

OT topic, but whatever happened to the Economy mod?

Here are the projects I'm working on, in descending order of priority:

I'm still planning on finishing it eventually, but it's been assigned a low priority for now. It's exactly like I said in one of the very first posts in the economy thread:
Every time I try to juggle multiple large projects I end up neglecting one of them.

(also, have I really only been a modder here for three months? It feels much longer than that...)

------------

Anyways, I've been playing around with it more and more with the Ironclads mod enanbled.  Mothership, here I come. >:D Very useful tool, makes dev mode look almost like a baby. ;D

I'm glad you're enjoying it. :) Just remember my warning at the end of the first post!
Logged

CrashToDesktop

  • Admiral
  • *****
  • Posts: 3876
  • Quartermaster
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #72 on: September 24, 2012, 05:57:19 PM »

Dark Souls-style invasions?  I eagerly await that. :)

And don't worry about the warning, I have a seperate save file that I use just for playing around with devmode and this. ;)
Logged
Quote from: Trylobot
I am officially an epoch.
Quote from: Thaago
Note: please sacrifice your goats responsibly, look up the proper pronunciation of Alex's name. We wouldn't want some other project receiving mystic power.

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #73 on: September 29, 2012, 11:15:48 PM »

Sorry for the lack of progress this week, lots of crazy real-life stuff happened. I'm an uncle now.

I'll have the update posted later today. Here's the changelog so far:
Quote
0.4 beta (September 30, 2012)
===============================
Less strict about capitalization (failed commands try again with different case)
AddShip: specifying a ship type without a variant will spawn an empty hull
The various Add<X> commands will accept their arguments in any order
Added syntax and usage help for all commands
Removed showMultiLineMessage methods, incorporated into showMessage
Logged

arcibalde

  • Admiral
  • *****
  • Posts: 1730
    • View Profile
Re: Unofficial Developer's Console (beta 0.3 released!)
« Reply #74 on: September 30, 2012, 12:14:49 AM »

I'm an uncle now.

Congrats  ;D   Uncle LazyWizard... Wait... Hey, you can't be Lazy any more. You have to make example man. You should be uncle WIZARD. Yeah. Awesome!  ;D
Logged
Creator of:
Relics MOD - vanilla balanced - Campaign integrated
Vanilla addon MOD - vanilla balanced - Campaign integrated
Project ONI MOD - mission only
Pages: 1 ... 3 4 [5] 6 7 ... 93