Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, juanex, Grant), 1,018 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
load_leve help :) #304037
01/04/10 17:09
01/04/10 17:09
Joined: Jan 2010
Posts: 3
C
chuj Offline OP
Guest
chuj  Offline OP
Guest
C

Joined: Jan 2010
Posts: 3
Welcome

I need help

You see I have a map(first_map.wmb, and i try load second map if i press X button

Code:
function load_map()
{
if(key_x) // X pressed
{
level_load("second_map.wmb");
}
}



This code does not works, why?

Last edited by chuj; 01/04/10 17:09.
Re: load_leve help :) [Re: chuj] #304040
01/04/10 17:21
01/04/10 17:21
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Code:
function load_map(STRING* filename)
{
    STRING* levelname = "#10";
    str_cpy(levelname, filename);
    str_cat(levelname, ".wmb");
    wait(1); //just for be sure the name is set
    error(levelname); //just for be sure the name is set
    level_load(levelname);
    wait(2);
}

function some_other_function()
{
    var keyget = 0; // the key_trigger, so the function isn´t called every frame!
    [...]
    while(1)
    {
        if(key_x == 1 && keyget == 0)
        {
            keyget = 1;
            load_map("second_map");
            wait_for(load_map);
        }
        else if(key_x == 0 && keyget == 1){keyget = 0;}
        wait(1);
    }
    [...]
}



tested and worked!


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: load_leve help :) [Re: Espér] #304053
01/04/10 18:12
01/04/10 18:12
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
short form ->

you need a while(1)...wait(1) around your if(key_x) grin

function load_map()
{
while(1)
{
if(key_x) // X pressed
{
level_load("second_map.wmb");
return;
}
wait(1);
}
}

Re: load_leve help :) [Re: Rei_Ayanami] #304071
01/04/10 21:25
01/04/10 21:25
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Or you could use on_x, like this:

Code:
function load_map()
{
  level_load("second_map.wmb");
}

on_x = load_map();



That's much more efficient than using a while loop, which might cause the map to load multiple times...


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: load_leve help :) [Re: Redeemer] #304089
01/04/10 22:57
01/04/10 22:57
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
@redeemer: if you have a close look to my example, you can see that i put a return after the level_load wink

Re: load_leve help :) [Re: Rei_Ayanami] #304093
01/04/10 23:21
01/04/10 23:21
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
@redeemer: i don´t think he want´s to change the level on every x-hitting ^^ i think he wanted to change the level, when level 1 is finished and the user presses X


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: load_leve help :) [Re: Espér] #304105
01/05/10 00:35
01/05/10 00:35
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Wait, didn't see the return() call in your code. Nevermind.

BTW: Happy birthday, guy!

Last edited by Redeemer; 01/05/10 00:35.

Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: load_leve help :) [Re: Redeemer] #304346
01/06/10 20:22
01/06/10 20:22
Joined: May 2006
Posts: 148
Latvia
MTD Offline
Member
MTD  Offline
Member

Joined: May 2006
Posts: 148
Latvia
If you load from another level - then put "me=null;" before level_load
other wise strange things happening wink
--------Preview

me=null;
level_load("test.wmb");
wait(1)

--------
And it should work.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1