How can I access my RoomScript functions,variables from my own Scripts?

Started by fancasopedia, Sat 31/08/2019 11:03:06

Previous topic - Next topic

fancasopedia

Hello,
  How can I  access  functions and variables   that   I created in my RoomScript from my own scripts like GlobalScript,Inventory,Player? I can access my variables and function in RoomScripts. Because my own scripts has header, therefore i am importing them globally but RoomScripts not.

eri0o

You can't. Scripts are ordered so that the lower script can't be called by the script above, only the other way, and the room script is always the lowest.

To elaborate, you can create on your script modules something like

MyObj.asc
Code: ags

void DealWithAnObject(Object* obj) {
  // Do something with obj
}


MyObj.ash
Code: ags

import void DealWithAnObject(Object* obj);


So in this way on your room script, you can call the above script, and it will be able to work with that room object you passed above. Inventory, player and other characters are globals, so they are accessible on module scripts and room scripts.

Crimson Wizard


Khris

To be clear: any variable / function that is supposed to be accessed from global scripts and room scripts has to be declared globally, in the topmost script that needs access.
If you only need a few globals you can use the Global Variables section of the Project tree.

SMF spam blocked by CleanTalk