SCUMM Verb Coin Null Pointer Help

Started by Bavolis, Tue 05/03/2019 04:16:26

Previous topic - Next topic

Bavolis

I've got everything set up and looking how I want it, and it all seems to work beautifully until I try to use the verb coin on something *outside* the inventory box while it is loaded (then I get a Null Pointer error). Am I missing something obvious here? I have never had a brain that processes code very well, so I get a bit lost in there trying to figure out what's causing it to break.

Here's a video demonstrating the crash: https://www.youtube.com/watch?v=8XS5Tg-h_yY&feature=youtu.be

Here's the error: 

I can take pictures of any other section of code, I'm just not sure of what would be useful here.

Snarky

This whole block of code assumes that you clicked at an inventory item. Why it thinks that's a safe assumption is hard to tell without the condition that the "else" refers to, but given the behavior it seems to be "if the inventory is open, that must be what you interacted with". You'd have to either fix that or ensure the inventory is always closed when the mouse is not on it. (The popup behavior looks a bit odd to me in itself.)

Also, it's generally better if you post the code as text inside [code] tags, rather than as pictures, and errors as well. That way it will be searchable, copyable, and not blank out once the image host dies.

Khris

If that is the VerbCoin template that comes with AGS: don't use it. It's full of bugs and the code is a mess, which is the reason why nobody fixes it. Sorry Electroshokker, but that's how it is.
Whenever somebody starts using it they crash right into the tech forums.

There's a VerbCoin module out there by monkey0506: https://www.adventuregamestudio.co.uk/forums/index.php?topic=42868.0

ManicMatt

#3
My game Trails and Traces uses that verb coin template, as I assumed it would be fine to use if it's included in AGS. Why wouldn't you?

I have my inventory gui pop up in the middle of the screen but doesn't fill the whole screen, and realised i could right click with my mouse when it's outside where the inventory would appear, and then attempt to use the verb coin in the room and find it would crash.

I got around this by having a transparent black screen filling layer, i think i put under my gui, so everything looks just slightly darker in the room, but in doing so you couldn't click on anything in the room now while the inventory is open.

I don't know if that is of any help to you?

I also have certain screens disable the verb coin, like the main menu, so you can't bring it up when that wouldn't make sense to.

Although like Snarky was saying about your mouse position. Why does the inventory pop up when your mouse is not all the way down yet? And not disappear as soon as you move the cursor off it? Is it not popping up because of the xy coordinates?

Khris

Again, no offense, but even that tiny snippet we see up top is just bad. First, there's duplicate code all over this. The only thing that changes is the mouse.Mode, yet each block has four statements.
Next, the comments talk about avoiding null pointer errors, but that's exactly what's happening. Why? Because the inventory item is no longer at mousex, mousey. Why not store the clicked item in the first place? Why no item2 != null check?

Fixing a bad coordinate check by including a semi transparent fullscreen GUI is certainly creative but shouldn't be necessary in the first place obviously.

The VerbCoin template is broken; nobody, including the author, is ever going to fix it, and it is only still included with AGS because nobody is actually using it. When once every blue moon somebody does, the whole mess starts all over again. It should never have been included in the first place, and fixing it is probably more work than creating your own from scratch.

Bottom line: do not use it.

ManicMatt

Yeah I mean, I agree! I'm pretty confident I fixed all the bugs in my game to do with the verb coin but that's only good for my gui etc. So I doubt my fixes could even be incorporated into the template.


Danvzare

Quote from: Khris on Tue 05/03/2019 08:05:16
The VerbCoin template is broken; nobody, including the author, is ever going to fix it
And this here, is exactly why I refuse to make any games using the VerbCoin.  (nod)

Quote from: ManicMatt on Tue 05/03/2019 08:12:13
Yeah I mean, I agree! I'm pretty confident I fixed all the bugs in my game to do with the verb coin but that's only good for my gui etc. So I doubt my fixes could even be incorporated into the template.
You could make your own template.

Bavolis

I do like the trick of blacking out the rest of the screen, it actually does make sense for this specific problem! However, there's enough of a warning flag here to switch the code to something more stable, Thanks for the advice, folks!


Cassiebsg

Yeah, I ended up writing my own verbcoin too, even though I started with the template, realized it didn't do what I needed it to, then went and tried using monkey's verbcoin, but wasn't exactly hat I wanted either. In the end I just wrote my own based on monkey's code (cause otherwise I probably would have never gotten there) and don't regret it one bit.  :)
There are those who believe that life here began out there...

SMF spam blocked by CleanTalk