Plantable Tiles Help plz

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
TheInquisitor
New User
Posts: 2
Joined: Sat Nov 28, 2009 5:20 pm

Plantable Tiles Help plz

Post by TheInquisitor »

pol core 98 using zulu hotel 98 conversion jaceace posted
i have already fixed alot on it somehow lol

hi im new to pol and have been working for a week on getting a server set up however i seem to be stuck on something i wanted to do

i am a complete noob at pol but i have managed well until with point lol

what i wanted to do is make a tile that can be locked down and then plant seeds on it now i just tried to duplicate what i seen for the land tile only using item it compiles but does not work i have tried many things so far lol
here are the 2 scripts i believe is what i have to modify
note: i even tried adding it as its own function and yes i made the dirt tile item already
i can place my tile down lock it down but cannot plant a seed on it

Code: Select all

use uo;
use cfgfile;
use os;

program plant_seed(character, seed)

	var cfg := ReadConfigFile("::itemdesc");

	if (!cfg)
        	return;
	endif

	var where := character;

	if (!is_plantable(GetMapInfo(where.x, where.y).landtile))
        	SendSysMessage(character, "You cannot plant here!");
        	return;
	endif
	
	var parms := {};
	parms[1] := where;
	parms[2] := cfg[seed.objtype].plant;

	start_script("seedling", parms);
	SubtractAmount(seed,1);
	SendSysMessage(character, "You plant the seed");

endprogram

function is_plantable(maptile)

var itemid         :={itemid};
	

if (maptile >= 0x9 && maptile <= 0x15)
        	return 1;
	elseif (maptile >= 0x14f && maptile <= 0x15c)
        	return 1;       
	
        elseif (itemid >= 0x31f4 && itemid <= 0x31f7)
        	return 1;
	elseif (itemid >= 0x32c9 && itemid <= 0x32ca)
        	return 1;       
	else
        	return 0;
	endif

endfunction

Code: Select all

C:\Users\Windows 7\Desktop\pol 98\pkg\opt\farming\seed.src, Line 5
program plant_seed(character, seed)
use os;
0: get arg 'character'
1: get arg 'seed'
var cfg := ReadConfigFile("::itemdesc");
2: decl local #2
3: "::itemdesc"
4: Func(3,0): ReadConfigFile
5: :=
6: #
if (!cfg)
7: local #2
8: if true goto 11
return;
9: ""
10: progend
var where := character;
11: decl local #3
12: local #0
13: :=
14: #
if (!is_plantable(GetMapInfo(where.x, where.y).landtile))
15: local #3
16: get member id 'x' (0)
17: local #3
18: get member id 'y' (1)
19: "britannia"
20: Func(2,0): GetMapInfo
21: get member 'landtile'
22: makelocal
23: jmp userfunc @65
24: if true goto 33
SendSysMessage(character, "You cannot plant here!");
25: local #0
26: "You cannot plant here!"
27: 3L
28: 1000L
29: Func(2,1): SendSysMessage
30: #
return;
31: ""
32: progend
var parms := {};
33: decl local #4
34: array
35: :=
36: #
parms[1] := where;
37: local #4
38: 1L
39: local #3
40: [] := (1) #
parms[2] := cfg[seed.objtype].plant;
41: local #4
42: 2L
43: local #2
44: local #1
45: get member id 'objtype' (4)
46: [] 1
47: get member 'plant'
48: [] := (1) #
start_script("seedling", parms);
49: "seedling"
50: local #4
51: Func(4,0): Start_Script
52: #
SubtractAmount(seed,1);
53: local #1
54: 1L
55: Func(2,2): SubtractAmount
56: #
SendSysMessage(character, "You plant the seed");
57: local #0
58: "You plant the seed"
59: 3L
60: 1000L
61: Func(2,1): SendSysMessage
62: #
63: leave block(5)
64: progend
C:\Users\Windows 7\Desktop\pol 98\pkg\opt\farming\seed.src, Line 30
function is_plantable(maptile)
65: pop param 'maptile'
var itemid         :={itemid};
66: decl local #1
67: array
68: local #1
69: init{}
70: :=
71: #
if (maptile >= 0x9 && maptile <= 0x15)
72: local #0
73: 9L
74: >=
75: local #0
76: 21L
77: <=
78: &&
79: if false goto 83
return 1;
80: 1L
81: return
82: goto118
elseif (maptile >= 0x14f && maptile <= 0x15c)
83: local #0
84: 335L
85: >=
86: local #0
87: 348L
88: <=
89: &&
90: if false goto 94
return 1;       
91: 1L
92: return
93: goto118
elseif (itemid >= 0x31f4 && itemid <= 0x31f7)
94: local #1
95: 12788L
96: >=
97: local #1
98: 12791L
99: <=
100: &&
101: if false goto 105
return 1;
102: 1L
103: return
104: goto118
elseif (itemid >= 0x32c9 && itemid <= 0x32ca)
105: local #1
106: 13001L
107: >=
108: local #1
109: 13002L
110: <=
111: &&
112: if false goto 116
return 1;       
113: 1L
114: return
115: goto118
return 0;
116: 0L
117: return
118: 0L
119: return
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Re: Plantable Tiles Help plz

Post by Yukiko »

The GetMapInfo function reads the terrain map data not the dynamic, or user placed, items in the game world.

If you are testing for a dynamic item in the world you want to use ListItemsAtLocation to see if your tile exists there.

Also you want to pass the value of the objtype member for the tile by referencing it with .objtype as in the following example:

Code: Select all

    foreach item in ListItemsAtLocation(character.x, character.y, character.z)
        if (!is_plantable(item.objtype))
            SendSysMessage(character, "You cannot plant here!");
            return 0;
        end
    endforeach
You would want to use the GetMapInfo function if you were going to use the "natural" or pre-existing map terrain rather than using tiles placed in the world.
User avatar
TheInquisitor
New User
Posts: 2
Joined: Sat Nov 28, 2009 5:20 pm

Re: Plantable Tiles Help plz

Post by TheInquisitor »

thnx much this worked :)
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Re: Plantable Tiles Help plz

Post by Yukiko »

Glad I could help.
Post Reply