Announcement: Why not try our official idea generator for inspiration when making puzzles?


Caravel Forum : DROD Boards : Architecture : Card-Flipping Script (A Different Kind of Casino Game)
New Topic New Poll Post Reply
Poster Message
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged

File: Heart Card.png (621 bytes)
Downloaded 7 times.
License: Public Domain
icon Card-Flipping Script (+2)  
So now, while I wait for Waving Views to hopefully get some more feedback, I'm working on a hold that I plan to use these custom "card tiles" as a main gimmick for one of the hold's levels, emulating a near-identical mechanic from another game. The idea is as follows:

- Cards are always face up or face down. Suits that are displayed on the cards won't matter, they're just for aesthetics.
- Whenever Beethro steps onto a card, nothing happens until he steps off, at which point the card will flip over and become darkened. A darkened card cannot be immediately stepped back onto - another card must be stepped onto first.
- The ultimate goal is to have all cards be face-down, at which point the cards (all labelled as required targets) will disappear from the room entirely. A final flip doesn't have to be onto a non-card tile, as long as that flip makes all cards face-down.

The issue is that I haven't had much experience with making custom scripts with the DROD engine. I did try my hand at writing the script to no avail, even having looked at pre-existing samples and guides on the forum for assistance. Can anyone help me with making the script part? (A sample image of one of the suits' sprites is provided.)

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-04-2019 at 03:51 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged
icon Re: Card-Flipping Script (+1)  
And just to clarify what the issues I'm having with my attempts at making even just the detection part of the script are, my script won't pick up the player's presence even when they go to where it should be picking up:

Click here to view the secret text


If someone could help me establish what's breaking down, that would be appreciated. I have been using some of the pre-existing threads' tips, but no luck so far.

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-04-2019 at 05:07 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 729
Registered: 06-13-2015
IP: Logged
icon Re: Card-Flipping Script (+1)  
Let's see what I can figure out...

quote:
Set var "_MyScriptX" = 0
Set var "_MyScriptY" = 0
Get natural target Regular monster


I can't figure out why you're setting myscripts here, especially why to 0, 0? Setting them this way will have any code that would check/use the x, y coordinates of something look at the top left corner of the room (the point (0, 0) in DROD coordinates). I especially don't understand the use here since you set them back to -9999 right after.

Separately, I don't know why you're using natural target. That tests for decoys, stalwarts, soldiers, and timeclones under certain circumstances. Unless the rooms with these cards will never have those entity types present, I would check for the player's presence over the card directly with a "wait for entity player at tile" command.

quote:
Wait while entity Player 0,0,0,0


This checks whether the player is standing on the tile (0, 0), which is not at all what you want. I would change this line to the following 5 lines:

Set var "_MyScriptX" = _MyX
Set var "_MyScriptY" = _MyY
Wait while entity Player 0,0,0,0
Set var "_MyScriptX" = -9999
Set var "_MyScriptY" = -9999

Setting myscript this way makes the wait while entity command check the location of the character calling the script, which is presumably what you want.

I would guess you're having trouble making sense of what myscript is for. I suggest giving this topic of mine a read to hopefully sort some things out: http://forum.caravelgames.com/viewtopic.php?TopicID=42834


If I understand your desired behavior correctly (beethro steps on-->card "primes" to flip-->beethro steps off, making the card flip), I coded something similar for Beethro's Awakening that checked for a specific way of stepping off I won't go into and toggled 4 different states instead of just 2. It wouldn't be too hard to snip that code out into what you seem to want.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 02-04-2019 07:17 PM]
02-04-2019 at 07:10 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged
icon Re: Card-Flipping Script (0)  
quote:
If I understand your desired behavior correctly (beethro steps on-->card "primes" to flip-->beethro steps off, making the card flip), I coded something similar for Beethro's Awakening that checked for a specific way of stepping off I won't go into and toggled 4 different states instead of just 2. It wouldn't be too hard to snip that code out into what you seem to want.

That is correct, but I do also want a freshly-flipped card to be untraverseable for until another card is flipped, hence the darkened states. And of course there's the issue of tracking all the cards' states so that they'll be removed once they're all face-down, but I guess that's easy to solve by setting a variable up for that via a non-preset character script for each room the cards are used in.

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-04-2019 at 09:23 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 729
Registered: 06-13-2015
IP: Logged
icon Re: Card-Flipping Script (+1)  
Making the card impassible: Ah, I forgot about that. That's going to be difficult to arrange cleanly because every card has to "listen" for every other card, and move order blurgh ugh grr. Long story short, I don't think there's any way to do it that doesn't involve either a "sometimes" or "always" 1-turn delay. Maybe that's acceptable in this case? It'll make the code I wrote below more complicated regardless because we can't get away with a "wait for/wait while" pair if the card needs to poll every turn for whether it can become passable again.

Checking whether all cards are flipped: I would have a designated global variable (Cardnum or something like that) which cards add 1 to when face-up, subtract 1 from when face-down. Then a character distinct to the particular room with a processing order 1 (or at least some processing order higher than the cards have) that sets that value to 0, and finally a character with processing order after the cards which checks whether the value is currently 0 to decide whether the room is "done".

I think this should handle everything except for the "impassible" bit (presuming that North means the card is up and that South means the card is down):
Click here to view the secret text


____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 02-04-2019 10:06 PM]
02-04-2019 at 09:59 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged
icon Re: Card-Flipping Script (+1)  
Had to make a few adjustments to your script since I only made the tile-set 4 sprites wide, so the actual number range is:

Up - O=1
Down - O=2
Dark Up - O=5
Dark Down - O=8

(Not an intuitive set at all, I know)
Either way, this is the new script with the modifications I made to make it run properly without disabling instant back-tracking:

Click here to view the secret text

Maybe I'm just overthinking it with the Appear/Disappear commands? I gotta get going for something soon, though, so I'll reply once I'm able to.

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-04-2019 at 10:54 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 729
Registered: 06-13-2015
IP: Logged
icon Re: Card-Flipping Script (+1)  
If you try to make the character Appear while the player's standing on top of it, its script will hang until the player steps off of it and his weapon is no longer on it, which could cause quite a few problems.

I'm having real trouble thinking of an implementation that would properly account for any card arrangement like this:

(- = wall, C = card)

-C
CC

Say the player starts on the SW card. Then he steps off eastward, flipping it and turning it impassable. Fine so far. But then he steps off northward, which means he's flipping the SE card and the SW card should become passable again. But the only way for the SW card to know that is if the SE card broadcasts a global variable announcing it has been flipped. If the SE card moves after the SW card then it won't register this has happened until the next turn, so both cards will be impassable until Beethro waits a turn. But if the SE card moves before the SW card then you can cause the exact same problem by starting on the SE card, moving W and then NE.

The "sometimes 1-turn delay" can be made irrelevant if you never put 3 cards adjacent to each other like this, but that's kind of an irritating restriction for puzzle design.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 02-05-2019 01:33 AM]
02-05-2019 at 01:33 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Chaco
Level: Smitemaster
Rank Points: 3226
Registered: 10-06-2005
IP: Logged
icon Re: Card-Flipping Script (+1)  
Depending on where you want to put the cards, it might help to place alternate floor (road, dirt, mosaic, image floor, etc.) underneath each card character. Then cards early in the turn sequence can detect if Beethro stepped on an accessible card tile by checking if the floor type underneath Beethro is said road, dirt, mosaic, image floor, etc. since it won't matter which one he stepped on, just that he did step on some card.

____________________________
Quick links to my stuff (in case you forgot where it was):
Click here to view the secret text

02-05-2019 at 01:56 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged
icon Re: Card-Flipping Script (0)  
Xindaris - Orthos squares are gonna be pretty common with the cards, so I guess there's that. I do plan for Beethro to also have no weapon for a lot of that level's duration.
Chaco - That is a good idea actually! Mark all card tiles as one identical floor type and non-card tiles as another floor type, then have it so that a darkened card waits a turn to lighten back up as long as Beethro is on the card-specific floor. That might work?

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-05-2019 at 01:14 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Dying Flutchman
Level: Master Delver
Rank Points: 140
Registered: 01-27-2017
IP: Logged
icon Re: Card-Flipping Script (+1)  
Hi Tio,

I have a suggesting for solving the problem of revisiting cards and checking puzzles completeness when all cards have been turned.

You could define three separate entities. Let's call them Card-flipped, Card-unflipped and Card-dark.
If the player steps on or off a card, you could actually change that card into another one.
For instance: player steps Card-unflipped -> destroy Card-unflipped & generate Card-dark.
When used steps off the card -> wait one turn & destroy Card-dark & generate Card-flipped.

I this way, it is easy to control the properties of each 'state'. The Card-dark would be an obstacle, but the other types can be set to ghost-display to allow walking over them, for instance.

Furthermore, it would be easy to check the solution: make a separate NPC that only checks of there are any Card-unflipped monsters in the room. If not, the puzzles is solved.

Hope this helps. I'm not completely sure of your intentions, so perhaps I'm talking nonsense, but generally, defining separate entities should make things easier here.

Also, if you you can revisit cards that have already been flipped, perhaps you need different Card-dark entities for flipped and unflipped tiles.

Good luck with your work. Sounds like it has some really nice puzzle potential.

EDIT: I was under the impression that dark cards always will become passable again after one turn, but now I see that stepping on another card is actually necessary... That dude make things complicated indeed. The best solution would be as suggested to work with flour types. Alternatively, you could plug in a dedicated character that checks if Beethro steps on a card tile. As long as this entity moves before all card tiles are evaluated that would work.

____________________________
Autocorrect is not my friend. Apologies for the typos.
====
Go vote for the deadlies!
http://forum.caravelgames.com/viewtopic.php?TopicID=43863&page=0#428173

