Reading the value of a variable[solved]

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Reading the value of a variable[solved]

Postby Skye » Wed Dec 28, 2005 2:43 pm

I wonder if someone can help me with a little problem.

In my game I have boxes of fuses that can be in any one of 4 locations and there can be 0 to 4 boxes available.

Currently, I am using 4 different variables for this
eg BoxAt01, BoxAt02, BoxAt03, BoxAt04

What I'm trying to do is achieve the same result but by using only 1 variable. I have an idea to use a numerical value assigned to the single variable that will allow the game to determine where the boxes are located
eg BoxOfFuses = 0110 - this would mean that there is a box at location 2 and 3, nothing at location 1 and 4.

I have no idea how I would script a procedure that could 'look' at the individual digits and thereby determine whether or not an overlay should be displayed nor how I could change the variable contents to 0 when the player picked up one of the boxes.

If anyone has any ideas I would really appreciate it. I'm struggling to try and reduce the number of variables I have in my game so that it doesn't take in the neighbourhood of 1:30 - 2:00 minutes to reload a saved game.

Skye
Skye
Expert Member
 
Posts: 325
Joined: Sat Sep 13, 2003 4:19 pm
Location: British Columbia, Canada

Postby ShadowHunter » Wed Dec 28, 2005 8:56 pm

Hi,

This is a way... it's just a demo example of course :wink:

Code: Select all
Sub Parse4Bit
   For k = 1 to 4
      'mid(text,start,length)
      Digit = Mid("0110",k,1)
         If Digit = 0 Then
            Hotspot(k).visible = false
            MsgBox "Hotspot " & k & " is invisible"
         Else
            Hotspot(k).visible = true
            MsgBox "Hotspot " & k & " is visible"
         End If      
   Next
End Sub


Hope it will help !

Good luck,

ShAdOwHuNtEr
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby Rooster » Wed Dec 28, 2005 9:14 pm

Hi Skye.

1. declare a global variant variable "box_switches"

2. initiate at game start; box_switches = "0000"

3. to set a switch; create a procedure as follows, and invoke it with the relevant switch number (ex set_box_switch 1)

sub set_box_switch (switch_no)
box_switches = mid(box_switches,1,switch_no - 1) + "1" + mid(box_switches,switch_no + 1, len(box_switches) - switch_no)
End Sub

4. to check the values of all the switches, do as follows

ix= 1

Do until ix > 4
value = mid(box_switches,ix,1)
MsgBox cstr(value)
ix = ix + 1
Loop



I hope this can be of any use for you. Note that if you use the debug tool to check the values of the variables, the first zeroes are suppressed, even in a variant variable.

I'm not a VBScript expert at all, there may be hundreds of better ways to do this, but it works anyway... :D

Hmmm, I see shadowhunter has given a reply as well, hmm, as I said, not a VBScript expert...

Struggling as you are, with the number of switches... Try to reuse switches as well, but it's easy to get lost....

Good luck

/Rooster
User avatar
Rooster
Active Member
 
Posts: 70
Joined: Wed Oct 13, 2004 1:42 pm
Location: Sweden

Postby Skye » Thu Dec 29, 2005 4:59 am

Thanks for the help ShadowHunter and Rooster. I'll see if I can figure it out.

Skye
Skye
Expert Member
 
Posts: 325
Joined: Sat Sep 13, 2003 4:19 pm
Location: British Columbia, Canada

Postby !Jakon » Sun Mar 26, 2006 6:18 am

I think you are right guys! :)
God bless America!
!Jakon
New Member
 
Posts: 4
Joined: Sun Mar 26, 2006 6:17 am


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests