Dynamical "custom properties"

Started by Hogofogo, Thu 05/09/2013 09:52:09

Previous topic - Next topic

Hogofogo

Hello wise ags masters,

Question: is there a way to have "custom properties" for objects, characters, hotspots which can by dynamically changed from script? Also they need to stay even when I'm changing rooms.

Same question with background info: I'm trying to create simple interface where you use just left mouse button. You use it for walking, when you hover cursor over some object/hotspot/character cursor will change to look cursor/interact cursor/talk cursor. And behavior can change, for example first action on character can be look, second talk etc. That is already working as I played a lot with global script - repeatedly_execute,on_mouse_click, with iItem_<action> events and with my own gui. Now what I want: when I click on item in gui, cursor will change to that item (already working) and I can move that cursor over room and when I hover with that cursor over some hotspot/character/object, cursor will change to same "glowing" item, this indicate that item can be used, that some action will happen. Change cursor graphics is simple but I don't know how to do testing condition. My idea is to put in globalscript in function repeatedly_execute() something like

if (  (room == something) and (GetAtScreen(mouse.x,mouse.y).ListOfUsableItems contains player.ActiveInventory)   ) then mouse.ChangeModeGraphics(glowingItemSprite)

So how to implement "listOfUsableItems"? And this list must be possible change dynamically.

Or is there possibility to implement OnMouseOver event to each object/char/hotspot? That would make everything easier.


Any answer appreciated, thanks :)

Khris

#1
Hi Hogofogo,
Quote from: Hogofogo on Thu 05/09/2013 09:52:09Or is there possibility to implement OnMouseOver event to each object/char/hotspot?
while there is, (at least for hotspots, I think,) no, don't ever implement global behavior on a per-item basis. Never, ever :)

What you do is use if (GetLocationType(mouse.x, mouse.y) != eLocationNothing).
This will be true if the mouse is above a hotspot, character or object.

As for custom properties that can be changed at runtime, there is a module for that floating around. Just search the module section for that term.
If you rather implement things yourself, the basic idea is to create a global array with however many indexes you're going to need.
Say you want to attach a String property to every hotspot in order to be able to change their name:
If your game has 10 rooms, you'll need a global String hotspot_name[400]; to cover every hotspot. In game, simply do hotspot[(player.Room-1)*40 + hPortait.ID] = "New name";

Hogofogo

That should work. I will try it.

Thank you

SMF spam blocked by CleanTalk