Hauptmenü

Neuigkeiten:

Bitte unterstützt uns und bestellt über diese Links bei Amazon  oder HumbleBumble!

Spezielles Türen-Script

Begonnen von NsMn, 23. Mai 2008, 16:12:55

Vorheriges Thema - Nächstes Thema

NsMn

Ich hätte mal eine Frage zu folgendem script(hab ich selbst ausgetüftelt):
Hotspot 2:

if(UsedAction(A_OPEN)){
player.Walk(271, 127,eBlock,eWalkableAreas);
ObjectOn(0);
PlaySound(2);
RestoreWalkableArea(3);
DisableHotspot(2);
}
else Unhandled(); 

Objekt 0:

...
else if(UsedAction(A_CLOSE)){
player.Walk(269, 131, eBlock, eWalkableAreas);
FaceDirection(player.ID, DIR_RIGHT);
PlaySound(3);
ObjectOff(0);
EnableHotspot(2);
RemoveWalkableArea(3);
}
...

Gibt es dafür keine einfachere Lösung?

LilaQ

Was möchtest du daran denn noch einfacher haben? Ist doch schon relativ slim.
Entwicklungsstatus:

A Christmas Odyssey

- [ GAME ] 100% Done
- [ TRANSLATION ] 71% Done

Bernard on a Boattrip(WT)

- [ GAME ]    1% Done
  >> Story: 10%
  >> Graphics: 1%
  >> Code: 0%
- [ TRANSLATION ] 0%
---------
http://theadventurebl0g.wordpress.com/

NsMn

#2
Okay.Aber wie müsste ich das schreiben,damit ich es als functionsbei AGS importieren könnte?
also das die functions lauten:
tuerHotspot(int object,int walkable Area,close string)
tuerObject(int hotspot,int walkable Area,open string,int new room)
PS:open string:was gesagt wird wenn die offene Tür geöffnet werden soll
close String:was gesagt wird wenn die geschlossene Tür geschlossen werden soll
Edit:Ach,das wäre wohl noch komplizierter ;)

LilaQ

Entwicklungsstatus:

A Christmas Odyssey

- [ GAME ] 100% Done
- [ TRANSLATION ] 71% Done

Bernard on a Boattrip(WT)

- [ GAME ]    1% Done
  >> Story: 10%
  >> Graphics: 1%
  >> Code: 0%
- [ TRANSLATION ] 0%
---------
http://theadventurebl0g.wordpress.com/

Kaktus

#4

function tuerHotspot(int tuerObject, int tuerHotspot, int tuerWalkable, const string closeString){
     if(UsedAction(A_OPEN))
     {
          PlaySound(2);
          object[tuerObject].Visible=1;
          RestoreWalkableArea (tuerWalkable);
          hotspot[tuerHotspot].Enabled=0;

      }
     else if(UsedAction(A_CLOSE)) player.Say(closeString);
     else return 0;
}



function tuerObject(int tuerObject, int tuerHotspot, int tuerWalkable, const string openString, int newRoom){
     if(UsedAction(A_CLOSE))
     {
          PlaySound(3);
          object[tuerObject].Visible=0;
          RemoveWalkableArea (tuerWalkable);
          hotspot[tuerHotspot].Enabled=1;
      }
     else if(UsedAction(A_OPEN)) player.Say(openString);
     else if(UsedAction(A_WALK_TO)) player.ChangeRoom(newRoom);
     else return 0;
}


So könnte es dann beispielsweise im Script vom Hotspot aussehen:

