2
edits
(added a section about moving code to separate scripts. Potentially dangerous as I am relatively new to this matter. Please review.) |
|||
Line 427: | Line 427: | ||
No, you're not going insane - there's no direct way to do this. You'll have to use variables (GlobalInts or your own - see the earlier entry on [[Scripting%2C_Code_%26_Interaction#Working_with_variables:_the_basics|working with variables]]), and check them in the 'Player enters Room' interaction of the room the Object (or whatever) is in. If you're likely to need to do it a lot you might want to try the {{Thread|OtherRoom module|20650}}, which handles everything for you. | No, you're not going insane - there's no direct way to do this. You'll have to use variables (GlobalInts or your own - see the earlier entry on [[Scripting%2C_Code_%26_Interaction#Working_with_variables:_the_basics|working with variables]]), and check them in the 'Player enters Room' interaction of the room the Object (or whatever) is in. If you're likely to need to do it a lot you might want to try the {{Thread|OtherRoom module|20650}}, which handles everything for you. | ||
''But what about character actions? They are not tied to a room and I can't use variables here.'' | |||
If you know that the character is in a specific room, you can access the room's objects/hotspots/regions with appropriate variables and the corresponding index of the item you want to access: | |||
if (player.Room == 3) | |||
{ | |||
object[0].Visible = true; //make object with ID 0 visible | |||
hotspot[4].Enabled = false; // enable hotspot with ID 4 | |||
region[7].Enabled = true; // enable region with ID 7 | |||
} | |||
Note that you are entering dangerous terrain by doing this. If you remove an object from a room, all subsequent objects will move up in the list, causing their ID to decrease by 1. If you don't adapt your ID in the object[] call, you will get some weird bugs. | |||
Avoid another trap by making absolutely sure that the character is really in that room when you access the objects. If not and there is no hotspot with ID 4 in the current room, the game will crash. | |||
[[Category:AGS Beginners' FAQ]] | [[Category:AGS Beginners' FAQ]] | ||
[[Category:Scripting]] | [[Category:Scripting]] |
edits