mal wieder types
Übersicht

baerserkerBetreff: mal wieder types |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
hiho!
Ich hab mal wieder ein prob. Ich hab mir mal das typetut von blitzbase durchgelesen und wollte mal ein inventarsystem machen. Code: [AUSKLAPPEN] ;types Type npc Field id,name$ Field x#,y#,z# Field hp,hp_max Field mana,mana_max,kreis Field speed#,speed_max# Field inventar.inventar End Type Type inventar Field items.items End Type Type items Field waffen.waffen Field art$ Field menge End Type Type waffen Field name$ Field x#,y#,z# Field dmg_schnitt,dmg_stich,dmg_feuer,dmg_magie Field effekte[9] Field beschreibung$ End Type Type select_npc Field npc.npc End Type ;globalen Global n.items = New items Global error$ Global pfad$ = ".." Global human.npc Global sel.select_npc = New select_npc ;head ChangeDir pfad$ ;funktionen Function createnpc(id,name$,x#,y#,z#,hp,mana,kreis,speed#,selected) human.npc = New npc human\id = id human\name$ = name$ human\x# = x# human\y# = y# human\z# = z# human\hp = hp human\hp_max = hp human\mana = mana human\mana_max = mana human\kreis = kreis human\speed_max# = speed# ;inventar anlegen human\inventar.inventar = New inventar ;human\inventar\items.items = New items ;human\inventar\items\art$ = "gold" ;human\inventar\items\menge = 0 If human = Null error$ = error$ + ", npc namens "+human\name$+" konnte nicht erstellt werden" If selected sel\npc = human End Function Function npc_ausruesten(npc.npc,scriptpfad$) If npc.npc <> Null If Not FileType(scriptpfad$) = True error$ = error$ + ", npc namens " + npc\name$ + " konnte nicht ausgerüstet werden, weil das script fehlt":return Local script = ReadFile(scriptpfad$) Local menge While Not Eof(script) Local zeile$ = Lower$(trim$(ReadLine(script))) If Instr(zeile$,"addgold") menge = Int(Replace$(zeile$,"addgold","")) If npc\inventar\items <> Null For npc\inventar\items.items = Each items If npc\inventar\items\art$ = "gold" npc\inventar\items\menge = npc\inventar\items\menge + menge EndIf Next EndIf If npc\inventar\items = Null npc\inventar\items.items = New items npc\inventar\items\art$ = "gold" npc\inventar\items\menge = menge EndIf EndIf Wend CloseFile script Return EndIf If npc.npc = Null error$ = error$ + ", konnte npc nicht finden" End Function Function updatenpc(npc.npc) For npc.npc = Each npc If npc\inventar\items <> Null Print "Der " + npc\name$ + " hat " + npc\inventar\items\menge + " " + npc\inventar\items\art$ EndIf Next End Function ;-----------------------------test----------------------------- ;s = WriteFile("_work\scripte\gold_fuer_herold.gsc") ;WriteLine s,"addgold 12440" ;WriteLine s,"addgold -240" ;-----------------------------main----------------------------- createnpc(1,"horst",0,0,0,100,10,0,10,true) npc_ausruesten(sel\npc,"_work\scripte\gold_fuer_horst.gsc") createnpc(2,"herold",0,0,0,100,10,0,10,true) npc_ausruesten(sel\npc,"_work\scripte\gold_fuer_herold.gsc") If error$ <> "" RuntimeError error$ updatenpc(sel\npc) Die scripte für horst: Code: [AUSKLAPPEN] addgold 1200 addgold -2222 für herold: Code: [AUSKLAPPEN] addgold 12440 addgold -123 das wird hoffentlich nicht beachtet addgold 32 Mein prob.: Das updatenpc sollt ja das gold der beiden anzeigen, aber er zeigt immer nur den letzten inventareintrag an. Irgendwie funzt meine überprüfung, ob es schon ein item dieser art gibt, nicht. plz help!!! ![]() ![]() ![]() |
||
bär, bär, bär... |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group