Location name on screen question
Moderators: marionline, SDHawk
Location name on screen question
Hi everyone.
I'm working on a game just now which has a fairly large overworld map (150sq x 80sqx), and what I'm hoping to be able to do is have the in-game name of areas within that map appear in the corner of the screen for a moment, then disappear (if you've played Breath of the Wild you might know the kind of effect I'm hoping to achieve - in fact, you can see it in this video in case you aren't familiar with BOTW)
I'm not sure if this is possible, and I'm not very experienced with scripting in the OHRRPGCE, but I'm keen to give it a bash if people think it can be done.
Many thanks!
I'm working on a game just now which has a fairly large overworld map (150sq x 80sqx), and what I'm hoping to be able to do is have the in-game name of areas within that map appear in the corner of the screen for a moment, then disappear (if you've played Breath of the Wild you might know the kind of effect I'm hoping to achieve - in fact, you can see it in this video in case you aren't familiar with BOTW)
I'm not sure if this is possible, and I'm not very experienced with scripting in the OHRRPGCE, but I'm keen to give it a bash if people think it can be done.
Many thanks!
See if you can work with this, set it as your on-step script for your map and fill the different areas with appropriate zones. Of course, edit the names and numbers as you see fit.
Code: Select all
global variable (1, current zone)
plotscript, check name zone, begin
variable (newzone)
## Making sure we aren't re-displaying the same zone we're already in.
newzone := zone at spot (hero x(me), hero y(me))
if (newzone == current zone) then (exit script)
## Put numbered zones inside areas, or just at the perimeter of areas.
switch (newzone) do (
case (1) $1="Plains"
case (2) $1="Forest"
case (3) $1="Mountains"
case (4) $1="Seaside"
## etc...
case (else) exit script
)
show string at (1, 10, 180) ## Lower left, more or less?
set timer (1, 5, 18, @hide name zone) ## 5 second timer before hiding area name.
current zone := newzone
end
script, hide name zone, begin
hide string (1)
end
That's a pretty nice script, so I put link to it on the wiki (no reason it couldn't have it own article).
You can simplify the script by using the name of the zone as the name of area (simply replace the 'switch' block with the line "get zone name(1, newzone)").
Also, that script won't work if you use zones for other purposes too and they overlap. So I suggest reserving a certain range of zone IDs, like 100-200 for region names. You'll then need to modify the script to check all the zones on a tile, and ignore other IDs.
You can simplify the script by using the name of the zone as the name of area (simply replace the 'switch' block with the line "get zone name(1, newzone)").
Also, that script won't work if you use zones for other purposes too and they overlap. So I suggest reserving a certain range of zone IDs, like 100-200 for region names. You'll then need to modify the script to check all the zones on a tile, and ignore other IDs.
Last edited by TMC on Sun Dec 31, 2017 6:36 am, edited 1 time in total.
Ah right, thanks for reminding me. This'll add a bit more to the script, but I have a simple method of looking through overlapped zones:
Unfortunately working this in with the current script is going to get messy and awkward very quickly.
Code: Select all
variable (i, z)
z := zone at spot (hero x(me), hero y(me), get count)
if (z > 0) then (
for (i, 0, z) do (
if (zone at spot (hero x(me), hero y(me), i) == 1) then (
## Do stuff based on zone 1
)
)
)
Last edited by Foxley on Sun Dec 31, 2017 8:41 am, edited 1 time in total.
Here we go. Tested, and it works.
EDIT: Trimmed down the code some, with TMC's input.
Code: Select all
global variable (1, current zone)
plotscript, check name zone, begin
variable (checkzone, z, i, changed)
## Loop through all potentially overlapping zones
z := zone at spot (hero x(me), hero y(me), get count)
for (i, 0, z--1) do (
## Making sure we aren't re-displaying the name zone we're already in.
checkzone := zone at spot (hero x(me), hero y(me), i)
if (checkzone == current zone) then (exit script)
## Checking for zones between 100-199, and storing the zone's
## name in string 1 if it's there.
if (checkzone >= 100 || checkzone < 200) then (
get zone name (1, checkzone)
break
)
)
show string at (1, 10, 180) ## Lower left, more or less.
set timer (1, 3, 18, @hide name zone) ## 3 second timer before hiding name.
current zone := checkzone
end
script, hide name zone, begin
hide string (1)
end
Last edited by Foxley on Sun Dec 31, 2017 9:40 am, edited 3 times in total.
Alright, so two things:
^^ This wasn't catching zones, it was actually doing jack squat because it can be over 100 or below 200, which essentially translates to "any zone". I've changed the || to &&.
I also brought back the "changed" variable, because as I expected, stepping between a zone with a name and a tile with no zone repeatedly kept re-triggering the "show string at" and the timer, so the text never went away as long as I kept moving.
Should be working just dandy now!
Code: Select all
if (checkzone >= 100 || checkzone < 200)
I also brought back the "changed" variable, because as I expected, stepping between a zone with a name and a tile with no zone repeatedly kept re-triggering the "show string at" and the timer, so the text never went away as long as I kept moving.
Should be working just dandy now!
Code: Select all
global variable (1, current zone)
plotscript, check name zone, begin
variable (checkzone, z, i, changed)
## Loop through all potentially overlapping zones
z := zone at spot (hero x(me), hero y(me), get count)
for (i, 0, z) do (
## Making sure we aren't re-displaying the name zone we're already in.
checkzone := zone at spot (hero x(me), hero y(me), i)
if (checkzone == current zone) then (exit script)
## Checking for zones between 100-199, and storing the zone's
## name in string 1 if it's there.
if (checkzone >= 100 && checkzone < 200) then (
get zone name (1, checkzone)
changed := true
break
)
)
if (changed) then (
show string at (1, 10, 180) ## Lower left, more or less.
set timer (1, 3, 18, @hide name zone) ## 3 second timer before hiding name.
current zone := checkzone
)
end
script, hide name zone, begin
hide string (1)
end
I see you uploaded an example game! Best to link to that here: Show zone names
Oops, I think I was to blame for the ||.
"for (i, 0, z) do (" should be "for (i, 0, z -- 1) do ("
What I meant by getting rid of 'changed' was to move everything in the "if (changed)" block into the for loop. But it only saves you two lines of code, so never mind.
Oops, I think I was to blame for the ||.
"for (i, 0, z) do (" should be "for (i, 0, z -- 1) do ("
What I meant by getting rid of 'changed' was to move everything in the "if (changed)" block into the for loop. But it only saves you two lines of code, so never mind.
Last edited by TMC on Tue Jan 02, 2018 4:09 am, edited 1 time in total.
Wow, I can't believe I didn't notice that earlier. Fixed that up, added the --1 back to the for loop, and it should now be good.
Code: Select all
global variable (1, current zone)
plotscript, check name zone, begin
variable (checkzone, z, i)
## Loop through all potentially overlapping zones
z := zone at spot (hero x(me), hero y(me), get count)
for (i, 0, z--1) do (
## Making sure we aren't re-displaying the name zone we're already in.
checkzone := zone at spot (hero x(me), hero y(me), i)
if (checkzone == current zone) then (exit script)
## Checking for zones between 100-199, and storing the zone's
## name in string 1 if it's there.
if (checkzone >= 100 && checkzone < 200) then (
get zone name (1, checkzone)
show string at (1, 10, 180) ## Lower left, more or less.
set timer (1, 3, 18, @hide name zone) ## 3 second timer before hiding name.
current zone := checkzone
break
)
)
end
script, hide name zone, begin
hide string (1)
end
Last edited by Foxley on Tue Jan 02, 2018 7:05 am, edited 1 time in total.