N00b problems with scripting tutorial

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
TheLordThyGod
Slime Knight
Posts: 220
Joined: Thu May 14, 2015 9:18 pm
Location: Muscle Shoals, AL, USA, Earth, Solar System, Milky Way, Known Universe
Contact:

N00b problems with scripting tutorial

Post by TheLordThyGod »

I am not a programmer. In the slightest. Yet.

But I'm trying to teach myself to script now.

I just did everything in the HamsterRepublic plotscripting tutorial and moved on to the Moogle1 tutorial. I'm currently working on lesson 3, specifically the first script of the lesson "zap."

I think the tutorial wants me to make an invisible NPC activated by "step on" that triggers the zap script, causing NPC 35 to appear. I have imported the script in Custom, created this NPC with step-on activation to run the zap script, and placed the NPC on the map. NPC 35 also exists. Nothing happens when I step on the NPC tile.

My script is below. I've checked it against Moogle1's tutorial, and can't find anything wrong. Any idea what I might be missing?

#------------------------
#ZAP

define script (4,zap,none)

script,zap,begin
if (herodirection(me)==west) then
(
set npc position(35,herox(me)--1,heroy(me))
)
if (herodirection(me)==north) then
(
set npc position(35,herox(me),heroy(me)--1)
)
if (herodirection(me)==east) then
(
set npc position(35,herox(me)+1,heroy(me))
)
if (herodirection(me)==south) then
(
set npc position(35,herox(me),heroy(me)+1)
)
end
Attachments
NPC
NPC
OHR NPC script issue ZAP.JPG (67 KiB) Viewed 2240 times
Last edited by TheLordThyGod on Sat Jun 17, 2017 8:56 am, edited 1 time in total.
...spake The Lord Thy God.
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

Post by marionline »

Does you Step-On-NPC look like this?
Image

I tested the script. It worked fine.
Could be that the step-on-activation is not running.
You could test this by making the npc display a textbox on step-on.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, that script is correct (although "define script" is obsolete, and so is displaying graphics using NPCs; these days you would use a slice instead).

Either the script isn't getting triggered, or it's not moving NPC ID 35 because it doesn't exist (maybe you set a "appears only if tag..." condition on it?) Or you made NPC 35 is invisible so you can't see it.

Setting the step-on NPC to show a textbox instead is a good suggestion.
You can also put a line like "show value(1)" in your script to confirm that it gets run.
User avatar
TheLordThyGod
Slime Knight
Posts: 220
Joined: Thu May 14, 2015 9:18 pm
Location: Muscle Shoals, AL, USA, Earth, Solar System, Milky Way, Known Universe
Contact:

Post by TheLordThyGod »

I set the invisible NPC to trigger a text box when stepped on, and that works. So the problem is something about either the script or NPC 35. I'm just not seeing it. Here's NPC 35.
Attachments
NPC 35
NPC 35
OHR NPC script issue NPC35.JPG (68.42 KiB) Viewed 2231 times
...spake The Lord Thy God.
User avatar
TheLordThyGod
Slime Knight
Posts: 220
Joined: Thu May 14, 2015 9:18 pm
Location: Muscle Shoals, AL, USA, Earth, Solar System, Milky Way, Known Universe
Contact:

Post by TheLordThyGod »

TMC wrote:Yes, that script is correct (although "define script" is obsolete, and so is displaying graphics using NPCs; these days you would use a slice instead).

Either the script isn't getting triggered, or it's not moving NPC ID 35 because it doesn't exist (maybe you set a "appears only if tag..." condition on it?) Or you made NPC 35 is invisible so you can't see it.

Setting the step-on NPC to show a textbox instead is a good suggestion.
You can also put a line like "show value(1)" in your script to confirm that it gets run.
I added "show value(1)" to the script and it worked, so the script is running at least.

Is there something else I'm supposed to do rather than "define script?"

I'm not to slices yet in any of the tutorials. I did see a link about them on one of the Hamster Republic pages I've been working from though, so I'm sure I'll get to that before long. I don't know the first thing about it at the moment though.
...spake The Lord Thy God.
User avatar
marionline
Metal Slime
Posts: 673
Joined: Sat Feb 26, 2011 9:23 pm

