How do I slices

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

Moderators: marionline, SDHawk

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

Post by Foxley »

I almost definitely won't have anything playable by Friday but I appreciate the sentiment!
User avatar
kylekrack
Liquid Metal Slime
Posts: 1243
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Bob the Hamster wrote: Also, there is almost never any good reason to use the "slice is valid" command. I need to update the docs to make it clear that command is only really there for debugging.
I think I actually needed to use this command, ironically. I remembered you saying this and felt immediately like I was doing something wrong. But I only used it because I have a script in the main loop that changes the cursor based on what the mouse is hovering over, and not all of the slice collections have that slice. Every time the game opened up it would give a script error for an invalid slice handle.

Code: Select all

if(slice is valid(lookup slice(sli:forward))) then(
		  	if(slice collide point(lookup slice(sli:forward),x,y)) then(
		  		replace weapon sprite(cursor,2))
		  	else(
		  		replace weapon sprite(cursor,0))
		  )
		  if(slice is valid(lookup slice(sli:backward))) then(
		  	if(slice collide point(lookup slice(sli:backward),x,y)) then(
		  		replace weapon sprite(cursor,3))
		  	else(
		  		replace weapon sprite(cursor,0))
		  )
This runs each game tick. Should I write it in a different way to not use slice collide point?
Last edited by kylekrack on Sun Jun 14, 2015 10:29 pm, edited 1 time in total.
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

That script is correct, but as I said before, the 'slice is valid' is pointless. You can just write "if(lookup slice(sli:forward))" instead.
Post Reply