Looking for puzzle scripts

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Ah! This is perfect. I assume I can use "npcref" to refer to any ole NPC calling the script?

Cheers
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, this is a drop-in replacement for walknpc: "npc" is either an npc reference or an npc id. So you can call it from an NPC activation script.
Last edited by TMC on Sat Feb 03, 2018 9:46 am, edited 1 time in total.
User avatar
Idontknow
Slime Knight
Posts: 219
Joined: Sat Dec 10, 2011 5:51 pm
Location: The Jerkstore
Contact:

Post by Idontknow »

That mirror npc idea is a pretty neat idea for a puzzle, I think I might use that one in a game sometime.

My games in general are very devoid of puzzles, but in the future I'd like to create some more. Some ideas I had are:
- The classic ice sliding puzzle: People think these are annoying but I don't mind them much. Putting invisible NPCs on the ice squares which move the player in the direction they're facing when stepped on would work. The tiles without those invisible NPCs would be the "ground" tiles.

The only problem I for see is ending up in an infinite loop if you hit a wall.

- Arrow Tiles: Those arrow puzzles from the old Pokemon games, would be similar to the ice sliding but the arrow tiles are invisible NPCs which move you until you hit a wall or other sliding tile.

- Bullet dodging with blocks: Recently I've been crazy about the Nier series. Some of the puzzles in Nier Gestalt are a series of rooms in which you must walk from one side of the room to the other without getting hit by projectiles shot out of blocks. Projectiles are nothing new, and most of the time you can jump away from them, as Nier is an action game. However the twist in these rooms is jumping teleports you back to the front door of the room. Some solutions require the player to push blocks in front of the projectiles to make a path, so it's kind of like a hybrid of block pushing and dodging puzzles. The scripts to do this could probably be engineered from scripts belonging to ohr sidescroller games.
Last edited by Idontknow on Sun Feb 04, 2018 1:12 am, edited 3 times in total.
Working as intended!
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Here's one for you:

I have a "while" loop that checks for the x/y coordinates of an NPC - it's included in the map's autorun script.

Code: Select all

script, sip_bas_checkvase1, begin
	while ( check tag (92) == off ) do
	(
		if ( npc x (32) == 56 && npc y (32) == 2 ) then
		(
			wait for npc (32)
			set tag (92, on) 
			play sound (0)
			pan camera (down, 0, 2)
			wait for camera
			pan camera (up, 0, 4)
			wait for camera
			camera follows hero
		)
		wait (1)
	)
end
At another point, I have a script that fades screen out, then teleports to the same map that uses the above autorun script. The problem is that the "teleport" script seems to be suspended once the player is teleported, in lieu of the autorun script. I suspect this has to do with the "while" loop.

Suggestions? I've tested other scripts called on the same map and they run fine, it just doesn't seem to like continuing a script called before the map change.
Last edited by guo on Wed Feb 14, 2018 2:53 am, edited 1 time in total.
vvight.wordpress.com
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

On further reading , it appears scripts suspending each other is a bit of a problem (with while loops, especially). Perhaps I will need to find a better solution to my "npc @ x/y" puzzles.

edit: Workaround found. I've split the "npc position check" area into it's own map so that it doesn't interfere with what else is going on. It's not perfect but it works for now. This is what I get for putting a bunch of different areas onto the one map.

I know I don't need to post my entire inner monologue but it may help someone down the track in the same situation. :angel:
Last edited by guo on Wed Feb 14, 2018 4:38 am, edited 1 time in total.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, it's a common problem. One way around it is to use a timer instead of a while loop, that way the script will run every tick but won't suspend other scripts.

If you just search the wiki for "timer" you will find a bunch of example scripts, and How do I add a timer?
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Oh, neato. I've already switched the area/script to it's own separate map which has solved the issue for now. There will be maps in future that I'll want to use this feature again, however. Cheers

edit: To clarify, I'm guessing I want the timer to look like this :

Code: Select all

set timer (0, 1, 1, @script)
Does it reset itself after running the trigger? Or would I want to have the "count" part set to a global variable, which is then reset by the trigger?

Thanks.
Last edited by guo on Wed Feb 14, 2018 9:49 pm, edited 1 time in total.
vvight.wordpress.com
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Very close! You actually want:

Code: Select all

set timer (0, 0, 1, @script)
because the count argument counts from zero, not from 1

And this just schedules the script to be run once on the next tick, not to run every tick.

If you want it to happen every tick, you should do:

Code: Select all

script, timer loop example, begin
  if(condition that makes the script stop) then(exit script)

  # the rest of the script goes here
  
  # make this script run again on the next tick
  set timer(0, 0, 1, @timer loop example)
end
Last edited by Bob the Hamster on Wed Feb 14, 2018 10:30 pm, edited 1 time in total.
User avatar
guo
Metal Slime
Posts: 749
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks!
vvight.wordpress.com
Post Reply