|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Fri Feb 22, 2008 6:50 pm
Portal room cost |
How do I set a portals room cost via a script (the portal was created using #PORTAL) command.
|
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Mon Mar 03, 2008 7:54 am |
OK, your question is rather vague, so let's see what we can do. Let's assume that you walked to the portal target room and entered
on the command line.
If you did as assumed, you need to do either of two things first: A) Find out what the roomvnum for that room is, or B) assign a short name to that room.
The most flexible way is B), of course. You can assign a short name to the room by entering a string in the appropriate place in the "other" tab of the property box. My preference is to enter the room name as the short name, that way I don't have to remember any thing special.
After you have done this, then you can do the following to assign a room cost programmatically:
Code: |
$rm = %roommode()
#CALL %roommode(1)
#CALL %roomcost(shortnameofroom,desiredroomcost)
#CALL %roommode($rm)
|
If, instead, you rather use the roomvnum then:
Code: |
$rm = %roommode()
#CALL %roommode(0)
#CALL %roomcost(roomvnum,desiredroomcost)
#CALL %roommode($rm)
|
shortnameofroom is a string, so either provide a string variable or place the actual name in double-quotes. roomvnum is an integer value.
If you are in the habit of assigning short names to relevant rooms such portal destinations, you can force the room mode to always be set by checking the appropriate box in the map properties or simply have the flag set at connect time, then your code will look simply like this:
Code: |
#CALL %roomcost(shortnameofroom,desiredroomcost)
|
To use this simplified code, just add a short name to all the important rooms, such as zone entrances, portal destinations, rooms that are targetted by triggers, etc. This makes scripting the mapper much easier, and if you export the zone to another map database (sending your created zone to someone else, for instance, or just copying your zone to another mdb) your script will still work even if the roomvnum changes.
You can add short names to your rooms via script by doing the following:
Code: |
#CALL %roomid(roomvnum,roomshortname)
or
$CALL %roomid(,roomshortname)
|
The second version assumes that you want to add the short name to the current map location.
This may not be exactly what you want, but the idea holds for any situation that requires scripting with data obtained from the mdb, or to dynamically modify the mdb. |
|
_________________ Sic itur ad astra. |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Tue Mar 04, 2008 1:26 am |
That almost does the trick that changes the roomcost of the final room that i go in. But not the portal. If I go into Edit->Portal And click on the portal, i see a cost field that should be associated w/ that portal. That is the cost that I am trying to set.
Thanks |
|
|
|
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Tue Mar 04, 2008 1:38 am |
I don't think that there is a way to change that cost via script, not that I've found. Similarly, and to my frustration, the disable_all_portals flag cannot be changed via script. I added it to the mapper wishlist. Let's hope that Zugg sees the need for it. There is something peculiar about that cost also, I've changed it and didn't see any apparent results. So I just changed the target room, instead. Of course, I could have been doing it wrong.
|
|
_________________ Sic itur ad astra. |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Tue Mar 04, 2008 5:49 pm |
I came up with a lua script that will let me change the cost of the portal. You will need to get luasql.odbc this can be found from http://www.keplerproject.org/luasql/ . And then you will need to register the database with windows. the dsl_map on the connect line will need to be changed to match the name that you registered. This will create a function called set_portal_cost. With two params. The first one is the portalid (what you type at the command line to use the portal) and the second one is the cost to use the portal.
<event event="onLoad" priority="770" language="Lua" id="77">
<value>require "luasql.odbc"
map_env=luasql.odbc()
map_conn=assert(map_env:connect("dsl_map"));
function set_portal_cost(portalid,cost)
assert(map_conn:execute("UPDATE PortalTbl SET Cost="..cost.." WHERE Name='"..portalid.."'"));
assert(map_conn:commit());cur=map_conn:execute("SELECT * FROM PortalTbl");
print(cur:fetch());
end;</value>
</event> |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Tue Mar 04, 2008 7:28 pm |
cazador wrote: |
And then you will need to register the database with windows. |
Care to elaborate on that step? At one point, many moons ago, I knew how to do this, but I've definitely forgotten. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
cazador Apprentice
Joined: 08 Dec 2005 Posts: 108
|
Posted: Tue Mar 04, 2008 9:00 pm |
Start -> control panel ->Administrator tools -> Data Sources :
Add .
Pick the Microsoft Access driver -> Finish. Fill in the name for Data Source Name (that is the name you are going to use in the script)
then click on Select, and find the database that you are looking for. You'll be all set at that point. |
|
|
|
|
|