[Last edited by Dying Flutchman at 02-05-2019 02:44 PM]
02-05-2019 at 02:36 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 729
Registered: 06-13-2015
IP: Logged
icon Re: Card-Flipping Script (+1)  
Generating entities back and forth feels like a super messy way to handle this, with no particular benefit I can think of. The floor-type idea is absolutely the right call, I feel. In that case, my psuedo-code for the whole thing would look like this:

Click here to view the secret text


The nice thing about using orientation is that you only need one character to handle everything, and you can "tell" it whether it's up or down by just placing it with the right orientation in the editor.

One last caveat: Imperative required target makes Beethro's sword kill the character (and I'm pretty sure Invulnerable cancels the required-target status), and I'm not sure it plays well with a non-visible character either. I would make a separate character which is the "invisible gray" color, stuck inside a wall where the player can't get to it, be the required target that dies when the cards are all down.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 02-05-2019 03:37 PM]
02-05-2019 at 03:31 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Dying Flutchman
Level: Master Delver
Rank Points: 140
Registered: 01-27-2017
IP: Logged
icon Re: Card-Flipping Script (0)  
Hi Xindaris,

I can see why one would call my proposal messy :)

However, I was not only thinking about the mechanism of switching appearance of the cards: orientation is indeed the most logical way to handle that.

But to check if all cards are turned, you'd need to check all tiles for a) having a card and b) having a certain orientation. That's also pretty messy.

Now I think about it, three may be an elegant solution to the last part: you could put (for instance) grass floor under each card to start. When a card is turned over, build (for instance) road underneath. The solution checker now only needs to check if the are any grass tiles left or not. The 'did the player step onto a card' routine should check for grass or road tiles.


Edit: perhaps I should not try to follow these discussions on my phone. I missed a couple of solutions from earlier posts...

____________________________
Autocorrect is not my friend. Apologies for the typos.
====
Go vote for the deadlies!
http://forum.caravelgames.com/viewtopic.php?TopicID=43863&page=0#428173

[Last edited by Dying Flutchman at 02-05-2019 05:12 PM]
02-05-2019 at 04:11 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 729
Registered: 06-13-2015
IP: Logged
icon Re: Card-Flipping Script (0)  
I already covered how you could easily check for all the cards to be flipped: They update a global variable when flipped (add 1 when up, subtract 1 when down), the entity that checks that variable moves after they do. Very neat and doesn't require much to make work. It's in the "partial code" I posted earlier, even.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 02-05-2019 04:38 PM]
02-05-2019 at 04:38 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged
icon Re: Card-Flipping Script (+1)  
Script Update:

Click here to view the secret text

I think I'm getting somewhat closer with this version of the script? The issue now, though, is that the script isn't lightening cards at all.

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template

[Last edited by Professor Tio at 02-05-2019 05:47 PM : Checking script errors]
02-05-2019 at 05:27 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged

File: Card Pains.hold (2.5 KB)
Downloaded 0 times.
License: Public Domain
icon Re: Card-Flipping Script (+2)  
Annnd the script works as desired!

Click here to view the secret text

I attached a testing hold to demonstrate how I set it up. Feel free to fiddle around with it, it's only 2 rooms (one entirely empty) to test all the parts of the script.

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-05-2019 at 08:29 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Xindaris
Level: Smitemaster
Avatar
Rank Points: 729
Registered: 06-13-2015
IP: Logged
icon Re: Card-Flipping Script (0)  
Glad to hear (read?) you got everything to work like you wanted.

I will note that your final "Go to Inactive Card" command is actually causing an infinite-loop-within-one-turn, which DROD deals with by violently terminating the character's code. (This is why when you make some kind of loop it's usually important to put a wait 0 or some other turn-stopping command somewhere in it.) You could achieve the same effect (pretty much) by removing that command, since when DRODscript reaches the end of the commands it just stops running.

____________________________
109th Skywatcher

Here are some links to Things!
Click here to view the secret text


[Last edited by Xindaris at 02-06-2019 04:35 AM]
02-06-2019 at 04:33 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
Professor Tio
Level: Delver
Avatar
Rank Points: 63
Registered: 01-30-2019
IP: Logged
icon Re: Card-Flipping Script (0)  
Ah got it, removed that GoTo part.

Oh and on a funny side note, shortly after I finished making the script, I got a Youtube recommendation for this video - Card-Flipping Alternatives

Best timing ever, haha.

____________________________
Hold stuff I guess!
Click here to view the secret text
My personal mindset about making holds is to create puzzles that provide a challenge for beginners, but still serve as fun little exercises for veterans.

Random DROD RPG Score-Point Sheet Template I quickly created if you wanna easily keep track of all your individual score-points in a hold! Score-Sheet Template
02-06-2019 at 01:20 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Architecture : Card-Flipping Script (A Different Kind of Casino Game)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.