AccueilAccueil  FAQFAQ  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  Connexion  
Le Deal du moment :
Funko POP! Jumbo One Piece Kaido Dragon Form : ...
Voir le deal

 

 [Résolu] cannot assign to the variable

Aller en bas 
3 participants
AuteurMessage
Chulien
Utilisateur confirmé: Rang *****
Chulien


Messages : 2232

[Résolu] cannot assign to the variable Empty
MessageSujet: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable EmptyVen 3 Sep 2010 - 18:10

Code:


    for(i=0; i<global.narti; i+=1)
    {
        artic = instance_find(obj_arti, i)
        for(j=0; j<global.nphases; j+=1)
        {
            (artic).phase[j] = instance_create(0,0, obj_phase)      //<<====== va pas plus loin...
            ( (artic).phase[j]).x_rel = (artic).x_rel;
            ( (artic).phase[j]).image_xscale = (artic).image_xscale;
        }   
    }   


ce code est exécuté une seule fois
les global.nquelquechose sont le nombre des objets en question
je n'arrive pas à dépasser cette ligne de code, artic étant l'id d'un objet
quelqu'un aurait il l'instinct pour trouver la solution?

Code:
___________________________________________
ERROR in
action number 1
of Key Release Event for <no key> Key
for object obj_phase:

In script scr_init_creer_mouvement:
Error in code at line 87:
              (arti).phase[j] = instance_create(0,0, obj_phase)

at position 14: Cannot assign to the variable


edit: j'ai trouvé ça sur un site

This error appears if you try to give a read-only variable a value.
mais canard.costume[2] c'est pas une variable en lecture seulement, on peut la modifier je vois pas pourquoi...


Dernière édition par Chulien le Ven 3 Sep 2010 - 19:26, édité 2 fois
Revenir en haut Aller en bas
http://sites.google.com/site/chuliendev
glcraft
Utilisateur confirmé: Rang *****
glcraft


Messages : 1698
Localisation : Entre l'Espagne, l'Italie, la Suisse, L'allemagne et le RU :P
Projet Actuel : Jeu de survie avancé
||--------

[Résolu] cannot assign to the variable Empty
MessageSujet: Re: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable EmptyVen 3 Sep 2010 - 18:22

on aurait pu penser que c'est a cause de la parenthese mais je doute que ce soit ca, ce serait trop simple pour un "Cannot assign to the variable" ^^

edit, j'ai compris
Citation :

for(i=0; i<global.narti; i+=1)
{
artic = instance_find(obj_arti, i)
for(j=0; j<global.nphases; j+=1)
{
(artic).phase[j] = instance_create(0,0, obj_phase) //<<====== va pas plus loin...
( (artic).phase[j]).x_rel = (artic).x_rel;
( (artic).phase[j]).image_xscale = (artic).image_xscale;
}
}

artic est un chiffre, le nombre d'instance nomméobj_arti et tu demande d'assigner (artic).phase[j] comme ci artic était un objet. Mais artic n'est qu'un chiffre, voila le probleme, c'est comme si en C++, tu assignait (artic).phase[j] alors queartic n'est pas une classe ni une structure mais juste une variable. Tu as compris le probleme ?
Revenir en haut Aller en bas
http://gameblog49.skyblog.com/
M@d_Doc
Modérateur
M@d_Doc


Messages : 6600
Localisation : 47°44'8.04
Projet Actuel : aucun

[Résolu] cannot assign to the variable Empty
MessageSujet: Re: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable EmptyVen 3 Sep 2010 - 19:10

en fait, non.
instance_find() retourne l'id (donc le pointeur en C++) de la nième instance d'un objet.
Donc de ce côté là, tout est bon.
En effet,

(0012092).phase[j] = blablabla

devrait marcher

_________________
[Résolu] cannot assign to the variable Control-commentTous les icones de gm utilisables sur le cbna ICI  [Résolu] cannot assign to the variable Main1-change-sprite
Revenir en haut Aller en bas
http://www.lecbna.org
Chulien
Utilisateur confirmé: Rang *****
Chulien


Messages : 2232

[Résolu] cannot assign to the variable Empty
MessageSujet: Re: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable EmptyVen 3 Sep 2010 - 19:23

c'est bon, j'ai trouvé, c'était une erreur bête de ma part:

il y avait en fait deux objets différents

obj_arti et obj_arti_mouv

à ce moment là, aucune instance d' obj_arti n'existe, seulement des obj_arti_mouv.
donc le instance_find(obj_arti, i) renvoyait... -4 apparemment, ce qui n'est pas un id.

voilà, c'est ma ptite vie, l'air de rien je pense qu'avoir posté m'a aidé à chercher, merci tord
Revenir en haut Aller en bas
http://sites.google.com/site/chuliendev
M@d_Doc
Modérateur
M@d_Doc


Messages : 6600
Localisation : 47°44'8.04
Projet Actuel : aucun

[Résolu] cannot assign to the variable Empty
MessageSujet: Re: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable EmptyVen 3 Sep 2010 - 19:26

ouaip, quand il ne trouve, il renvoi une valeur négative, car 0 peux correspondre à une id pour certaines ressources (sprites pas sur, son etc)

_________________
[Résolu] cannot assign to the variable Control-commentTous les icones de gm utilisables sur le cbna ICI  [Résolu] cannot assign to the variable Main1-change-sprite
Revenir en haut Aller en bas
http://www.lecbna.org
glcraft
Utilisateur confirmé: Rang *****
glcraft


Messages : 1698
Localisation : Entre l'Espagne, l'Italie, la Suisse, L'allemagne et le RU :P
Projet Actuel : Jeu de survie avancé
||--------

[Résolu] cannot assign to the variable Empty
MessageSujet: Re: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable EmptyVen 3 Sep 2010 - 19:29

lol ok
(et je me suis trompé la reponse derniere, artic n'est pas un nombre c'est un id, je croyais que tu utilisais la fonction instance_number(), en tout cas tu la résolu ^^)
Revenir en haut Aller en bas
http://gameblog49.skyblog.com/
Contenu sponsorisé





[Résolu] cannot assign to the variable Empty
MessageSujet: Re: [Résolu] cannot assign to the variable   [Résolu] cannot assign to the variable Empty

Revenir en haut Aller en bas
 
[Résolu] cannot assign to the variable
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» [résolu] Une variable globale ou une variable locale persistante?
» [résolu] Problème de variable
» [résolu]Variable/afficheVie
» sauvegarde variable [Résolu]
» [résolu] Variable var inconnue

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Forum Le CBNA :: Développement :: Entraide débutants-
Sauter vers: