NicoM1 / IceEntity

A simple framework for managing entitys, components, and live-at-runtime scripts in haxeflixel
MIT License
58 stars 7 forks source link

FlxG.keys input always null in scripts #8

Closed NicoM1 closed 10 years ago

NicoM1 commented 10 years ago

I've found a nasty bug: seemingly, when you attempt to get any value from FlxG.keys.pressed (or .justPressed, etc.) inside of a script, the value returned is always null. It would be very beneficial if anyone could confirm this happens:)

gamedevsam commented 10 years ago

I believe this is because just pressed callbacks are inline function calls which don't exist in a Dynamic representation of FlxG.keys object. I need to take a closer look at the CPP code to confirm this. Does this issue occur on both Flash and Cpp targets?

Looking at FlxKeyList, you can see that the properties are not inline, but the get_ functions are. Not sure why this would cause an issue, inspection of the CPP FlxKeyList file should reveal any potential issues.

PS: Could you provide a link to the CPP key list file? That would help a bunch!

ibloat commented 10 years ago

trace(FlxG.keys.pressed); results in a FlxKeyList for me. Same for justPressed. FlxG.keys.pressed.T correctly reports true when 'T' is being pressed, otherwise false. OS/Target: Linux x86_64 HaxeFlixel updated from git a few minutes ago, same for IceEntity OpenFL 2.0

NicoM1 commented 10 years ago

@gamedevsam that sounds plausible, I can try and find that file later, that's worrying though, because I'm unsure if that can be fixed....

@ibloat you get proper values for pressed keys inside of ice entity scripts? (Not in normal code, like in XML specified scripts?)

gamedevsam commented 10 years ago

I looked into the generated cpp file, and all properties are properly represented regardless of being inline. Something else is going on here, can you provide a snippet of the code that is failing?

NicoM1 commented 10 years ago

Only tested on neko so far, will check more when I get home, but just trace(FlxG.keys.pressed.A); returns null

ibloat commented 10 years ago

Yes works fine on the Linux cpp target but returns null when targeting Neko. https://gist.github.com/ibloat/4b73aadf6e6cce6f7f0b

NicoM1 commented 10 years ago

@ibloat thanks so much for testing, thats very interesting, I'll look at the code that is generated for neko, I really appreciate the help from both of you by the way:)

edit: I guess there is no visible code generated, @gamedevsam got any ideas as to how to look into this behavior?

NicoM1 commented 10 years ago

@gamedevsam I'm thinking that your original though could have been correct, just that it happens in neko not cpp, I should have clarified that:/

gamedevsam commented 10 years ago

Unfortunately I can't provide any assistance with Neko issues. Neko has historically been the cause of much annoyance for me and because of that I never considered it as a valid target for game development.

You could try posting a bug on the Neko repo, but it's not very active, and Nicolas doesn't seem particularly motivated to frequently fix bugs and put out new releases.

NicoM1 commented 10 years ago

hmmm ok maybe I'll just put a warning about it, its not like any releases are gonna use neko so its not too big. Although, I do currently love it for testing, but I guess thats kinda the point of the live-scripting system;)

NicoM1 commented 10 years ago

@gamedevsam @ibloat well, this actually was fixable:D found the solution here: https://github.com/HaxeFoundation/hscript/issues/10 If you guys could double-check that it works on neko now that would be great:)

Unfortunately it appears hscript is not very actively maintained, there are a couple important looking issues on the repo from weeks ago with no responses...

gamedevsam commented 10 years ago

Considering hscript is open source and all written in Haxe, I would advise you not to worry too much about the lack of support at the moment. If push comes to shove you can dig deep and fix it yourself, or you could post a bounty to get the issue fixed.

NicoM1 commented 10 years ago

well the problem itself is fixed (I just used underscorediscovery's answer), I just mean theres several ready made fixes for different problems on the hscript repo, but none have been merged in...