Post by marionline »

Is NPC 35 placed on the map somewhere?
User avatar
TheLordThyGod
Slime Knight
Posts: 220
Joined: Thu May 14, 2015 9:18 pm
Location: Muscle Shoals, AL, USA, Earth, Solar System, Milky Way, Known Universe
Contact:

Post by TheLordThyGod »

marionline wrote:Is NPC 35 placed on the map somewhere?
Is it supposed to be? I got the impression from the tutorial that this script was supposed to place the NPC on the map.
...spake The Lord Thy God.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, you have to place the NPC manually (probably somewhere out of sight). It's a somewhat odd way to do things. I mistakenly thought you'd done that since you said "NPC 35 also exists".
To create the NPC by script you would use the "create NPC" command. E.g. you could put "create NPC(35, 0, 0)" at the top of the script (create NPC 35 at 0,0).

The modern alternative to definescript is to write "plotscript,zap,begin" instead. plotscripts are listed in Custom, plain scripts without definescript aren't.
(If you change that, you'll have to re-set the zap script in the map editor)
Last edited by TMC on Sat Jun 17, 2017 1:35 pm, edited 1 time in total.
User avatar
TheLordThyGod
Slime Knight
Posts: 220
Joined: Thu May 14, 2015 9:18 pm
Location: Muscle Shoals, AL, USA, Earth, Solar System, Milky Way, Known Universe
Contact:

Post by TheLordThyGod »

Thanks, now I see what's expected. The Moogle1 tutorial has some issues with clarity. I plan on sticking with it though, as I need to be walked through a lot of basics and see how they work in practice.
...spake The Lord Thy God.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7660
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

I'll bet that tutorial may have been written before the "create NPC" command even existed.

I know for a while it was standard practice to hide copies of NPCs for scripts way off in a corner of the map, and move them onscreen when ready.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Oh! It never occurred to me that create NPC wasn't one of the very first script commands. It was added in 2001.
User avatar
Holofox
Slime
Posts: 16
Joined: Thu Aug 03, 2017 8:48 pm
Location: New Zulin* mythical place near Austraaaaaaaalia, in the land of the long white cloud

Post by Holofox »

Hey, how do you create npcs anyway? Iv'e read the basic tutorial, but the option at the load game/create new game screen doesn't exsist for me though thats where the tutorial is claiming it to be.
KutKu
Red Slime
Posts: 31
Joined: Sun Jan 01, 2017 11:17 pm

Post by KutKu »

I'm assuming you've already created a new "project.rpg" and loaded it up. Also how much time have spent applying yourself to learn OHR?

Now a days OHR comes with a few placeholder graphics built in. There's three NPCs sprites with their palettes already colored in. However, there's one graphic type created within maptile 0. Luckily OHR has you covered for that.

Anyway, first you have to create the data for a map. [Edit Map Data]

Luckily there's also a map created when you start a game from scratch. "Map 0:" So all you have to do next is select it from the list and press enter or space. My first piece of actual advice is to give your map a very specific name. It's the last option "Map name:" If say for instance all you're doing is just adding NPCs to see what they look like, call it "Checking out my NPCs" or "NPC appearance room" This is to make sure that you don't get confused later on when you may have 100 or more maps.

Once you've given your map an appropriate name, select the option "Edit NPCs..." there's already one there with a picture, but we want to make a new one. So instead select "Add new NPC" and press space/or enter. Your NPC should already be highlighted and confirm that NPC again and you should go to the next menu.

From there you can do anything to your hearts content.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Holofox wrote:Hey, how do you create npcs anyway? Iv'e read the basic tutorial, but the option at the load game/create new game screen doesn't exsist for me though thats where the tutorial is claiming it to be.
Which tutorial? Moogle's? The plotscripting tutorial on the wiki? I don't know what 'option' you're referring to, or whether you're asking how to create an NPC using a script (you use the create npc command for that).

Also, welcome!
Post Reply