Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] createTerrain

1527942386

Edited 1527963692
MyRoll20Stuffs
API Scripter
I created this script to create a terrain or effect underneath a targeted token / character. It is suppose to serve 2 purposes: 1) Set up rough terrain obstacles long before the players go to this 2) Have an npc drop terrain effects as they move&nbsp; An example of situation #2 goes like this: have an NPC like a kobold spill grease on the ground as he moves. Next turn have him spawn "fire" with this command, right next to the grease. All the grease catches fire and the NPCs can use all sorts of other terrain effects / obstacles to funnel the party where they want them to go. Here's the script: /* createTerain v0.71 By: Kastion Profile: <a href="https://app.roll20.net/users/3173313/kastion" rel="nofollow">https://app.roll20.net/users/3173313/kastion</a> --------------------------------------------------------- Create Obstacles / Elements Commands: --------------------------------------------------------- !create acid @{selected|character_id} !create ash @{selected|character_id} !create balls @{selected|character_id} !create bramble @{selected|character_id} !create branches @{selected|character_id} !create blood @{selected|character_id} !create caltrops @{selected|character_id} !create coral @{selected|character_id} !create fire @{selected|character_id} !create foam @{selected|character_id} !create gas @{selected|character_id} !create glass @{selected|character_id} !create glue @{selected|character_id} !create grease @{selected|character_id} !create ice @{selected|character_id} !create lava @{selected|character_id} !create marbles @{selected|character_id} !create marsh @{selected|character_id} !create mud @{selected|character_id} !create rocks @{selected|character_id} !create sand @{selected|character_id} !create shock @{selected|character_id} !create shrub @{selected|character_id} !create smoke @{selected|character_id} !create snow @{selected|character_id} !create water @{selected|character_id} !create web @{selected|character_id} */ var acid_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53695993/aLrdNuNBK_h23Do3k8RhEw/thumb.png?15260525125#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53695993/aLrdNuNBK_h23Do3k8RhEw/thumb.png?15260525125#.png</a>", &nbsp;&nbsp;&nbsp; ash_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55185107/4CgV7CuVU1uqPr9MWv290w/thumb.png?15279373045#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55185107/4CgV7CuVU1uqPr9MWv290w/thumb.png?15279373045#.png</a>", &nbsp;&nbsp;&nbsp; balls_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53683250/A3Z7szxzwhLulTNjvbxgBw/thumb.png?15260322965#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53683250/A3Z7szxzwhLulTNjvbxgBw/thumb.png?15260322965#.png</a>", &nbsp;&nbsp;&nbsp; bramble_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55180902/0KS_rodI24Rh1RK97iuMgQ/thumb.png?15279287585#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55180902/0KS_rodI24Rh1RK97iuMgQ/thumb.png?15279287585#.png</a>", &nbsp;&nbsp;&nbsp; branches_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55185590/jpy0PDgpqncCzSBEV6FNsg/thumb.png?15279383345#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55185590/jpy0PDgpqncCzSBEV6FNsg/thumb.png?15279383345#.png</a>", &nbsp;&nbsp;&nbsp; blood_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53051008/Vno5kc8_em0yquxXltwbyQ/thumb.png?15251824175#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53051008/Vno5kc8_em0yquxXltwbyQ/thumb.png?15251824175#.png</a>", &nbsp;&nbsp;&nbsp; caltrops_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53524631/XAVdLxigZ12Z7FWOF_ZGww/thumb.png?15258058995#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53524631/XAVdLxigZ12Z7FWOF_ZGww/thumb.png?15258058995#.png</a>", &nbsp;&nbsp;&nbsp; coral_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55181488/tUBdPWQSPY39PPwfDggXDA/thumb.png?15279297745#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55181488/tUBdPWQSPY39PPwfDggXDA/thumb.png?15279297745#.png</a>", &nbsp;&nbsp;&nbsp; fire_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53533619/ZbnZ992UHoJUQW2_KQJtiQ/thumb.png?15258157335#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53533619/ZbnZ992UHoJUQW2_KQJtiQ/thumb.png?15258157335#.png</a>", &nbsp;&nbsp;&nbsp; foam_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53695879/meu5NplQDGv3BeQThSOtEQ/thumb.png?15260522785#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53695879/meu5NplQDGv3BeQThSOtEQ/thumb.png?15260522785#.png</a>", &nbsp;&nbsp;&nbsp; gas_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55180737/mtxBaSuTdCbmNiTP_kEpqw/thumb.png?15279283675#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55180737/mtxBaSuTdCbmNiTP_kEpqw/thumb.png?15279283675#.png</a>", &nbsp;&nbsp;&nbsp; glass_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55185020/uyXWIPk86rhCWzXmumb4JA/thumb.png?15279371335#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55185020/uyXWIPk86rhCWzXmumb4JA/thumb.png?15279371335#.png</a>", &nbsp;&nbsp;&nbsp; glue_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53680978/dgB-IwYWgVEPKH8ERWZZYA/thumb.png?15260254695#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53680978/dgB-IwYWgVEPKH8ERWZZYA/thumb.png?15260254695#.png</a>", &nbsp;&nbsp;&nbsp; grease_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53682542/9ORQuNsS4yyhOpqxIfC4PQ/thumb.png?15260305355#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53682542/9ORQuNsS4yyhOpqxIfC4PQ/thumb.png?15260305355#.png</a>", &nbsp;&nbsp;&nbsp; ice_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53681599/Kn3UtkSE0gCgP6lKsOZRBg/thumb.png?15260276215#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53681599/Kn3UtkSE0gCgP6lKsOZRBg/thumb.png?15260276215#.png</a>", &nbsp;&nbsp;&nbsp; lava_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55180820/pSMl60oodiCtuRdWzJgzfA/thumb.png?15279285465#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55180820/pSMl60oodiCtuRdWzJgzfA/thumb.png?15279285465#.png</a>", &nbsp;&nbsp;&nbsp; marbles_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53682724/fMJvZqsUxeKUIm6GYYwSJQ/thumb.png?15260308385#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53682724/fMJvZqsUxeKUIm6GYYwSJQ/thumb.png?15260308385#.png</a>", &nbsp;&nbsp;&nbsp; marsh_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55181384/RbK_06n4FU4INd1f6ERxHw/thumb.png?15279295415#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55181384/RbK_06n4FU4INd1f6ERxHw/thumb.png?15279295415#.png</a>", &nbsp;&nbsp;&nbsp; mud_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55181722/hQ4SH17XauqJ-Uh3p96cKg/thumb.png?15279303345#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55181722/hQ4SH17XauqJ-Uh3p96cKg/thumb.png?15279303345#.png</a>", &nbsp;&nbsp;&nbsp; rocks_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53683086/t2AzEXFgS_3l9R6B-4vSRQ/thumb.png?15260318295#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53683086/t2AzEXFgS_3l9R6B-4vSRQ/thumb.png?15260318295#.png</a>", &nbsp;&nbsp;&nbsp; sand_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55181261/VWFZCLR5X53mqxehWQ0c5A/thumb.png?15279292895#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55181261/VWFZCLR5X53mqxehWQ0c5A/thumb.png?15279292895#.png</a>", &nbsp;&nbsp;&nbsp; shock_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53696347/8nn5PAtnHRLnteijUkENeA/thumb.png?15260531935#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53696347/8nn5PAtnHRLnteijUkENeA/thumb.png?15260531935#.png</a>", &nbsp;&nbsp;&nbsp; shrub_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55185658/nOOZ-UqN7991kP6G9_43Qg/thumb.png?15279384705#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55185658/nOOZ-UqN7991kP6G9_43Qg/thumb.png?15279384705#.png</a>", &nbsp;&nbsp;&nbsp; smoke_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53535877/cU_ESc0V25nr9YZyyGgJ6Q/thumb.png?15258182285#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53535877/cU_ESc0V25nr9YZyyGgJ6Q/thumb.png?15258182285#.png</a>", &nbsp;&nbsp;&nbsp; snow_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55181536/xPwWZ3TcLOPbIdh6DZ2k4g/thumb.png?15279299175#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55181536/xPwWZ3TcLOPbIdh6DZ2k4g/thumb.png?15279299175#.png</a>", &nbsp;&nbsp;&nbsp; water_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/53682782/VAEqPyecgXkYYCby4SmydA/thumb.png?15260309965#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/53682782/VAEqPyecgXkYYCby4SmydA/thumb.png?15260309965#.png</a>", &nbsp;&nbsp;&nbsp; web_imgsrc = "<a href="https://s3.amazonaws.com/files.d20.io/images/55185406/dQ3z9PIEQujaKvs8PfuIkg/thumb.png?15279378895#.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/55185406/dQ3z9PIEQujaKvs8PfuIkg/thumb.png?15279378895#.png</a>"; on('ready', function() { &nbsp;&nbsp;&nbsp; log("-=&gt; Create Terrain Script Loaded - (Last Edited by Kastion [02/06/2018]) &lt;=-"); &nbsp;&nbsp;&nbsp; on('chat:message', function(msg) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (msg.type == "api" && playerIsGM(msg.playerid) && msg.content.indexOf("!create") !== -1) { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var terrain = msg.content.split(' ')[1]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var charid = msg.content.split(' ')[2]; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var c = getObj('character',charid); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var t = findObjs({ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _type: 'graphic', &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; represents: charid &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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&nbsp;&nbsp;&nbsp;&nbsp; top: t.get('top'), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left: t.get('left'), &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name: terrain &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat('Create Terrain', '/w gm Incorrect terrain type specified. Types: acid, ash, balls, bramble, branches, blood, caltrops, coral, foam, fire, gas, glass, glue, grease, ice, lava, marbles, marsh, mud, rocks, sand, shock, shrub, smoke, snow, water, web'); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sendChat('Create Terrain', '/w gm Player / Token error or unspecified.'); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; }) }); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If you have any suggestions or ideas for new terrain or elemental effects of sort let me know and I'll try to add them to the function.
1527960527
GiGs
Pro
Sheet Author
API Scripter
Fun script! i think you could probably set up an event on token move (on("change:graphic", test its the token and that it has moved), so that a token can leave a trail of the terrain type, without user intervention. You'd need a command to switch it on and off.&nbsp; You'd probably have to use the spacebar trick when moving a token to leave the proper path. But it would be pretty cool, and also simplify setting up obstacle regions.
1527963606

Edited 1527963835
MyRoll20Stuffs
API Scripter
G G said: Fun script! i think you could probably set up an event on token move (on("change:graphic", test its the token and that it has moved), so that a token can leave a trail of the terrain type, without user intervention. You'd need a command to switch it on and off.&nbsp; You'd probably have to use the spacebar trick when moving a token to leave the proper path. But it would be pretty cool, and also simplify setting up obstacle regions. That's a great idea! I think I'll take a crack at it in the next couple of days then update the script in this thread. Until then I do one of two things: 1) Add a "create" command to a token action so when I select a token I have access to a handful of terrain / element buttons I can quickly use to drop while moving. AND 2) Use the following "master macro" I made. !create ?{Create|acid|ash|balls|bramble|branches|blood|caltrops|coral|foam|fire|gas|glass|glue|grease|ice|lava|marbles|marsh|mud|rocks|sand|shock|shrub|smoke|snow|water|web} @{selected|character_id}