N00b problems with scripting tutorial
Moderators: marionline, SDHawk
- 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
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
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
- OHR NPC script issue ZAP.JPG (67 KiB) Viewed 2242 times
Last edited by TheLordThyGod on Sat Jun 17, 2017 8:56 am, edited 1 time in total.
...spake The Lord Thy God.
- marionline
- Metal Slime
- Posts: 673
- Joined: Sat Feb 26, 2011 9:23 pm
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.
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.
- 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:
- 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:
I added "show value(1)" to the script and it worked, so the script is running at least.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.
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.
- marionline
- Metal Slime
- Posts: 673
- Joined: Sat Feb 26, 2011 9:23 pm
- 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:
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)
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.
- 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:
- Bob the Hamster
- Lord of the Slimes
- Posts: 7660
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
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.
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.
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).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.
Also, welcome!