Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Assign a variable with the map tileset value?

Status
Not open for further replies.

TheZealot

Villager
Xy$
0.00
I'm trying to make it so a certain item will only work if it's used on a map using either the overworld, outside, or SF outside tilesets, but I can't find anything to make it work that way. Anyone know how?
 

CT_Bolt

Global Moderator
Staff member
Resource Team
Xy$
0.02
Hmm... depending on what the item does I have a few different approaches...

In the example below I've created an item that will teleport the user to a specific spot when used.

Create an item and set a common event under "Effects".

In that common event use a conditional branch with the following script:
JavaScript:
$gameMap.tileset().name === "Outside" || $gameMap.tileset().name === "Overworld" || $gameMap.tileset().name === "SF Outside"
...or if you want to use the Tileset ID's instead:
JavaScript:
$gameMap.tileset().id=== 1 || $gameMap.tileset().id=== 2 || $gameMap.tileset().id=== 5
  • If the condition is met then you event it to do what ever you want the item to do...
  • Else if the condition is not met then return the item to the player since it was actually used and triggered the common event & display a message saying it can't be used.
    • (only return it if you want, you could also make the player waste it)

You can also set the Item's "Occasion" to "Menu Screen" if you don't want the item to be used in battle.

Item Setup:


Common Event:
However this is only actually a "work around".
As the item really is being used the other effects/damage/etc. would still be done also.

That being said this seems to be the best way without using a plugin. (wink)

Using Yanfly's Item Requirement Plugin you can do more and it's easy to setup.
Use that plugin with the following item notetag:
JavaScript:
<Enable Requirements>
Eval: $gameMap.tileset().name === "Outside" || $gameMap.tileset().name === "Overworld" || $gameMap.tileset().name === "SF Outside"
</Enable Requirements>

Let me know if that helps. (cool)(thumbsup)
 
Last edited:

TheZealot

Villager
Xy$
0.00
I completely forgot that I can manually put in JavaScript code in the conditional statements! Thanks a bunch, that helps a ton!

The item in question actually calls a common event, so adding the JavaScript bit to an if...else statement worked perfectly. Again, thanks a ton!
 

CT_Bolt

Global Moderator
Staff member
Resource Team
Xy$
0.02
I completely forgot that I can manually put in JavaScript code in the conditional statements! Thanks a bunch, that helps a ton!

The item in question actually calls a common event, so adding the JavaScript bit to an if...else statement worked perfectly. Again, thanks a ton!
Oh that's wonderful to hear! No problem. Happy to help. (cute)(thumbsup)

I'll be around if you need anything else. (cool)(icecream)

Problem solved.Thread now closed.
 
Status
Not open for further replies.
Top