if(MovePlayer(271,127){
     if(tuerHotspot(0, 2,3, "Die ist schon geschlossen.")){}
     else if (UsedAction(A_LOOK_AT)) player.Say("Das ist eine schöne, geschlossene Tür.");
     else Unhandled();
}

und vom Objekt:

if(any_click_move(271,127, DIR_RIGHT){
     if(tuerObject(0, 2,3, "Die ist schon geöffnet.",1)){}
     else if (UsedAction(A_LOOK_AT)) player.Say("Das ist eine schöne, geöffnete Tür.");
     else Unhandled();
}


Nicht getestet, aber sollte funktionieren. (Vielleicht ist irgendwo noch ein Tippfehler drin ;) )

NsMn

#5
Super!Wenn ich jetzt noch die anderen Ints(Koordinaten etc)dazunehme spart das mir vie Arbeit!Danke!
Edit:Es werden die ganze Zeit Fehler angezeigt, dass ich kein "FaceDirection" benutzen darf  ???
Hier wäre mein Script:

function DoorO( int GI, int doorobject, int dir,int doorhotspot, int walkableArea, const string open,const string lookat, int x, int y){
    if(UsedAction(A_CLOSE)){
    player.Walk(x, y, eBlock, eWalkableAreas);
    FaceDirection(player.ID, dir);
    PlaySound(3);
    ObjectOff(doorobject);
    EnableHotspot(doorhotspot);
    RemoveWalkableArea(walkableArea);
    SetGlobalInt(GI, 0);
    }
    else if(UsedAction(A_LOOK_AT)){
      player.Walk(x, y, eBlock, eWalkableAreas);
      FaceDirection(player.ID, dir);
      Display(lookat);
    }
    else if(UsedAction(A_OPEN)){
      player.Walk(x, y, eBlock, eWalkableAreas);
      FaceDirection(player.ID, dir);
      Display(open);
    }
      else Unhandled();
}

Kaktus

Also für mich sieht es richtig aus. Wie lautet denn die genaue Fehlermeldung?


Nebenbei bemerkt solltest du den Charakter niemals mit Block zu einem Hotspot laufen lassen.

NsMn

#7
"already referenced name as import;you must define it before using it"
EdiT:das script wäre jetzt so:
function DoorO( int GI, int doorobject, int dir,int doorhotspot, int walkableArea, const string open,const string lookat, int x, int y){
    if(UsedAction(A_CLOSE)){
    MovePlayer(x, y);
    FaceDirection (GetPlayerCharacter (), dir);
    PlaySound(3);
    ObjectOff(doorobject);
    EnableHotspot(doorhotspot);
    RemoveWalkableArea(walkableArea);
    SetGlobalInt(GI, 0);
  }
  else if(UsedAction(A_OPEN)){
    MovePlayer(x, y);
    FaceDirection (GetPlayerCharacter (), dir);
      Display(open);
}
    else if(UsedAction(A_LOOK_AT)){
      MovePlayer(x, y);
      FaceDirection (GetPlayerCharacter (), dir);
      Display(lookat);
    }
    else return 0;
     
}

Kaktus

Man muss eine Funtion erst deklarieren bevor man sie aufrufen kann.
Beispiel:
Das würde funtionieren

function blabla()
{
// mach irgendwas
}

blabla();


Andersrum aber nicht:


blabla();

function blabla()
{
// mach irgendwas
}



Also suche mal im Script nach "function FaceDirection()" und stell sicher, dass deine eigene Funktion darunter steht

NsMn

Ach so!Gut,danke,funktioniert einwandfrei.Schade nur,dass man nur begrenzt vile Ints einfügen kann.

1mal_volltanken

Zitat von: edna_mausi in 24. Mai 2008, 14:01:24
Ach so!Gut,danke,funktioniert einwandfrei.Schade nur,dass man nur begrenzt vile Ints einfügen kann.

Wie viele Ints sind denn offiziell zulässig? Das kann ja durchaus wichtig sein, falls man mal ne größere Epi plant.
"Tage sind eigentlich wie Nächte...nur nicht ganz so spät!"...hörte ich einmal einen sehr klugen, alten Mann beim Erdnüsse sortieren in der Kneipe sagen, kurz bevor er vom Hocker rutschte.


"Nicht jeder, der aus dem Rahmen fällt, war vorher im Bilde!"

Kaktus

@edna_mausi Ja, das Limit liegt afaik bei 14 Parametern für Funktionen. Wenn du mehr brauchst, musst du wohl oder übel zwei Funktionen verwenden.

@1mal_volltanken Soweit ich weiß gibt es da bei den normalen Ints keine Beschränkung.
Nur bei den Get/SetGlobalInts gibt es eine Beschränkung auf 500, aber soviele würde kein Mensch verwenden, das würde das Script beinahe unlesbar machen.

Bòógieman

hab vor langer zeit mal ein plugin gesehen das die max GI anzahl stark erhöht
also falls die 500 nicht reichen sollten, gäbe es eine lösung  ;)
könnte ja sein, dass jemand die grashalme vor bernards haus animieren will und jedem einzelnen einen GI zuweist...  ;D
Schlachtaman Vibrations, UHYEAH!!!
_________________________________

>>>> Ende der Kommunikation <<<<

Link2005

Dafür Bräuchte man aber bestimmt ca. 500x10³² GIs. ;)
Aber wie viele GIs hat man mit dem PlugIn? ???

MMM Epi 63: B-DUN DX
10% - AGS-Rohdateien von B-DuN finden
25% - Story
60% - Scripten, Grafiken
85% - Betatest
100%

Bòógieman

phu keine ahnung mehr
ich glaube 1.000.000 oder so  ;)
Schlachtaman Vibrations, UHYEAH!!!
_________________________________

>>>> Ende der Kommunikation <<<<