SpinLock Module: basic help

Started by vjamesv, Fri 19/01/2007 04:26:15

Previous topic - Next topic

vjamesv

I am trying to get the SpinLock module working in my game, and so far I have gotten the left and right buttons working correctly where they spin the dial, but i am not sure how to test if the correct combination has been tested.  i used the code included in the readme file which is:


if (SpinLock.SpinRight()){
  Display("You figured it out!");
}

and i put that code in the interaction for the right arrow button.  after i did that when i used the button it would turn the dial by two numbers instead of one.  can someone help me with this?

i haven't tried making a reset button, i am hoping to figure that out by looking through the code, but if someone can help with that too that would be great.  i think this is an awesome module, but i did not find many posts on it, and there was not much documentation.

Khris

SpinLock.SpinRight() will turn the dial even if it is the if-condition.

Code: ags
bool a=SpinLock.SpinRight();  // turn dial

if (a) Display("You figured it out!");


OR remove the first call to SpinRight(), the one before the if.

Implementing a reset button should be simple, just call SpinLock.ResetCombo() in its onClick-code.

vjamesv

The reset button worked great, and I also put in an exit button.  I still cannot get it to recognize when i have put in the correct combination though.  I have tried both ways you mentioned for the right button:

bool a=SpinLock.SpinRight();
if (a) Display("You figured it out!");

and i also tried:

if (SpinLock.SpinRight()){
  Display("You figured it out!");
}

Both ways, i could spin the lock forever and i never got the combination.  here is what i used to set the combination.  i put this in the room settings to occur after fadein:

SpinLock.InitLock(3,42,8); 
SpinLock.SetCombo(2,1,5);

please help....   thank you

Ashen

I'm not very familiar with the module (available HERE, for anyone wondering), but what if you ignore that SpinLock.SpinRight should check the combo as well, and directly use SpinLock.CheckCombo yourself?

Since the module's author hasn't been on in over a year, I doubt you'll get any official support on this. Perhaps you could try adding a few Display... commands to the module script, to see where the check is failing?
I know what you're thinking ... Don't think that.

vjamesv

well that sucks.  i sent him a message, so we'll see if i can get a response. 

i put in the checkcombo but i still am not getting a response to anything i do.  all i do is sit and spin...

maybe strazer will be able to help me figure it out since it looks like he had a lot of input on the module... 

Maverick

Ashen

I looked at the code for checkcombo and I have some ideas why it doesn't work but as a noob I would rather reserve my opinion before someone takes my head off.

Vjamesv
I managed to create a little work around if you are interested

Add the following code to the header script
Code: ags

struct SpinLock{
Ã,  import static function InitLock(int obj, int view,Ã,  int max);
Ã,  import static function SetCombo(int a, int b, int c);
Ã,  import static function ResetCombo();
Ã,  import static function SpinLeft();
Ã,  import static function SpinRight();
Ã,  import static function CheckCombo();
Ã,  [color=Red]import static function CheckSolved();[/color]

};

In the main module script add this function above checkcombo
Code: ags

static function SpinLock::CheckSolved(){
	if(firstBool == true && secondBoolA == true && secondBoolB == true && currentPosition == thirdNum){
	Display("Hoorah");//or whatever caption you want to display
	}
Ã,  
} 


Add the function above to your SpinRight function in the main module script like this:
Code: ags

static function SpinLock::SpinRight()
{
Ã,  if(firstNum < 0)
	{
	Ã,  Display("You have not set the combination");
	
	}
Ã,  prevPosition = currentPosition;
Ã,  currentPosition --;
Ã,  if(currentPosition < 0)
Ã,  {
Ã,  Ã,  currentPosition = maxNum;
	}
	object[obj].SetView(view, 0, currentPosition);
	prevDirection = direction;
	direction = "right";
	[color=Red]SpinLock.CheckSolved();[/color]
			
	if(SpinLock.CheckCombo())
	{
	Ã,  return true;
	}
	else
	{
	Ã,  return false;
	}
}


Now you do not need to put the if(Spinlock.SpinRight()) in the room script.
I know that this is not the perfect solutionÃ,  :P (maybe Ashen can clean it up) but I tested it and it works which seems to be the issue here.

vjamesv

i input all the code you gave me, and when i went to save the room i got this error:

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:

In: 'Script header'



Error (line 5): 'SpinLock' is already defined



Do you want to fix the script now? (Your room has not been saved).
---------------------------
Yes   No   
---------------------------



maybe i did not put the struct in the right spot?  i put it in the header script




Maverick

#7
Where exactly did you put this code?
Did you edit the modules header or create a new header?

