Hi,
I have 650 rooms interconnected like a map. I want to be able to set a terrain attribute for a room so that it has specific properties, water, mountain, desert, forest, ect. I want to be able to change the grid_fill to a specific color water= blue, forest = green, ect. How do i set a "terrain" attribute and have it communicate with the specific room i want?
map and drawing grid
water
communicator
, tick enabled when game beginscommunicator
and paste thisif (game.pov.parent.terrain= "water") {
game.pov.parent.grid_fill = "blue"
}
redraw
Grid_Redraw
functioncommunicator
and upgrade itif (game.pov.parent.terrain= "water") {
game.pov.parent.grid_fill = "blue"
}
Grid_Redraw
magicalseed
, go to inventory tab, tick object can be taken
magicalseed
, tick use
, go to use tab, at use on its own
,run script
, enter code view and type ingame.pov.parent.terrain = "forest"
communicator
and upgrade it againif (game.pov.parent.terrain= "water") {
game.pov.parent.grid_fill = "blue"
}
if (game.pov.parent.terrain= "forest") {
game.pov.parent.grid_fill = "green"
}
Grid_Redraw
use
the magicalseed, whichever the player is in, that room becomes forest immediately and the room becomes green respectivelyQuick demo/ Sample code (Customize according to what you need)
To paste the code
<!--Saved by Quest 5.8.6836.13983-->
<asl version="580">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="test14">
<gameid>3e197e1d-2fc8-4d76-8ce4-d74c8ce580c5</gameid>
<version>1.0</version>
<firstpublished>2024</firstpublished>
<gridmap />
</game>
<object name="room">
<inherit name="editor_room" />
<isroom />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<exit alias="north" to="room2">
<inherit name="northdirection" />
</exit>
<object name="magicalseed">
<inherit name="editor_object" />
<take />
<feature_usegive />
<use type="script">
game.pov.parent.terrain = "forest"
</use>
</object>
</object>
<object name="room2">
<inherit name="editor_room" />
<terrain>water</terrain>
<exit alias="south" to="room">
<inherit name="southdirection" />
</exit>
</object>
<turnscript name="communicator">
<enabled />
<script>
if (game.pov.parent.terrain= "water") {
game.pov.parent.grid_fill = "blue"
}
if (game.pov.parent.terrain= "forest") {
game.pov.parent.grid_fill = "green"
}
Grid_Redraw
</script>
</turnscript>
<function name="Grid_Redraw">
foreach (object, AllObjects()) {
if (Grid_GetRoomBooleanForPlayer(game.pov, object, "grid_isdrawn")) {
Grid_DrawRoom (object, true, game.pov)
}
}
</function>
</asl>
I have 650 rooms interconnected like a map. I want to be able to set a terrain attribute for a room so that it has specific properties, water, mountain, desert, forest, ect. I want to be able to change the grid_fill to a specific color water= blue, forest = green, ect. How do i set a "terrain" attribute and have it communicate with the specific room i want?
If you want this to change when you change the terrain, the simplest way would be to use a change script. This changes the colour every time the terrain changes.
A script like this in your start script would set the initial colour for all rooms, and then set them up to change automatically if the terrain changes.
foreach (room, AllRooms ()) {
room.changedterrain => {
terrains = Split("water;forest;desert")
colours = Split ("blue;green;yellow")
if (ListContains (terrains, this.terrain)) {
i = IndexOf (terrains, this.terrain)
this.grid_fill = ListItem (colours, i)
}
}
room.changedgrid_fill => {
if (room.grid_render) {
Grid_Redraw ()
Grid_DrawPlayerInRoom (game.pov.parent)
}
}
if (HasString (room, "terrain")) {
do (room, "changedterrain")
}
}
Then you can set the room's terrain like any other attribute.
I'm not sure what I'm doing wrong. I placed the code in the game start script and then created the attribute "terrain" in the room attribute's tab. I set the terrain value to string and input the variable "water". When I run the game, there appears to be no change. Did i forget something?
Hmm… I've not used the grid system much. Let me try this out to see what the issue might be…
Ah, I was mixing up details of Quest's map system with a different engine. grid_render
records whether a room is currently drawn, not whether it should be hidden from the map. So my script was only setting up the script for rooms which are already drawn.
I'll edit the script above, so that it will work correctly.
(edited now… I don't really understand why it's necessary to redraw the whole grid, but apparently telling it to just redraw one room doesn't work. I need to understand Paper.js better if I'm going to do more with the map)