Movement/room changing script works, then causes errors

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Movement/room changing script works, then causes errors

Post by Foxley »

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.

Code: Select all

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?
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

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!
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

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.

https://www.dropbox.com/s/hhdoriia3gpor ... p.zip?dl=0
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

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.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

If "lookup slice" cannot find the code, then it returns 0

Slice collections do need to be loaded, but they do not need to be visible
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

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.
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

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".
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

What you want to do is actually super easy

Code: Select all

sl := lookup slice(sli:foo)
if (sl) then(
  #do things that only happen if the slice is found
)
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Funny, I actually figured that out a minute ago, then F5ed the webpage and saw you had posted that exact thing I just did. Thanks again.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

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.
Post Reply