I uploaded a demo with the altered module HERE and the "changed"(Sorry Snake Blisken I just couldn't figure it out) module HERE . Take a look at the demo and you will see where I added the code. The combination is set for 5,1,3.

I also suggest that you add the following line of code to fix the problem with the final dial only being set properly after the text "Hoorah" has already been displayed.

Code: ags

static function SpinLock::CheckSolved(){
if(firstBool == true && secondBoolA == true && secondBoolB == true && currentPosition == thirdNum){
Wait(5); // THIS IS THE LINE YOU MUST ADD!!!!!!!!!!!
Display("Hoorah");//or whatever caption you want to display
}
Ã,  
} 



I hope this helps.

EDIT 6/2/2007
Download file update for demo game (now virus free :-[).
Take note that the wait command is now included i the the CheckSolved function to make sure that the rotation is completed before "Hoorah" (or whatever) is displayed.Ã,  Sorry about the win 32/Hirag.a but my anti virus program did not pick it up (not even when I scanned for it today even though the last update was 27/1/2007) but AVG7 did so I'm sure its fixed.

EDIT 9/2/2007
Uploaded a new module file with the fix.



vjamesv

yeah i was in the wrong area.  i was using the game's header script and not the module's.  thank you so much for your help!

AntmanJB

Hey, I found a similar thread but it didn't fully answer my questions so I'm just going to ask them myself.
First of all, where do I put the module so AGS can recognise it?
Well actually, what I'm looking for is a step-by-step guide to getting it to work. The readme file was not very clear.
Thanks for any help you can give me.
By the way, it's that Snake Blissken one.
"Marge, it takes two to lie. One to lie, and one to listen."

Khris

From the script menu, choose Module manager and import it there.

vjamesv


Yeah the instructions did not help me at all, so it took me a while to figure out how to make it work. 

I made a separate room for this, and i put the graphics in there as separate objects.  Then in the interaction menu for each object, under 'any click on object' i put run script, and then put the script for each object as explained in the readme file there. 

Also, for the settings in the room, when the players enters i put a run script where i ran the SpinLock.InitLock and SpinLock.SetCombo commands. 

Hope that helps get you started.

AntmanJB

Okay, I've managed to do most of it.
I have the room, with the combo as an object using all the different views. The spin left, spin right and reset buttons are all working properly. (Note: the object can't cover those buttons or they won't work, I used hotspots for them.)
The only thing I can't work out is how exactly to use the SpinLock.CheckCombo bit to finish it.
As soon as I do that, my small game will be done! I think I'll post it here if I can, although don't get your hopes up for something great.

Anyway thanks for the help.
"Marge, it takes two to lie. One to lie, and one to listen."

Khris

Try this:

Code: ags
// inside spin left/right-button's on_Click
  SpinLock.SpinLeft();/SpinRight();
  if (SpinLock.CheckCombo()) {
    Display("The lock springs open!");
    player.ChangeRoom(5);
  }

Maverick

This question came up a few weeks ago so you can also take a look at THIS thread to help you along.

As for how the spinlock works:

Rotate right till you hit the first number
Rotate left and pass the second number the first time you reach it and go all the way around till you hit it again
Rotate right until you hit the 3rd number and the lock should be open.
QuoteAs soon as I do that, my small game will be done! I think I'll post it here if I can, although don't get your hopes up for something great
By saying post it here I assume you mean in the game release section of the forum and not in this thread because that is a definate no no!




AntmanJB

Okay Maverick, number 1: I already looked at that page and it didn't answer my first questions. That's why I started this post.
Number 2: I know where the finished games go.
Number 3: YOUR EXAMPLE LOCK IN THE OTHER THREAD DOWNLOADED A VIRUS TO MY COMPUTER.
So maybe you should check on that.
Luckily it seems to be a low threat one.
"Marge, it takes two to lie. One to lie, and one to listen."

Ashen

OK, I'd somehow managed to miss this (second) thread.

AntmanJB, since the questions are closely related I've merged them. As I told vjamesv in another of his threads questions about a specific module really belong in the module's thread, to keep them all together. Keeping them to one thread here is the next best thing :)

Maverick, I also get that virus error - it seems to be in the compiled exe of the test game. Deleting that folder and recompiling seems to get rid of the threat, but you might want to look in to it, as Antman says.
I know what you're thinking ... Don't think that.

AntmanJB

#17
Yeah that's okay that you merged them. Except that now people think my problems has been solved since it says that in the subject line!
I'm still having trouble with the checkcombo.
Code: ags
<SpinLock.SpinLeft();Ã,  
if(SpinLock.CheckCombo()){Display("blah blah")>

That's what I have for SpinLeft, and for SpinRight too.
But whenever I put in the combo, it doesn't end.
I followed the correct directions but it still won't recognise it.
I couldn't seem to follow those earlier suggestions about altering the module's script so any advice would be appreciated.
"Marge, it takes two to lie. One to lie, and one to listen."

Ashen

Dang, I thought I'd set it to use your title, sorry about that. I guess now this can stand as the SpinLock help thread, since it seems to have picked up some interest (nothing for a year, then 2 questions in a month!).

Unfortunately, it seems like CheckCombo not working properly is some quirk of how it was coded. Maverick's version fixed that, I think, so if we can get a virus-free version up you should be OK.
I know what you're thinking ... Don't think that.

Maverick

Holy Sh..! :-[

Updated it so try it again.

SMF spam blocked by CleanTalk