I wrote up a room changing script that is actually pretty elegant and easy for me to work with (I surprised myself). However after changing rooms once, I then get a "slicecollidepoint: invalid slice handle 0" error from the "mouse clicked" script when clicking anything.
It's basically James's mouse click script in the other thread with slight modifications. Mostly I removed the "holder" argument.
script, mouseclicked, slice, begin
variable(sl)
sl := lookup slice (slice)
if (mouse click) then (
return (slice collide point (sl, mouse pixel x, mouse pixel y))
) else (
exit returning (false)
)
end
I don't know what my change room script is doing to make the error happen. All it does is free the slice tied to the 'currentroom' global variable, load the appropriate new slice collection to 'currentroom', and then update the 'currentroomID' number value. 'currentroomID' is a global variable I made so I can check what the current room is in a switch/case.
Any ideas? Anyone want to look at my .HSS and see if you notice anything wrong?
Ugh. Nevermind... I found out what was causing it. I put a weird line in the "check HUD clickables" script to check if clicking the room slice container was registering a response. I took it out and now room change/movement is WORKING. Woohoo!
This error is happening again, but more drastically. I split up my single script check-for-slices-and-do-something-if-it's-there script into separate smaller scripts for the sake of organization, and now this seems to be happening. If I hit "Ignore" when it comes up I seem to have to hit Ignore for as many checks as there were. I'm going to just go ahead and upload the ZIP to my Dropbox, if anyone cares to figure out what's going on here.
It seems that any slice that's clicked that's not in Slice Collection 0 (the one that gets autoloaded in the new game script) then it gives a slice handle 0 error.
.... Does that mean that you can only check for slice lookups that are currently loaded and visible on screen or else it'll be like "derp, that's slice handle 0"? If so, that really sucks, and I don't have enough time to re-plan and re-write the entire first person engine I've implemented so far.
Is there any way for it to ignore slices it can't find so it at least doesn't cause script errors? I can't have every slice collection in the entire game loaded all at once, that's not going to work.
Okay. Now that my critical thinking faculties are working a bit better, I think I might have an idea. Maybe I can have situational slice collections like submenus and separate screens that aren't always visible be loaded alongside tags being turned on. Then have if ( conditions related to those tags so it only checks relevant slice collections.
I really think that returning slice handle 0, game.exe should just be "okay, it's slice handle 0, I'm not gonna freak out" instead of making a script error interrupt the game, though. Really, the only reason this is even an issue is because of the script error popping up. Nothing bad or unintended even happens if I mash "Ignore".
It really is very useful to show a script error immediately when you make a small mistake. New programmers usually don't realise it, but after years programming you understand that the sooner you find out about a mistake, the less time you will spend in the long run fixing it.
However, I ALSO agree that getting script error messages in the middle of a game is a bad thing. And unfortunately error messages pop up in some old games even though they don't seem to be broken and didn't show errors previously, because of something that changed in the engine at some point. So I want to make a change to script error reporting in existing games.
Last edited by TMC on Thu Jun 18, 2015 4:04 am, edited 2 times in total.