Jump to content


Photo

Digimon RPG - the GM version!


  • This topic is locked This topic is locked
23 replies to this topic

#1 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 04:14 PM

Hi.
Check this first:
http://gmc.yoyogames...howtopic=535603

To make it short:
I'm trying to make a wide-range RPGish Digimon game for GM, with NPCs, battles, items, stuff and LOTS of Digivolutions!
Anyone on for a helping hand?

Current versions:
Ver. 0.1.0 (Fully working CHOOSING screen. Doesn't lead anywhere as of now.)

PS.
Thanks, Yal.
I needed to be pushed a bit. :thumbsup:

Edited by Koshej, 03 May 2012 - 12:25 PM.


#2 Jobo

Jobo

    Freelancer

  • Local Moderator
  • 2554 posts
  • Version:GM:Studio

Posted 02 May 2012 - 04:24 PM

sprite_index takes a resource (integer) representing a sprite.
Therefore you cannot feed it strings, as you do with string(argument) (string() converts argument to string format).
  • 0

#3 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 04:27 PM

So what CAN I do???
I've heard the CAN'T like 3 times already - so do suggest what I CAN do...

#4 PetzI

PetzI

    GMC Member

  • GMC Member
  • 1051 posts
  • Version:GM8.1

Posted 02 May 2012 - 04:40 PM

real(name) instead of string(name) will feed it a real number. I'm not sure about the rest, since you mentioned external names? I'm not entirely sure what you mean by that.

Edited by PetzI, 02 May 2012 - 04:42 PM.

  • 0

#5 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 04:48 PM

PetzI
Well, why don't you check out my ver.0... then?
You'll see it all.
Also, my point is THIS type of code:

ini_open("choice.ini")
keychoice="choice_"+string(i)
choicespr="choice"+string(i)
name="Pics/"+ini_read_string("choice",string(keychoice),"")+".png"
unlocked=ini_read_string("unlocked",string(keychoice),"")
if ((file_exists(string(name)))&&(unlocked="TRUE")) {execute_string(sprite_replace(string(choicespr),string(name),1,1,0,0,0))}
if ((!file_exists(string(name)))&&(unlocked="TRUE")) {execute_string(sprite_assign(choicespr,nopic))}
if (unlocked="FALSE") {execute_string(sprite_assign(choicespr,locked))}
ini_close()

The actual ERROR is, that ALL sprites get replaced with the LAST sprite replacement option, be it a loaded pic or hardcoded nopic/locked sprites...
Which shows TWO errors actually, cause previously changed sprites (choice1) should NOT be even affected by the next choices (choice2 etc)...
THIS I don't understand at all...

Edited by Koshej, 02 May 2012 - 05:08 PM.


#6 Jobo

Jobo

    Freelancer

  • Local Moderator
  • 2554 posts
  • Version:GM:Studio

Posted 02 May 2012 - 04:58 PM

Have you fiddled with sprite_get_name(string)?

keychoice="choice_"+string(i)
choicespr="choice"+string(i)
name="Pics/"+ini_read_string("choice" ,string(keychoice),"")+".png"
unlocked=ini_read_string("unlocked",string(keychoice), "")
You're constantly overwriting your variables. I suggest using an array?

Edited by Jobo, 02 May 2012 - 04:58 PM.

  • 0

#7 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 05:01 PM

Jobo
Can you please give me the actual CODE that I could try?
Cause I have no idea, where to put that thing in...
Or what it should end up giving to me.
Since it reads (index), but I want it to read string(choicespr), which IS a string.

Yeah, sorry, I meant the real problem is the choicespr sprite_index thingy, not string(name) which it reads ok (it's a FILE NAME!!!).

As of arrays, that's not the error reason, for sure.

Edited by Koshej, 02 May 2012 - 05:03 PM.


#8 Jobo

Jobo

    Freelancer

  • Local Moderator
  • 2554 posts
  • Version:GM:Studio

Posted 02 May 2012 - 05:10 PM

Cause I have no idea, [...] what it should end up giving to me.

How can I help you if you don't know what you want it to do?

Since it reads (index), but I want it to read string(choicespr), which IS a string.

And sprite_index does not take a string as an argument. This will return the integer value of the string thus giving you a completely unwanted result.

You will have to code a work-around for this.
if(choicespr == index) sprite_index = index;

I suggest using a switch statement for this.

switch(choicespr) {
     case "result 1 of choicespr":
          sprite_index = something;
     break;

     case "result 2 of choicespr":
          sprite_index = something else;
     break;

     ...
}

Also, if you're using a for-loop with the variable i, and you want to store all the "choicespr" possibilities in variables, look up on arrays.
  • 0

#9 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 05:16 PM

Jobo
Why don't you actually look at my file in the first post, ver.0.0.0.1???
It will give you all what I want to get as result, and also what I do get, the error is VISIBLE when you run the game.
I have choice(i) (aka choice1 through choice32) hardcoded "choosing" sprites.
I want to change them according to what the ini file says: into the monster(i).png/nopic/locked.
What it DOES though, it takes the last correct result and applies it to ALL sprites at once.
This doesn't make sense to begin with, cause I programmed it to do only ONE switch per sprite, not a step event that could repeat itself.
So, PLEASE, check out the file - and then help me with this stupid error...
PLEASE!!!

#10 Jobo

Jobo

    Freelancer

  • Local Moderator
  • 2554 posts
  • Version:GM:Studio

Posted 02 May 2012 - 05:24 PM

Post your entire script. I don't feel like going through the hassle of downloading and searching through a gmk file looking for someone's issue.
  • 0

#11 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 05:37 PM

Step event of object chooser:

if (i<32)
{
i+=1
instance_create(64*((i-1) mod 8),64*((i-1) div 8),pic)
ini_open("choice.ini")
keychoice="choice_"+string(i)
choicespr="choice"+string(i)
name="Pics/"+ini_read_string("choice",string(keychoice),"")+".png"
unlocked=ini_read_string("unlocked",string(keychoice),"")
if ((file_exists(string(name)))&&(unlocked="TRUE")) {sprite_replace(choicespr,name,1,1,0,0,0)}
if ((!file_exists(string(name)))&&(unlocked="TRUE")) {sprite_assign(choicespr,nopic)}
if (unlocked="FALSE") {sprite_assign(choicespr,locked)}
ini_close()
}

Create event of object pic:

t=instance_number(pic)
sprite_index="choice"+string(t)

It was tweaked a bit.
But the main thing is, it correctly reads the filenames, but then applies them to all current sprites...
What doesn't make sense at all - is how the sprites change real-time, with each new option being applied to ALL sprites.
The pic object has the only action during its creation - changing its sprite according to its number (simply sprite1 goes to object1, etc).
The chooser object has a step-limited change, which again SHOULD apply only to the sprite of that step (sprite5 on step5, nothing more affected)...
SO???
(I do advice running the actual game, so that you can SEE the error, it's very obvious, much more than from the code itself...)

EDIT:
OK, so no one is gonna help me for real...
As usual...

Edited by Koshej, 02 May 2012 - 09:19 PM.


#12 Weird Dragon

Weird Dragon

    GMC Member

  • Global Moderators
  • 1930 posts
  • Version:GM:Studio

Posted 02 May 2012 - 10:04 PM

...

Create event of object pic:


t=instance_number(pic)
sprite_index="choice"+string(t)


...


You can not use a string as a sprite index as has already been pointed out. Instead of that code use a switch statement as already suggested by jobo.
I took a look in your game and saw that your sprite names are choice1, choice2, choice3 etc. up to choice32.

This is what you can do:

Make a new variable, could be called sprite_choise. Then you can put this code in the create event of pic:
t=instance_number(pic);
sprite_choise="choice"+string(t);
    switch (sprite_choise)
  	{
 		case "choise1": sprite_index=choice1; break;
 		case "choise2": sprite_index=choice2; break;
 		case "choise3": sprite_index=choice3; break;
 		//  etc. ....
 		case "choice32": sprite_index=choice32; break;
   	}

That is 32 cases in the switch statement, takes a little time to type, but compared with how long it takes to type all the text in this topic it is a rather little effort.

Edited by Weird Dragon, 02 May 2012 - 10:10 PM.

  • 0

#13 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 02 May 2012 - 10:53 PM

This means, that I'd have to do the same with the previous code too (sprite_replace/assign).
Which makes a HUGE code...
Well, if there's no other option...
I'll tell you tomorrow, I'm gonna sleep now. :rolleyes:

The code will become:

if (i<32)
{
i+=1
instance_create(64*((i-1) mod 8),64*((i-1) div 8),pic)
ini_open("choice.ini")
keychoice="choice_"+string(i)
choicespr="choice"+string(i)
name="Pics/"+ini_read_string("choice" ,string(keychoice),"")+".png"
unlocked=ini_read_string("unlocked",string(keychoice), "")
if (i=1)
{
if ((file_exists(string(name)))&&(unlocked=" TRUE")) {sprite_replace(choice1,name,1,1,0,0,0)}
if ((!file_exists(string(name)))&&(unlocked=" TRUE")) {sprite_assign(choice1,nopic)}
if (unlocked="FALSE") {sprite_assign(choice1,locked)}
}
if (i=2) etc...
ini_close()
}

Hmmm...

Edited by Koshej, 02 May 2012 - 10:55 PM.


#14 Weird Dragon

Weird Dragon

    GMC Member

  • Global Moderators
  • 1930 posts
  • Version:GM:Studio

Posted 03 May 2012 - 12:04 AM

Just a short reply as I am also going to bed. The code i posted in my former reply can be slightly shorter, since you don't need two variables "t" and "sprite_choise". One is sufficient, "t", and you don't need to turn that one into a string:

t=instance_number(pic);
    switch (t)
        {
                case 1: sprite_index=choice1; break;
                case 2: sprite_index=choice2; break;
                case 3: sprite_index=choice3; break;
                //  etc. ....
                case 32: sprite_index=choice32; break;
        }

***

But you might want to store the sprites in an array since you also want to use them in the other code you posted, and the array can be used in both cases.

sprite_array[0] = choice1;
sprite_array[1] = choice2;
// etc. up to:
sprite_array[31] = choice32;

Then you only need this simple code in the create event of pic:
t=instance_number(pic);
sprite_index=sprite_array[t-1];

***

You could make the array global unless you want to refer to the instance where the array is initialized, could be in a controller object.

Global array:
global.sprite_array[0] = choice1;
// etc.

or if the array is initialized in an object named obj_ctrl:
obj_ctrl.sprite_array[0] = choice1;
// etc

***

or you could initialize the array in a script and call that script whenever you want to use the array:

A script named scr_array:

sprite_array[0] = choice1;
sprite_array[1] = choice2;
// etc. up to:
sprite_array[31] = choice32;

Create event of pic:

scr_array();
t=instance_number(pic);
sprite_index=sprite_array[t-1];

Edited by Weird Dragon, 03 May 2012 - 12:30 AM.

  • 0

#15 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 03 May 2012 - 10:14 AM

WeirdDragon
THANKS!!!
IT WORKS!!!
Final code (and THE thing was to move the ENTIRE code to the chooser object, I don't know WHY, but it solved the problem!).
Create event:

sprite_array[0]=none
sprite_array[1]=choice1
sprite_array[2]=choice2
sprite_array[3]=choice3
sprite_array[4]=choice4
sprite_array[5]=choice5
sprite_array[6]=choice6
sprite_array[7]=choice7
sprite_array[8]=choice8
sprite_array[9]=choice9
sprite_array[10]=choice10
sprite_array[11]=choice11
sprite_array[12]=choice12
sprite_array[13]=choice13
sprite_array[14]=choice14
sprite_array[15]=choice15
sprite_array[16]=choice16
sprite_array[17]=choice17
sprite_array[18]=choice18
sprite_array[19]=choice19
sprite_array[20]=choice20
sprite_array[21]=choice21
sprite_array[22]=choice22
sprite_array[23]=choice23
sprite_array[24]=choice24
sprite_array[25]=choice25
sprite_array[26]=choice26
sprite_array[27]=choice27
sprite_array[28]=choice28
sprite_array[29]=choice29
sprite_array[30]=choice30
sprite_array[31]=choice31
sprite_array[32]=choice32
for (i=1; i<33; i+=1)
{
nnn=instance_create(64*((i-1) mod 8),64*((i-1) div 8),pic)
nnn.sprite_index=sprite_array[i]
ini_open("choice.ini")
keychoice="choice_"+string(i)
name="Pics/"+ini_read_string("choice",string(keychoice),"")+".png"
unlocked=ini_read_string("unlocked",string(keychoice),"")
if (file_exists(string(name))) {sprite_replace(sprite_array[i],name,1,1,0,0,0)}
if ((!file_exists(string(name)))&&(unlocked="TRUE")) {sprite_assign(sprite_array[i],nopic)}
if (unlocked="FALSE") {instance_create(64*((i-1) mod 8),64*((i-1) div 8),locked)}
ini_close()
}

Step event:

ini_open("choice.ini")
keychoice="choice_"+string(1+(x div 64)+(8 * y div 64))
name=ini_read_string("choice",string(keychoice),"")
unlocked=ini_read_string("unlocked",string(keychoice),"")
chosen=ini_read_string("choice",string(keychoice),"")
if (unlocked="FALSE") {chosen=chosen+" - LOCKED"}
ini_close()

ENTER event:

show_message(string(chosen))

As of now, pressing Enter just shows you your choice but doesn't lead anywhere.

My near future plans are:
1. Adding stat viewing as a separate "window", whether VIEW or ROOM.
2. Proceeding to the adventure stage: choosing between NPC fights and hunting.
3. (Much later) The actual battle screen.

After MUCH work (mostly on the sprites), the final CHOOSING SCREEN version is finally done!
If interested, check my newly uploaded ver.0.1.0 for exact results. :thumbsup:

Edited by Koshej, 03 May 2012 - 12:23 PM.


#16 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 03 May 2012 - 02:59 PM

New problem:
screen_refresh removes all objects, but leaves the draw_text s...
How to draw things effectively???
I've read the help file - but somehow my game doesn't work accordingly.
Draw event, of course:

draw_text(x,y+64,name)
screen_refresh()

The game screen blinks for a few times, then only the text is left.
All objects come back, when I call up a message (obviously freezes the screen).
How to make this simple thing work???
Thanks...

PS.
Can it be something with the frequency???
Cause when I tried to draw sprites for the choosing screen, it worked similarly - blinking, appearing/disappearing of sprites...

Edited by Koshej, 03 May 2012 - 03:01 PM.


#17 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 03 May 2012 - 05:54 PM

New version of the same problem:

screen_wait_vsync()
draw_text(x,y+64,name)

Now I CAN see the other objects AND the text - but the drawing object's sprite is missing...
I'll have to use yet one more object for that - but maybe you do know a solution???

Oops...
Might NOT be the problem...
Also THIS ends up weird:
Create...

sprite_array[0]=none
sprite_array[1]=choice1
sprite_array[2]=choice2
sprite_array[3]=choice3
sprite_array[4]=choice4
sprite_array[5]=choice5
sprite_array[6]=choice6
sprite_array[7]=choice7
sprite_array[8]=choice8
sprite_array[9]=choice9
sprite_array[10]=choice10
sprite_array[11]=choice11
sprite_array[12]=choice12
sprite_array[13]=choice13
sprite_array[14]=choice14
sprite_array[15]=choice15
sprite_array[16]=choice16
sprite_array[17]=choice17
sprite_array[18]=choice18
sprite_array[19]=choice19
sprite_array[20]=choice20
sprite_array[21]=choice21
sprite_array[22]=choice22
sprite_array[23]=choice23
sprite_array[24]=choice24
sprite_array[25]=choice25
sprite_array[26]=choice26
sprite_array[27]=choice27
sprite_array[28]=choice28
sprite_array[29]=choice29
sprite_array[30]=choice30
sprite_array[31]=choice31
sprite_array[32]=choice32
for (i=1; i<33; i+=1)
{
nnn=instance_create(64*((i-1) mod 8),64*((i-1) div 8),pic)
nnn.sprite_index=sprite_array[i]
ini_open("choice.ini")
keychoice="choice_"+string(i)
name="Pics/"+ini_read_string("choice",string(keychoice),"")+".png"
unlocked=ini_read_string("unlocked",string(keychoice),"")
if (file_exists(string(name))) {sprite_replace(sprite_array[i],name,1,1,0,0,0)}
if ((!file_exists(string(name)))&&(unlocked="TRUE")) {sprite_assign(sprite_array[i],nopic)}
if (unlocked="FALSE") {instance_create(64*((i-1) mod 8),64*((i-1) div 8),locked)}
ini_close()
}

Step...

ini_open("choice.ini")
j=1+(x div 64)+(8 * y div 64)
keychoice="choice_"+string(j)
name=ini_read_string("choice",string(keychoice),"")
unlocked=ini_read_string("unlocked",string(keychoice),"")
if (unlocked="FALSE") {name="LOCKED"}
if (unlocked="TRUE") {sprite_assign(infopic,sprite_array[j])}
if (unlocked="FALSE") {sprite_assign(infopic,locked)}
info.name=name
ini_close()

infopic is the sprite of the info object.
Seems, that sprite_assign ISN'T working...
HELP, AGAIN!!!

Edited by Koshej, 03 May 2012 - 07:05 PM.


#18 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 04 May 2012 - 09:07 AM

Thanks for ignoring me. :whistle:

#19 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 04 May 2012 - 02:55 PM

Some great GML masters you all are... :verymad:

#20 theepicgeno

theepicgeno

    BrokenIMG

  • GMC Member
  • 926 posts
  • Version:GM:Studio

Posted 04 May 2012 - 03:12 PM

Some great GML masters you all are... :verymad:


Keep talking like that and we won't help you :)
  • 0

#21 Koshej

Koshej

    GMC Member

  • Banned Users
  • 40 posts
  • Version:GM8

Posted 04 May 2012 - 03:21 PM

Keep NOT helping me and I'll have a REASON to talk like that. :thumbsup:
I asked for a simple question help YESTERDAY, almost a DAY ago...
Now, ain't I right, if I didn't get an answer YET..???
(And it's definitely something simple, I just can't figure it out, WHERE is the glitch...)

#22 theepicgeno

theepicgeno

    BrokenIMG

  • GMC Member
  • 926 posts
  • Version:GM:Studio

Posted 04 May 2012 - 03:25 PM

I asked for a simple question help YESTERDAY, almost a DAY ago...
Now, ain't I right, if I didn't get an answer YET...

No. Cause once I waited a whole week with no replies. And illegal bumps are not cool.
  • 0

#23 talonstart

talonstart

    Artist

  • GMC Member
  • 450 posts
  • Version:GM:Studio

Posted 04 May 2012 - 04:50 PM

I do not enjoy a person that is forcing one to help..
To be a greedy meany who dosnt know what to do, and call the people who will help crap.. is not going to make people want to help you.

1.) you should hold patience - its a key factor in the programming world.

2.) dont force yourself to get a free code, cause then were making the game not you.

3.) let people offer there service.. if you dont get it. (grab a book, and read) tutorials.. try something different..

4.) you should respect the people here, there here to help what they can, we dont know your game nor want too we just wanna play it when your done.

5.) if we have the ideal what your doing, or want help you should post in the forums looking for groups. and post your project for hire..

Dont be a sour wart.. take your time.. and patience.
  • 0

#24 Nocturne

Nocturne

    Nocturne Games

  • Administrators
  • 19895 posts
  • Version:GM:Studio

Posted 05 May 2012 - 05:58 PM

Koshej, I am closing this topic and I suggest that you go and read the rules of the forum before you decide to post again... You have done nothing but illegally bump this topic and then complain because you don't get help quick enough, and THAT is not the way of this community. You are no better than anyone else here and if they have to wait 48 hours to get their questions answered, then so do you. Posted Image
  • 3




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users