Jump to content

[Tutorial] Using string variables


wishy

Recommended Posts

Gonna do an attempt at showing you how to use string variables for a basic eventsystem which can easily be copy/pasted instead of having to make and edit a bunch of variables and events each time.

 

Here's a video of the result:

Spoiler

 

 

1. Create a global variable, make sure it's a string and empty

Spoiler

TT4rnYw.png

 

2. Create a map event, rename it (name must be unique per event)

3. Assign an animation or sprite to it

4. Add an event that sets the global variable (set in step 1) to 

\gv{nameofglobalvariable}\evtparam{evtName}-

(This will change the global variable to the current content of the variable + "1-", basically adding the name of the event to the current string)

Spoiler

gJ4Mgfc.png

5. Click Spawn/Execution Conditions

6. Click Add List > Add Condition

7. Check the global variable set in step 1, check if it  doesn't contain (Negated)

\evtparam{evtName}-

So anytime the global variable doesn't contain the name of the event, this page will trigger.

 

Spoiler

QUqaTgR.png

 

8. Copy/paste this page, change the sprite or animation and uncheck the negated condition

Spoiler

MOJf3pN.png

 

9. Change the event to set the global variable (set in step 1) to Find

\evtparam{evtName}-

and Replace it with an empty string.

 

(this will remove the event name from the global variable)

 

Spoiler

cn80Z13.png

 

10. Now you can copy/paste this event anywhere in your game, the only thing you need to do is change the event name to a unique name

 

full video of this tutorial:

 

Link to comment
Share on other sites

22 minutes ago, AisenArvalis said:

I have to ask, what is the point of this? It could easily be replicated just using self switches instead.

There's many possibilities for this, it's just an example that indead replicates switches, but without the need of having to make and edit a bunch of variables/switches and events each time. (says so literally in the first line of the tutorial)

You can only do a limited amount with self switches, this is more extendable, you can add character names, map names, positions etc...

 

I use this logic for all my housing, interior options, farms, doors, etc... 

Link to comment
Share on other sites

@AisenArvalisHere's an extended example of the above tutorial, hope it's a bit clearer now:

 

I should probably add that it's better practice to have condition contain a special character (adding a - at the end when you add strings and a - in front of the condition for example), like this:

iXvZtxG.png

this way, the condition does not trigger if a player should happen to have the same name as your event, because data in the string is stored like this for the above example: "eventname1:playername-eventname2:playername2-eventname3:playername"

 

Why? because playernames can't have special characters :)

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...