can the player enter a container?

4 views
Skip to first unread message

Eric F.

unread,
Aug 4, 2011, 6:21:38 PM8/4/11
to jacl-discuss
Hello,

I was wondering if the player was supposed to enter a container (if
the size allowed this). I got a negative message when I tried to do
so, so I've made a function for this:

{enter
write "OK^"
move player to vehicle
}

Now it's written I'm in the vehicle. The problem is if I try to move,
I'll move into another random object (for example an object I own),
and after a while it will get an exception and crash.

Stuart Allen

unread,
Aug 4, 2011, 9:36:34 PM8/4/11
to jacl-d...@googlegroups.com
Hi Eric

The short answer to this is no, I never really coded for that, I
always made vehicles locations. That's not to say that it wouldn't be
possible to do though. I'd be inclined to do something like use one of
the unused properties like 'status', and when the player enters the
vehicle the player's status is set to the object that represents the
vehicle. That way the player's parent is still the actual location.
You'd then need to modify the +travel code and test if the player was
currently in a vehicle (or any other container for that matter) before
allowing any of the direction commands to be processed normally. For
example:

{+travel
...
if destination = 0
write "You can't go that way.^"
set time = false
else
set from_location = here
set player(parent) = destination
move player(status) to destination ;Bring the vehicle along too
execute "+display_location"
set time = true
endif
}

Also, don't forget that with JACL any function you define in your game
will override a function of the same name in the library so you can
just copy the whole +travel function into your game and modify it
without hacking the library directly.

Another simple option would be to add a test to the library code for
movement that says something like:

if here hasnt LOCATION
write "The only way from here is out.^"
endif

That of course presumes that the vehicle is driven with special
commands rather than just east, west etc.

You'll have to forgive me, I haven't looked at anything JACL related
for about year or some myself so I'm a bit rusty. If you have a
particular method you think would work well from a developers
perspective I can look into modifying the code.

Stuart

--
http://dangarstu.tumblr.com

Reply all
Reply to author
Forward
0 new messages