![]() |
Instance?
Someone once tolled me that gScript was like ActionScript,
so is it possible to set instances? incase u dont know, instances make the "npc" noticealbe by other scripts like: the character is called "chr_npc" PHP Code:
|
use findnpc?
PHP Code:
|
I don't know exactly what you mean by instance, but GS2 is object-based and you can access other objects from the current 'this'. Some objects have a global identifier this.name and you can use ObjectName.variable or ObjectName.function if the function is public.
Edit: Find-NPC isn't necessary since the NPC would need a name for you to use findnpc(). |
"Instance" is just macromedia's way of trying to be unique. The term you are looking for is 'object'. As stated above, you can find the name of any npc by echoing this.name.
(Try echo(this.name);) This will only work on database npcs though but there are other ways to access level npcs such as finding the npc in the "npcs" array-variable. |
You're right.
There is a findareanpcs() function to find npcs in a specific area. Or, you could make a list in a DB npc (in the NPC you want to access somewhere else) dbNPC.foo = this; then in any other NPC you could use dbNPC.foo.x += 5; |
i dont understand how to use that stuff, could you use it in a script?
say ur trying to make an npc move called "rupert" |
Quote:
Edit: Oh my, nevermind, you can set up a global reference to the object. PHP Code:
Something I did on Aeon was to add a new global var Control pointing to Control-NPC. There is an array npcs representing all npcs in the current level. |
Quote:
|
Creating a variable like that gives it global scope???
|
Quote:
|
PHP Code:
|
Quote:
NPCRupert.chat = "whatever"; or if it was never a showchar NPCRupert.message("whatever"); |
cool, thank you guys :D
|
Quote:
PHP Code:
|
Quote:
What Stefan meant by "odd names" would be any object with a math or script character in it (Examples are: +-*/^%!@()[]{}<>'") Hope that makes sense! |
| All times are GMT +2. The time now is 11:19 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.