Cannot condition a WriteINI line?

This forum is meant for people to share their knowledge by writing their own tutorials for Adventure Maker.

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

Cannot condition a WriteINI line?

Postby drdna » Sun Feb 15, 2015 1:25 am

Hello all,

I cannot seem to include a Action.WriteINI line into a "If, then, else" conditional loop. Here's what I'm trying to do:

I have 6 hotspots. I click a button and I get 6 random buttons in their place. I click it again and I get 6 more random buttons etc. That part works great using a random generator to populate a chal1 variable for button 1, chal2 for button 2, chal3 for button 3, and so on. Now, I need to be able to click on a button, and depending what it is, write to an INI file. The condition I use is this:

Code: Select all
If chal1 = 1 Then
Action.WriteINI "P:\Pushfile.dd",1,1, "Button 1"
ElseIf chal1 = 2 Then
  Action.WriteINI "P:\Pushfile.dd",1,1, "Button 2"
ElseIf chal1 = 3 Then
  Action.WriteINI "P:\Pushfile.dd",1,1, "Button 3"


This is only for the first 3 but you should get the idea. I use the same type of code for randomizing the buttons and it works fine. I have even verified that the variable is valid by creating a test field on the frame to display it. However, let say that variable "chal1" is 3, and I click the button #3, it does not write anything to the file. I have added some other code and it does execute withing the condition, so the coding is correct. I've also tried JUST the Action.WriteINI "P:\Pushfile.dd",1,1, "Button 3" line and it works perfectly, just NOT with the conditional statement.

I'm at my wits end. Can someone explain why Action.????? works inside a If/then/else statement but WriteINI won't?

Oh, I've even tried a single line condition:

Code: Select all

   If chal1 = 1 then Action.WriteINI "P:\Pushfile.dd",1,1, "Button 1"
   If chal1 = 2 then Action.WriteINI "P:\Pushfile.dd",1,1, "Button 2"
   If chal1 = 3 then Action.WriteINI "P:\Pushfile.dd",1,1, "Button 3"



Nothing works. Why?

Thanks
drdna
Member
 
Posts: 49
Joined: Fri Dec 29, 2006 10:16 pm

Re: Cannot condition a WriteINI line?

Postby reneuend » Sun Feb 15, 2015 8:06 pm

I'm not sure "why" you are writing to a file, but that's outside the actual issue.
I noticed that you put in the actual path. I think you would be better off storing the INI in the "external" folder of your project and using GetPath(2) to set the path to it: So in our case: Action.WriteINI GetPath(2) + "Pushfile.dd", 1, 1, "Button 1"
Another possibility, and not a good one, is calling a subroutine from the if condition and putting the WriteINI command inside the subroutine. Kind of a indirect way of using this command.

I built my own routine to write to files because I wanted more control of the file structure.
In case you are interested, there is an article on it in BBB issue 15: http://hickchickgames.com/am_magazine/bbb15.pdf
I think I've updated the routine since that time, but not sure. I'll get you the latest if you are interested.

Good Luck and keep us updated on the outcome.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2680
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA


Return to Post Your Own Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests

cron