The Daily Click ::. Forums ::. Klik Coding Help ::. Load Files in Array - String or Value?
 

Post Reply  Post Oekaki 
 

Posted By Message

caccolothemeaning



Registered
  03/12/2008
Points
  373
17th April, 2009 at 17:56:54 -

Greetings again...

This time I'm facing a weird detour in which I have to choose if use Global Strings to store the name of the level to load (and consequentially need to create a new frame for every premade level) or use a Global Value to simply increase and reload the frame when the level is completed.

The problem is:

With the Global String I allow the Array to load a specific file (eg. "C:\DOT Levels\"+Level+".arr" where "Level" is the actual Global String previously set) at the very beginning of the frame but I cannot make it to increase that value (suppose "Level" contains just the string "1" so the file to load would be "1.arr") when player completes the level. Then I will need frames over frames to load the default levels I've made for my game.

With the Global Value I can load all the levels within a single frame just increasing the "Level" value when player completes the level and refreshing the frame. And this seems the most obvious (and easiest) way to build my game... but I really don't know how to let the Array to handle the files to load. With Global Values I can't tell it to load "C:\DOT Levels\"+Level+".arr" since it will results as a Mixed Strings and Numbers and the script won't work.

I can let the game to use Global Strings if player has made a custom level and wish it to be loaded into the game but I prefere to use a Global Value instead of a Global String for my default levels.

Any ideas about that?

Thank a lot in advance!

Regards

 
Image

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1969

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th April, 2009 at 18:16:55 -

"C:\DOT Levels\Level" + Str$( Global Value A ) + ".arr"
(that's if the arrays are named "Level1.arr" etc)

Also, don't use fixed paths like "C:\DOT\Levels". It's much better to keep the levels in the same folder as the game itself, which the player should be able to put wherever they like (do NOT distribute your game in an installer).

Use the Appdrive$, Appdir$, and Apppath$ functions for this.


 
n/a

caccolothemeaning



Registered
  03/12/2008
Points
  373
17th April, 2009 at 18:27:51 -

Umh... I'm afraid I may need further informations about those last functions you mentioned 'cause I've never herad about them before.

And about the Str$( Global Value A )... sounds really like the right solution for me.

I'll make a try and post effects here

Thanks Sketchy!

--------------------

Or you mean Appdrive$+":\"+Appdir$+Str$(Global Value A)+".arr" ?

Edited by caccolothemeaning

 
Image

caccolothemeaning



Registered
  03/12/2008
Points
  373
17th April, 2009 at 18:37:06 -

Ok the thing with Str$( Global Value A ) works seamlessly! Thanks a lot! You're really a saviour to me!

If you wish so I'd like to know better about those functions you mentioned. I'll really apreciate that

 
Image

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1969

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
17th April, 2009 at 20:02:16 -

You find them under "Filenames" (in the same place as you retrieve Global Values etc from).
They tell you the current location of the game .exe itself, so it can be installed anywhere and still work properly.

Suppose your game is located at "C:\Games\MyGame\MyGame.exe"

Appdrive$ -> C:
Appdir$ -> \Games\MyGame\
Apppath$ -> C:\Games\MyGame\

You could easily store your levels in a separate sub-folder too, and use the following to load the array files:

Apppath$ + "Levels\Level" + Str$( Global Value A ) + ".arr"

This way, if the game itself were located at "C:\Games\MyGame\MyGame.exe", it would load level 1 from "C:\Games\MyGame\Levels\Level1.arr"


Edited by Sketchy

 
n/a

caccolothemeaning



Registered
  03/12/2008
Points
  373
18th April, 2009 at 00:32:06 -

I have no words to describe how much I thank you Sketchy.

You've really helped me a lot and now I'm ready to post a new project about this game I'm making.

The engine is complete I just have to design the "dungeon style" levels.

Thank you again!

 
Image
   

Post Reply



 



Advertisement

Worth A Click